use of com.unboundid.ldap.protocol.ModifyDNResponseProtocolOp in project ldapsdk by pingidentity.
the class InMemoryOperationInterceptorRequestHandler method processModifyDNRequest.
/**
* {@inheritDoc}
*/
@Override()
@NotNull()
public LDAPMessage processModifyDNRequest(final int messageID, @NotNull final ModifyDNRequestProtocolOp request, @NotNull final List<Control> controls) {
final InterceptedModifyDNOperation op = new InterceptedModifyDNOperation(connection, messageID, request, toArray(controls));
activeOperations.put(messageID, op);
try {
for (final InMemoryOperationInterceptor i : interceptors) {
try {
i.processModifyDNRequest(op);
} catch (final LDAPException le) {
Debug.debugException(le);
return new LDAPMessage(messageID, new ModifyDNResponseProtocolOp(le.toLDAPResult()), le.getResponseControls());
} catch (final Exception e) {
Debug.debugException(e);
return new LDAPMessage(messageID, new ModifyDNResponseProtocolOp(ResultCode.OTHER_INT_VALUE, null, ERR_DS_INTERCEPTOR_REQUEST_ERROR.get(String.valueOf(op), i.getClass().getName(), StaticUtils.getExceptionMessage(e)), null));
}
}
final LDAPMessage resultMessage = wrappedHandler.processModifyDNRequest(messageID, new ModifyDNRequestProtocolOp((ModifyDNRequest) op.getRequest()), op.getRequest().getControlList());
op.setResult(resultMessage.getModifyDNResponseProtocolOp().toLDAPResult(toArray(resultMessage.getControls())));
for (final InMemoryOperationInterceptor i : interceptors) {
try {
i.processModifyDNResult(op);
} catch (final Exception e) {
Debug.debugException(e);
return new LDAPMessage(messageID, new ModifyDNResponseProtocolOp(ResultCode.OTHER_INT_VALUE, null, ERR_DS_INTERCEPTOR_RESULT_ERROR.get(String.valueOf(op), i.getClass().getName(), StaticUtils.getExceptionMessage(e)), null));
}
}
return new LDAPMessage(messageID, new ModifyDNResponseProtocolOp(op.getResult()), op.getResult().getResponseControls());
} finally {
activeOperations.remove(messageID);
}
}
use of com.unboundid.ldap.protocol.ModifyDNResponseProtocolOp in project ldapsdk by pingidentity.
the class LDAPDebuggerTestCase method testSuccessfulModifyDN.
/**
* Provides test coverage for a successful modify DN operation.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testSuccessfulModifyDN() throws Exception {
TestRequestHandler.setReturnOp(new ModifyDNResponseProtocolOp(0, null, null, null));
final ModifyDNRequest r = new ModifyDNRequest("ou=People,dc=example,dc=com", "ou=Users", true, "o=example.com");
r.addControl(new Control("1.2.3.4"));
conn.modifyDN(r);
}
use of com.unboundid.ldap.protocol.ModifyDNResponseProtocolOp in project ldapsdk by pingidentity.
the class LDAPDebuggerTestCase method testFailedModifyDN.
/**
* Provides test coverage for a failed modify DN operation.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { LDAPException.class })
public void testFailedModifyDN() throws Exception {
TestRequestHandler.setReturnOp(new ModifyDNResponseProtocolOp(32, "dc=example,dc=com", "msg", Arrays.asList("ldap://server1.example.com/dc=example,dc=com", "ldap://server2.example.com/dc=example,dc=com")));
conn.modifyDN("ou=People,dc=example,dc=com", "ou=Users", true, "o=example.com");
}
use of com.unboundid.ldap.protocol.ModifyDNResponseProtocolOp in project ldapsdk by pingidentity.
the class CannedResponseRequestHandlerTestCase method testDefaultConstructor.
/**
* Tests the behavior of the request handler with the default configuration.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testDefaultConstructor() throws Exception {
final CannedResponseRequestHandler handler = new CannedResponseRequestHandler().newInstance(null);
LDAPMessage m = handler.processAddRequest(1, new AddRequestProtocolOp("dc=example,dc=com", Arrays.asList(new Attribute("objectClass", "top", "domain"), new Attribute("dc", "example"))), Collections.<Control>emptyList());
assertNotNull(m);
assertEquals(m.getMessageID(), 1);
assertTrue(m.getProtocolOp() instanceof AddResponseProtocolOp);
assertNotNull(m.getControls());
assertTrue(m.getControls().isEmpty());
m = handler.processBindRequest(2, new BindRequestProtocolOp("uid=admin,dc=example,dc=com", "password"), Collections.<Control>emptyList());
assertNotNull(m);
assertEquals(m.getMessageID(), 2);
assertTrue(m.getProtocolOp() instanceof BindResponseProtocolOp);
assertNotNull(m.getControls());
assertTrue(m.getControls().isEmpty());
m = handler.processCompareRequest(3, new CompareRequestProtocolOp("dc=example,dc=com", "objectClass", new ASN1OctetString("top")), Collections.<Control>emptyList());
assertNotNull(m);
assertEquals(m.getMessageID(), 3);
assertTrue(m.getProtocolOp() instanceof CompareResponseProtocolOp);
assertNotNull(m.getControls());
assertTrue(m.getControls().isEmpty());
m = handler.processDeleteRequest(4, new DeleteRequestProtocolOp("dc=example,dc=com"), Collections.<Control>emptyList());
assertNotNull(m);
assertEquals(m.getMessageID(), 4);
assertTrue(m.getProtocolOp() instanceof DeleteResponseProtocolOp);
assertNotNull(m.getControls());
assertTrue(m.getControls().isEmpty());
m = handler.processExtendedRequest(5, new ExtendedRequestProtocolOp("1.2.3.4", null), Collections.<Control>emptyList());
assertNotNull(m);
assertEquals(m.getMessageID(), 5);
assertTrue(m.getProtocolOp() instanceof ExtendedResponseProtocolOp);
assertNotNull(m.getControls());
assertTrue(m.getControls().isEmpty());
m = handler.processModifyRequest(6, new ModifyRequestProtocolOp("dc=example,dc=com", Arrays.asList(new Modification(ModificationType.REPLACE, "description", "foo"))), Collections.<Control>emptyList());
assertNotNull(m);
assertEquals(m.getMessageID(), 6);
assertTrue(m.getProtocolOp() instanceof ModifyResponseProtocolOp);
assertNotNull(m.getControls());
assertTrue(m.getControls().isEmpty());
m = handler.processModifyDNRequest(6, new ModifyDNRequestProtocolOp("ou=People,dc=example,dc=com", "ou=Users", true, null), Collections.<Control>emptyList());
assertNotNull(m);
assertEquals(m.getMessageID(), 6);
assertTrue(m.getProtocolOp() instanceof ModifyDNResponseProtocolOp);
assertNotNull(m.getControls());
assertTrue(m.getControls().isEmpty());
m = handler.processSearchRequest(7, new SearchRequestProtocolOp("dc=example,dc=com", SearchScope.SUB, DereferencePolicy.NEVER, 0, 0, false, Filter.createEqualityFilter("uid", "test"), Arrays.<String>asList()), Collections.<Control>emptyList());
assertNotNull(m);
assertEquals(m.getMessageID(), 7);
assertTrue(m.getProtocolOp() instanceof SearchResultDoneProtocolOp);
assertNotNull(m.getControls());
assertTrue(m.getControls().isEmpty());
}
use of com.unboundid.ldap.protocol.ModifyDNResponseProtocolOp in project ldapsdk by pingidentity.
the class JSONAccessLogRequestHandler method processModifyDNRequest.
/**
* {@inheritDoc}
*/
@Override()
@NotNull()
public LDAPMessage processModifyDNRequest(final int messageID, @NotNull final ModifyDNRequestProtocolOp request, @NotNull final List<Control> controls) {
final long opID = nextOperationID.getAndIncrement();
final JSONBuffer buffer = getRequestHeader("modify-dn", opID, messageID);
buffer.appendString("dn", request.getDN());
buffer.appendString("new-rdn", request.getNewRDN());
buffer.appendBoolean("delete-old-rdn", request.deleteOldRDN());
final String newSuperior = request.getNewSuperiorDN();
if (newSuperior != null) {
buffer.appendString("new-superior", newSuperior);
}
buffer.endObject();
logHandler.publish(new LogRecord(Level.INFO, buffer.toString()));
logHandler.flush();
final long startTimeNanos = System.nanoTime();
final LDAPMessage responseMessage = requestHandler.processModifyDNRequest(messageID, request, controls);
final long eTimeNanos = System.nanoTime() - startTimeNanos;
final ModifyDNResponseProtocolOp protocolOp = responseMessage.getModifyDNResponseProtocolOp();
generateResponse(buffer, "modify-dn", opID, messageID, protocolOp.getResultCode(), protocolOp.getDiagnosticMessage(), protocolOp.getMatchedDN(), protocolOp.getReferralURLs(), eTimeNanos);
buffer.endObject();
logHandler.publish(new LogRecord(Level.INFO, buffer.toString()));
logHandler.flush();
return responseMessage;
}
Aggregations