Class SyncTask

  • All Implemented Interfaces:
    Runnable

    public class SyncTask
    extends TimerTask
    Routine for uploading and updating entries from a source LDAP v3 directory to a target LDAP v3 directory accessed by means of a Json2Ldap web API.

    The routine performs the following steps:

    1. Retrieves the source directory entries for upload / update by making an LDAP search request using the specified Configuration.SourceDirectory.Search criteria.
    2. Retrieves all previously uploaded entries in the target directory under the Configuration.TargetDirectory.baseDn branch (using LDAP search).
    3. Uploads the source directory entries that are missing in the target branch (using LDAP add). They receive an RDN attribute Configuration.TargetDirectory.rdnAttribute. The attributes to upload and their source name -> target name mapping is given by Configuration.Sync.attributeMap.
    4. Updates the target entries whose corresponding mapped source entry attributes have changed (using LDAP modify).
    5. Deletes the target directory entries that don't have a corresponding source entry (using LDAP delete).

    The run() method performs the upload and update algorithm. The TimerTask interface of this class can be used to run the synchronisation periodically on a dedicated thread.

    During the run of a sync task subscribed objects receive events that allow the progress and any exceptions to be monitored. The event types are described in the run() method comments.

    • Constructor Detail

      • SyncTask

        public SyncTask​(Configuration config)
        Creates a new synchronisation task with the specified configuration.
        Parameters:
        config - The configuration parameters.
    • Method Detail

      • addListener

        public boolean addListener​(SyncTaskEventListener listener)
        Registers a new listener for synchronisation task events.
        Parameters:
        listener - The listener.
        Returns:
        true if the listener is not already registered.
      • removeListener

        public boolean removeListener​(SyncTaskEventListener listener)
        Unregisters a listener for synchronisation task events.
        Parameters:
        listener - The listener.
        Returns:
        true if the specified listener was registered.
      • compareForUpdate

        protected List<ModifySpec> compareForUpdate​(com.unboundid.ldap.sdk.Entry sourceEntry,
                                                    com.unboundid.ldap.sdk.Entry targetEntry)
        Compares the attributes of the specified source (reference) entry and target entry and if they differ returns a non-empty list of modification specifications to apply to the target entry.
        Parameters:
        sourceEntry - The source (reference) directory entry, with any required attribute name mapping applied.
        targetEntry - The corresponding target directory entry.
        Returns:
        The necessary modification specifications, empty if the attributes of the two entries match.