LOG.debug( "------------- starting handleSearchResult ------------" );
try
{
Entry remoteEntry = syncResult.getEntry();
Control ctrl = syncResult.getControl( SyncStateValueControl.CONTROL_OID );
SyncStateValueControl syncStateCtrl = new SyncStateValueControl();
try
{
syncStateCtrl = ( SyncStateValueControl ) syncStateControlDecoder.decode( ctrl.getValue(), syncStateCtrl );
}
catch ( Exception e )
{
LOG.error( "Failed to decode syncStateControl", e );
}
if ( syncStateCtrl.getCookie() != null )
{
syncCookie = syncStateCtrl.getCookie();
LOG.debug( "assigning the cookie from sync state value control: "
+ StringTools.utf8ToString( syncCookie ) );
}
SyncStateTypeEnum state = syncStateCtrl.getSyncStateType();
LOG.debug( "state name {}", state.name() );
// check to avoid conversion of UUID from byte[] to String
if ( LOG.isDebugEnabled() )
{
LOG.debug( "entryUUID = {}", StringTools.uuidToString( syncStateCtrl.getEntryUUID() ) );
}
switch ( state )
{
case ADD:
if ( !session.exists( remoteEntry.getDn() ) )
{
LOG.debug( "adding entry with dn {}", remoteEntry.getDn().getName() );
LOG.debug( remoteEntry.toString() );
session.add( new DefaultServerEntry( schemaManager, remoteEntry ) );
}
// in refreshOnly mode the modified entry will be sent with state ADD
else if( !config.isRefreshPersist() )
{
LOG.debug( "updating entry in refreshOnly mode {}", remoteEntry.getDn().getName() );
modify( remoteEntry );
}
break;
case MODIFY:
LOG.debug( "modifying entry with dn {}", remoteEntry.getDn().getName() );
modify( remoteEntry );
break;
case DELETE:
LOG.debug( "deleting entry with dn {}", remoteEntry.getDn().getName() );
session.delete( remoteEntry.getDn() );
break;
case PRESENT:
LOG.debug( "entry present {}", remoteEntry );
break;