This article covers a Bloomreach Experience Manager version 11. There's an updated version available that covers our most recent release.

Filtering properties before replication

If you have properties that contain sensitive information you don't want to risk exposing in your target environment, then you may need to implement the PropertyFilter interface to filter out or modify such properties. Most of the use cases however, can be handled by the already configured generic property filter.

Use the generic property filter

If you want to simply exclude properties by name then you can use the pre-configured generic property filter. Simply add the name of the property you want to exclude to  /hippo:configuration/hippo:modules/replication/hippo:moduleconfig/metadata/filter/excludedProperties

You can use a 'contentpropadd' instruction in your hippoecm-extension.xml file for this:

  <sv:node sv:name="excludeexamplepropertyfromreplication">
    <sv:property sv:name="jcr:primaryType" sv:type="Name">
      <sv:value>hippo:initializeitem</sv:value>
    </sv:property>
    <sv:property sv:name="hippo:contentroot" sv:type="String">
      <sv:value>/hippo:configuration/hippo:modules/replication/hippo:moduleconfig/metadata/filter/excludedProperties</sv:value>
    </sv:property>
    <sv:property sv:name="hippo:contentpropadd" sv:type="String">
      <sv:value>example:example</sv:value>
    </sv:property>
    <sv:property sv:name="hippo:sequence" sv:type="Double">
      <sv:value>8992.4</sv:value>
    </sv:property>
  </sv:node>

You can also use this filter when you want to change the value of some specific property to a constant value. Specify the multi-valued configuration properties  /hippo:configuration/hippo:modules/replication/hippo:moduleconfig/metadata/filter/modifiedProperties and /hippo:configuration/hippo:modules/replication/hippo:moduleconfig/metadata/filter/modifiedValues for this purpose. Properties named in the former property get the value specified at the corresponding position in the latter property. Only properties of type string can be modified in this way.

Implement your own PropertyFilter 

If the logic to determine which properties to filter out, or the way to modify those properties, is more complicated than what can be accomplished with the generic property filter, then you must implement your own. Create a class that implements the interface  com.onehippo.cms7.replication.PropertyFilter:

/**
 * Implement this interface to filter out and/or modify certain properties before they are replicated.
 */
public interface PropertyFilter {

    /**
     * Whether the {@code property} is to be replicated or not.
     * @throws RepositoryException
     */
    boolean excludeProperty(Property property) throws RepositoryException;

    /**
     * Allows to modify the value to be sent to the target.
     * @param property  the property to be modified
     * @param value  the original value
     * @return  the modified value to be sent to the target or {@code null} if this filter
     * does not modify the value.
     * @throws RepositoryException
     */
    Value modifyValue(Property property, Value value) throws RepositoryException;

}

 If you want to be passed the moduleConfig node that registers your filter with the replication engine, then also implement the interface  com.onehippo.cms7.replication.Configurable.

To register the filter with the replication engine add a node of type hipposys:moduleconfig below  /hippo:configuration/hippo:modules/replication/hippo:moduleconfig/metadata/:

<?xml version="1.0" encoding="UTF-8"?>
<sv:node sv:name="myfilter" xmlns:sv="http://www.jcp.org/jcr/sv/1.0">
  <sv:property sv:name="jcr:primaryType" sv:type="Name">
    <sv:value>hipposys:moduleconfig</sv:value>
  </sv:property>
  <sv:property sv:name="className" sv:type="String">
    <sv:value>com.onehippo.cms7.replication.metadata.ExamplePropertyFilter</sv:value>
  </sv:property>
</sv:node>

And the hippoecm-extension.xml instruction:

  <sv:node sv:name="myreplicationpropertyfilter">
    <sv:property sv:name="jcr:primaryType" sv:type="Name">
      <sv:value>hippo:initializeitem</sv:value>
    </sv:property>
    <sv:property sv:name="hippo:contentresource" sv:type="String">
      <sv:value>myreplicationpropertyfilter.xml</sv:value>
    </sv:property>
    <sv:property sv:name="hippo:contentroot" sv:type="String">
      <sv:value>/hippo:configuration/hippo:modules/replication/hippo:moduleconfig/metadata</sv:value>
    </sv:property>
    <sv:property sv:name="hippo:sequence" sv:type="Double">
      <sv:value>8992.3</sv:value>
    </sv:property>
  </sv:node>

Note that the same class may implement both the PropertyFilter interface and the ReplicationScopeProvider interface.

 

Did you find this page helpful?
How could this documentation serve you better?
On this page
    Did you find this page helpful?
    How could this documentation serve you better?