String msg = "Cannot process a null modDnRequest";
LOG.debug( msg );
throw new IllegalArgumentException( msg );
}
ModifyDnFuture modifyDnFuture = modifyDnAsync( modDnRequest );
// Get the result from the future
try
{
// Read the response, waiting for it if not available immediately
// Get the response, blocking
ModifyDnResponse modifyDnResponse = modifyDnFuture.get( timeout, TimeUnit.MILLISECONDS );
if ( modifyDnResponse == null )
{
// We didn't received anything : this is an error
LOG.error( "ModifyDN failed : timeout occurred" );
throw new LdapException( TIME_OUT_ERROR );
}
if ( modifyDnResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
{
// Everything is fine, return the response
LOG.debug( "ModifyDN successful : {}", modifyDnResponse );
}
else
{
// We have had an error
LOG.debug( "Modify failed : {}", modifyDnResponse );
}
return modifyDnResponse;
}
catch ( TimeoutException te )
{
// Send an abandon request
if ( !modifyDnFuture.isCancelled() )
{
abandon( modDnRequest.getMessageId() );
}
// We didn't received anything : this is an error
LOG.error( "Modify failed : timeout occurred" );
throw new LdapException( TIME_OUT_ERROR, te );
}
catch ( Exception ie )
{
// Catch all other exceptions
LOG.error( NO_RESPONSE_ERROR, ie );
// Send an abandon request
if ( !modifyDnFuture.isCancelled() )
{
abandon( modDnRequest.getMessageId() );
}
throw new LdapException( NO_RESPONSE_ERROR, ie );