// modify the filter to include the context Csn
ExprNode initialContentFilter = new AndNode( modifiedFilter, csnNode );
request.setFilter( initialContentFilter );
SearchResultDone searchDoneResp = doSimpleSearch( session, request );
if ( searchDoneResp.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
{
replicaLog.setLastSentCsn( contextCsn );
byte[] cookie = Strings.getBytesUtf8( replicaLog.getId() + REPLICA_ID_DELIM + contextCsn );
if ( refreshNPersist ) // refreshAndPersist mode
{
contextCsn = sendContentFromLog( session, request, replicaLog, contextCsn );
cookie = Strings.getBytesUtf8(replicaLog.getId() + REPLICA_ID_DELIM + contextCsn);
IntermediateResponse intermResp = new IntermediateResponseImpl( request.getMessageId() );
intermResp.setResponseName( SyncInfoValue.OID );
SyncInfoValueDecorator syncInfo = new SyncInfoValueDecorator(
ldapServer.getDirectoryService().getLdapCodecService(), SynchronizationInfoEnum.NEW_COOKIE );
syncInfo.setCookie( cookie );
intermResp.setResponseValue( syncInfo.getValue() );
session.getIoSession().write( intermResp );
// switch the handler mode to realtime push
handler.setPushInRealTime( refreshNPersist );
}
else
{
// no need to send from the log, that will be done in the next refreshOnly session
SyncDoneValue syncDone = new SyncDoneValueDecorator(
ldapServer.getDirectoryService().getLdapCodecService() );
syncDone.setCookie( cookie );
searchDoneResp.addControl( syncDone );
session.getIoSession().write( searchDoneResp );
}
}
else
// if not succeeded return
{
LOG.warn( "initial content refresh didn't succeed due to {}", searchDoneResp.getLdapResult()
.getResultCode() );
replicaLog.truncate();
replicaLog = null;
// remove the listener