Class ChangeRecord.Builder

  • Enclosing class:
    ChangeRecord

    public static class ChangeRecord.Builder
    extends java.lang.Object
    This class is used to construct ChangeRecord instances. At least a ChangeType and an identifiableInfo DN are required; the rest of the parameters are optional. Arbitrary properties can also be added to the object by calling addProperty(Object, Object). The setter methods return the Builder instance itself, so that these calls can be chained. When finished setting up parameters, call the build() method to create a new ChangeRecord.
    • Constructor Detail

      • Builder

        public Builder​(ChangeType type,
                       DN identifiableInfo)
        Creates a Builder which can be used to construct a ChangeRecord.
        Parameters:
        type - the ChangeType (ADD/MODIFY/MOD-DN/DELETE). This can be null to indicate a resync operation.
        identifiableInfo - a unique identifier for the entry that changed (i.e. "accountID=123"). If multiple attributes are part of the identifier, they should be separate RDN components of the DN (i.e. "accountID=123,groupID=5").
      • Builder

        public Builder​(ChangeType type,
                       java.lang.String identifiableInfo)
        Creates a Builder which can be used to construct a ChangeRecord.
        Parameters:
        type - the ChangeType (ADD/MODIFY/MOD-DN/DELETE). This can be null to indicate a resync operation.
        identifiableInfo - a unique identifier for the entry that changed (i.e. "accountID=123"). If multiple attributes are part of the identifier, they should be delimited with the default delimiter of "%%" (i.e. "accountID=123%%groupID=5").
      • Builder

        public Builder​(ChangeType type,
                       java.lang.String identifiableInfo,
                       java.lang.String delimiter)
        Creates a Builder which can be used to construct a ChangeRecord.
        Parameters:
        type - the ChangeType (ADD/MODIFY/MOD-DN/DELETE). This can be null to indicate a resync operation.
        identifiableInfo - a unique identifier for the row that changed (i.e. "accountID=123"). If multiple attributes are part of the identifier, they should be delimited with a unique string (i.e. "accountID=123%%groupID=5") which is specified by the delimiter parameter.
        delimiter - The delimiter used to split separate components of the identifiable info. If this is null, the default of "%%" will be used.
    • Method Detail

      • changeNumber

        public ChangeRecord.Builder changeNumber​(long changeNumber)
        Set the change number that identifies this particular change (if applicable). If this is not used, a change number will be automatically generated for the ChangeRecord.
        Parameters:
        changeNumber - the change number
        Returns:
        the Builder instance
      • identifiableInfoAfterChange

        public ChangeRecord.Builder identifiableInfoAfterChange​(DN identifiableInfoAfterChange)
        Set the DN of the entry after the change. This should only be used if the change type was a Modify DN.
        Parameters:
        identifiableInfoAfterChange - The final DN of the entry after the change.
        Returns:
        the Builder instance.
        Throws:
        java.lang.IllegalArgumentException - if the change type is not Modify DN.
      • changedAttributes

        public ChangeRecord.Builder changedAttributes​(java.lang.String[] changedAttributes)
        Set the set of changed attributes for this change entry.
        Parameters:
        changedAttributes - an array of attribute names that were modified as part of the change
        Returns:
        the Builder instance
      • modifier

        public ChangeRecord.Builder modifier​(java.lang.String modifier)
        Set the user account name that made the change.
        Parameters:
        modifier - the account name or user name of the entity that made the change
        Returns:
        the Builder instance
      • changeTime

        public ChangeRecord.Builder changeTime​(long changeTime)
        Set the time at which the change occurred. This should be based on the clock at the source endpoint if possible.
        Parameters:
        changeTime - the time of the change (in milliseconds since January 1, 1970 00:00:00.000 GMT)
        Returns:
        the Builder instance
      • fullEntry

        public ChangeRecord.Builder fullEntry​(Entry entry)
        Set the full source entry on this ChangeRecord. This may be desirable if the source does not provide logical separation between the "change record" and the entry itself. If this is set on the ChangeRecord, the Data Sync Server will skip the call to fetchEntry() in your extension and instead use this Entry.

        When using this mechanism, make sure to set it to a non-null Entry even on a DELETE, because this will be used to correlate to the destination entry to delete.

        Parameters:
        entry - the full source entry that was changed
        Returns:
        the Builder instance
      • addProperty

        public ChangeRecord.Builder addProperty​(java.lang.Object key,
                                                java.lang.Object value)
        Add an arbitrary attachment or property to the ChangeRecord being built. Nor the key or the value are allowed to be null.
        Parameters:
        key - the key for the property
        value - the value of the property
        Returns:
        the Builder instance
      • build

        public ChangeRecord build()
        Construct the ChangeRecord. This method may only be called once.
        Returns:
        a ChangeRecord instance