AddFuture addFuture = (AddFuture)responseFuture;
if ( addFuture == null )
{
LOG.error( "AddFuture is null" );
throw new LdapException( "AddFuture is null" );
}
// remove the listener from the listener map
if ( LOG.isDebugEnabled() )
{
if ( addResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
{
// Everything is fine, return the response
LOG.debug( "Add successful : {}", addResponse );
}
else
{
// We have had an error
LOG.debug( "Add failed : {}", addResponse );
}
}
// Store the response into the future
addFuture.set( addResponse );
// Remove the future from the map
removeFromFutureMaps( messageId );
break;
case BIND_RESPONSE:
// Transform the response
BindResponseCodec bindResponseCodec = (BindResponseCodec)response;
bindResponseCodec.setMessageId( messageId );
bindResponseCodec.addControl( response.getCurrentControl() );
BindResponse bindResponse = convert( bindResponseCodec );
BindFuture bindFuture = (BindFuture)responseFuture;
if ( bindFuture == null )
{
LOG.error( "BindFuture is null" );
throw new LdapException( "BindFuture is null" );
}
// remove the listener from the listener map
if ( bindResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
{
authenticated.set( true );
// Everything is fine, return the response
LOG.debug( "Bind successful : {}", bindResponse );
}
else
{
// We have had an error
LOG.debug( "Bind failed : {}", bindResponse );
}
// Store the response into the future
bindFuture.set( bindResponse );
// Remove the future from the map
removeFromFutureMaps( messageId );
break;
case COMPARE_RESPONSE:
// Transform the response
CompareResponseCodec compResCodec = (CompareResponseCodec)response;
compResCodec.setMessageId( messageId );
compResCodec.addControl( response.getCurrentControl() );
CompareResponse compareResponse = convert( compResCodec );
CompareFuture compareFuture = (CompareFuture)responseFuture;
if ( compareFuture == null )
{
LOG.error( "CompareFuture is null" );
throw new LdapException( "CompareFuture is null" );
}
// remove the listener from the listener map
if ( LOG.isDebugEnabled() )
{
if ( compareResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
{
// Everything is fine, return the response
LOG.debug( "Compare successful : {}", compareResponse );
}
else
{
// We have had an error
LOG.debug( "Compare failed : {}", compareResponse );
}
}
// Store the response into the future
compareFuture.set( compareResponse );
// Remove the future from the map
removeFromFutureMaps( messageId );
break;
case DEL_RESPONSE:
// Transform the response
DelResponseCodec delRespCodec = (DelResponseCodec)response;
delRespCodec.addControl( response.getCurrentControl() );
delRespCodec.setMessageId( messageId );
DeleteResponse deleteResponse = convert( delRespCodec );
DeleteFuture deleteFuture = (DeleteFuture)responseFuture;
if ( deleteFuture == null )
{
LOG.error( "DeleteFuture is null" );
throw new LdapException( "DeleteFuture is null" );
}
if ( LOG.isDebugEnabled() )
{
if ( deleteResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
{
// Everything is fine, return the response
LOG.debug( "Delete successful : {}", deleteResponse );
}
else
{
// We have had an error
LOG.debug( "Delete failed : {}", deleteResponse );
}
}
// Store the response into the future
deleteFuture.set( deleteResponse );
// Remove the future from the map
removeFromFutureMaps( messageId );
break;
case EXTENDED_RESPONSE:
// Transform the response
ExtendedResponseCodec extResCodec = (ExtendedResponseCodec)response;
extResCodec.setMessageId( messageId );
extResCodec.addControl( response.getCurrentControl() );
ExtendedResponse extendedResponse = convert( extResCodec );
ExtendedFuture extendedFuture = (ExtendedFuture)responseFuture;
if ( extendedFuture == null )
{
LOG.error( "ExtendedFuture is null" );
throw new LdapException( "extendedFuture is null" );
}
// remove the listener from the listener map
if ( LOG.isDebugEnabled() )
{
if ( extendedResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
{
// Everything is fine, return the response
LOG.debug( "Extended successful : {}", extendedResponse );
}
else
{
// We have had an error
LOG.debug( "Extended failed : {}", extendedResponse );
}
}
// Store the response into the future
extendedFuture.set( extendedResponse );
// Remove the future from the map
removeFromFutureMaps( messageId );
break;
case INTERMEDIATE_RESPONSE:
IntermediateResponseCodec intermediateResponseCodec = (IntermediateResponseCodec)response;
intermediateResponseCodec.setMessageId( messageId );
intermediateResponseCodec.addControl( response.getCurrentControl() );
setIResponse( intermediateResponseCodec, responseFuture );
break;
case MODIFY_RESPONSE:
// Transform the response
ModifyResponseCodec modRespCodec = (ModifyResponseCodec)response;
modRespCodec.setMessageId( messageId );
modRespCodec.addControl( response.getCurrentControl() );
ModifyResponse modifyResp = convert( modRespCodec );
ModifyFuture modifyFuture = (ModifyFuture)responseFuture;
if ( modifyFuture == null )
{
LOG.error( "ModifyFuture is null" );
throw new LdapException( "ModifyFuture is null" );
}
if ( LOG.isDebugEnabled() )
{
if ( modifyResp.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
{
// Everything is fine, return the response
LOG.debug( "ModifyFuture successful : {}", modifyResp );
}
else
{
// We have had an error
LOG.debug( "ModifyFuture failed : {}", modifyResp );
}
}
// Store the response into the future
modifyFuture.set( modifyResp );
// Remove the future from the map
removeFromFutureMaps( messageId );
break;
case MODIFYDN_RESPONSE:
// Transform the response
ModifyDNResponseCodec modDnRespCodec = (ModifyDNResponseCodec)response;
modDnRespCodec.setMessageId( messageId );
modDnRespCodec.addControl( response.getCurrentControl() );
ModifyDnResponse modifyDnResp = convert( modDnRespCodec );
ModifyDnFuture modifyDnFuture = (ModifyDnFuture)responseFuture;
if ( modifyDnFuture == null )
{
LOG.error( "ModifyDNFuture is null" );
throw new LdapException( "ModifyDNFuture is null" );
}
if ( LOG.isDebugEnabled() )
{
if ( modifyDnResp.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
{
// Everything is fine, return the response
LOG.debug( "ModifyDN successful : {}", modifyDnResp );
}
else
{
// We have had an error
LOG.debug( "ModifyDN failed : {}", modifyDnResp );
}
}
// Store the response into the future
modifyDnFuture.set( modifyDnResp );
// Remove the future from the map
removeFromFutureMaps( messageId );
break;
case SEARCH_RESULT_DONE:
// Store the response into the responseQueue
SearchResultDoneCodec searchResultDoneCodec = (SearchResultDoneCodec)response;
searchResultDoneCodec.setMessageId( messageId );
searchResultDoneCodec.addControl( response.getCurrentControl() );
SearchResultDone searchResultDone = convert( searchResultDoneCodec );
SearchFuture searchFuture = (SearchFuture)responseFuture;
if ( searchFuture == null )
{
LOG.error( "SearchFuture is null" );
throw new LdapException( "SearchFuture is null" );
}
if ( LOG.isDebugEnabled() )
{
if ( searchResultDone.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
{
// Everything is fine, return the response
LOG.debug( "Search successful : {}", searchResultDone );
}
else
{
// We have had an error
LOG.debug( "Search failed : {}", searchResultDone );
}
}
// Store the response into the future
searchFuture.set( searchResultDone );
// Remove the future from the map
removeFromFutureMaps( messageId );
break;
case SEARCH_RESULT_ENTRY:
// Store the response into the responseQueue
SearchResultEntryCodec searchResultEntryCodec = (SearchResultEntryCodec)response;
searchResultEntryCodec.setMessageId( messageId );
searchResultEntryCodec.addControl( response.getCurrentControl() );
SearchResultEntry srchEntry = convert( searchResultEntryCodec );
searchFuture = (SearchFuture)responseFuture;
if ( searchFuture == null )
{
LOG.error( "SearchFuture is null" );
throw new LdapException( "SearchFuture is null" );
}
if ( LOG.isDebugEnabled() )
{
LOG.debug( "Search entry found : {}", srchEntry );
}
// Store the response into the future
searchFuture.set( srchEntry );
break;
case SEARCH_RESULT_REFERENCE:
// Store the response into the responseQueue
SearchResultReferenceCodec searchResultReferenceCodec = (SearchResultReferenceCodec)response;
searchResultReferenceCodec.setMessageId( messageId );
searchResultReferenceCodec.addControl( response.getCurrentControl() );
SearchResultReference searchResultReference = convert( searchResultReferenceCodec );
searchFuture = (SearchFuture)responseFuture;
if ( searchFuture == null )
{
LOG.error( "SearchFuture is null" );
throw new LdapException( "SearchFuture is null" );
}
if ( LOG.isDebugEnabled() )
{
LOG.debug( "Search reference found : {}", searchResultReference );