001package com.pingidentity.sync.source.plugin;
002
003import com.unboundid.directory.sdk.sync.api.LDAPSyncSourcePlugin;
004import com.unboundid.directory.sdk.sync.types.PostStepResult;
005import com.unboundid.directory.sdk.sync.types.SyncOperation;
006import com.unboundid.ldap.sdk.LDAPInterface;
007
008import java.util.concurrent.atomic.AtomicReference;
009
010/**
011 * This class simply store the connection with the source in a sync operation for later use.
012 */
013public class StashConnection extends LDAPSyncSourcePlugin
014{
015    public static final String ATTACHMENT_ID = "connection";
016    
017    /**
018     * @return the extension name
019     */
020    @Override
021    public String getExtensionName()
022    {
023        return "Stash Connection";
024    }
025    
026    /**
027     * @return an array of descriptive paragraph about the extension
028     */
029    @Override
030    public String[] getExtensionDescription()
031    {
032        return new String[]{"Stash the connection to the source server from which a change was detected in the sync " +
033                "operation for use later for example in a sync pipe plugin"};
034    }
035    
036    /**
037     * Performs the necessary processing to stash the connection in a sync operation
038     * @param sourceConnection the connection to the source
039     * @param fetchedEntryRef a reference to the entry
040     * @param operation the sync operation
041     * @return CONTINUE as to not alter the processing flow
042     */
043    public PostStepResult postFetch(
044            LDAPInterface sourceConnection,
045            AtomicReference<com.unboundid.ldap.sdk.Entry> fetchedEntryRef,
046            SyncOperation operation)
047    {
048        operation.putAttachment(ATTACHMENT_ID, sourceConnection);
049        return PostStepResult.CONTINUE;
050    }
051    
052    @Override
053    public void toString(StringBuilder buffer)
054    {
055    }
056}