use of org.apache.directory.api.ldap.model.message.extended.ModifyNoDResponse in project directory-ldap-api by apache.
the class LdapNetworkConnection method modify.
/**
* {@inheritDoc}
*/
@Override
public ModifyResponse modify(ModifyRequest modRequest) throws LdapException {
if (modRequest == null) {
String msg = "Cannot process a null modifyRequest";
LOG.debug(msg);
throw new IllegalArgumentException(msg);
}
ModifyFuture modifyFuture = modifyAsync(modRequest);
// Get the result from the future
try {
// Read the response, waiting for it if not available immediately
// Get the response, blocking
ModifyResponse modifyResponse = modifyFuture.get(timeout, TimeUnit.MILLISECONDS);
if (modifyResponse == null) {
// We didn't received anything : this is an error
if (LOG.isErrorEnabled()) {
LOG.error(I18n.err(I18n.ERR_03203_OP_FAILED_TIMEOUT, "Modify"));
}
throw new LdapException(TIME_OUT_ERROR);
}
if (modifyResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS) {
// Everything is fine, return the response
if (LOG.isDebugEnabled()) {
LOG.debug(I18n.msg(I18n.MSG_03224_MODIFY_SUCCESSFUL, modifyResponse));
}
} else {
if (modifyResponse instanceof ModifyNoDResponse) {
// A NoticeOfDisconnect : deserves a special treatment
throw new LdapException(modifyResponse.getLdapResult().getDiagnosticMessage());
}
// We have had an error
if (LOG.isDebugEnabled()) {
LOG.debug(I18n.msg(I18n.MSG_03223_MODIFY_FAILED, modifyResponse));
}
}
return modifyResponse;
} catch (Exception ie) {
// Catch all other exceptions
LOG.error(NO_RESPONSE_ERROR, ie);
// Send an abandon request
if (!modifyFuture.isCancelled()) {
abandon(modRequest.getMessageId());
}
throw new LdapException(ie.getMessage(), ie);
}
}
Aggregations