* This method only needs to be implemented if the 'synchronization-mode' on * the Sync Pipe is set to 'standard'. If it is set to 'notification', this * method will never be called, and the pipe will pass changes straight * through to one of {@link #createEntry}, {@link #modifyEntry}, or * {@link #deleteEntry}. *
* Note that the if the source entry was renamed (see
* {@link SyncOperation#isModifyDN}), the
* destEntryMappedFromSrc
will have the new DN; the old DN can
* be obtained by calling
* {@link SyncOperation#getDestinationEntryBeforeChange()} and getting the DN
* from there. This method should return the entry in its existing form
* (i.e. with the old DN, before it is changed).
*
* This method must be thread safe, as it will be called repeatedly and
* concurrently by each of the Sync Pipe worker threads as they process
* entries.
* @param destEntryMappedFromSrc
* the LDAP entry which corresponds to the destination "entry" to
* fetch
* @param operation
* the sync operation for this change
* @return a list containing the full LDAP entries that matched this search
* (there may be more than one), or an empty list if no such entry
* exists
* @throws EndpointException
* if there is an error fetching the entry
*/
@Override
public List
* This method must be thread safe, as it will be called repeatedly and
* concurrently by the Sync Pipe worker threads as they process CREATE
* operations.
* @param entryToCreate
* the LDAP entry which corresponds to the destination
* "entry" to create
* @param operation
* the sync operation for this change
* @throws EndpointException
* if there is an error creating the entry
*/
@Override
public void createEntry(final Entry entryToCreate,
final SyncOperation operation)
throws EndpointException
{
if (shouldIgnore(entryToCreate, operation))
{
return;
}
try
{
connectionPool.add(entryToCreate);
operation.logInfo("Created entry: " + entryToCreate.getDN());
}
catch(LDAPException e)
{
throw new EndpointException(e);
}
}
/**
* Modify an "entry" on the destination, corresponding to the LDAP
* {@link Entry} that is passed in. This method is responsible for
* transforming the contents of the entry into the desired format and
* transmitting it to the target destination. It may perform multiple updates
* (including inserting or deleting other attributes) in order to fully
* synchronize the entire entry on the destination endpoint.
*
* Note that the if the source entry was renamed (see
* {@link SyncOperation#isModifyDN}), the
*
* This method must be thread safe, as it will be called repeatedly and
* concurrently by the Sync Pipe worker threads as they process MODIFY
* operations.
* @param entryToModify
* the LDAP entry which corresponds to the destination
* "entry" to modify. If the synchronization mode is 'standard',
* this will be the entry that was returned by {@link #fetchEntry};
* otherwise if the synchronization mode is 'notification', this
* will be the destination entry mapped from the source entry, before
* changes are applied.
* @param modsToApply
* a list of Modification objects which should be applied; these will
* have any configured attribute mappings already applied
* @param operation
* the sync operation for this change
* @throws EndpointException
* if there is an error modifying the entry
*/
@Override
public void modifyEntry(final Entry entryToModify,
final List
* This method must be thread safe, as it will be called repeatedly and
* concurrently by the Sync Pipe worker threads as they process DELETE
* operations.
* @param entryToDelete
* the LDAP entry which corresponds to the destination
* "entry" to delete. If the synchronization mode is 'standard',
* this will be the entry that was returned by {@link #fetchEntry};
* otherwise if the synchronization mode is 'notification', this
* will be the mapped destination entry.
* @param operation
* the sync operation for this change
* @throws EndpointException
* if there is an error deleting the entry
*/
@Override
public void deleteEntry(final Entry entryToDelete,
final SyncOperation operation)
throws EndpointException
{
if (shouldIgnore(entryToDelete, operation))
{
return;
}
try
{
connectionPool.delete(entryToDelete.getDN());
operation.logInfo("Deleted entry: " + entryToDelete.getDN());
}
catch(LDAPException e)
{
throw new EndpointException(e);
}
}
/**
* Entries that have 'cn=ignore user' as the RDN will be ignored. This method
* demonstrates using SyncOperation#setIgnored() to direct the Sync Server to
* ignore certain types of changes and isn't tied to a true use case.
*
* @param entry
* The entry to to be checked.
* @param operation
* The sync operation.
* @return {@code true} if the entry should be ignored.
* @throws EndpointException
* If the RDN could not be retrieved.
*/
protected boolean shouldIgnore(final Entry entry,
final SyncOperation operation) throws EndpointException {
try
{
final RDN rdn = entry.getRDN();
for (Attribute attribute : rdn.getAttributes())
{
if (attribute.getName().equalsIgnoreCase("cn") &&
attribute.getValue().equals("ignore user"))
{
// Setting this prevents this operation from being included in the
// monitor statistics.
operation.setIgnored();
return true;
}
}
}
catch(LDAPException e)
{
throw new EndpointException(e);
}
return false;
}
}
fetchedDestEntry
will have the old DN; the new DN can
* be obtained by calling
* {@link SyncOperation#getDestinationEntryAfterChange()} and getting the DN
* from there.
*