Search in sources :

Example 36 with ModifyDNRequest

use of com.unboundid.ldap.sdk.ModifyDNRequest in project ldapsdk by pingidentity.

the class InMemoryDirectoryServerReferentialIntegrityTestCase method testModifyDNWithReferentialIntegrity.

/**
 * Tests the behavior for modify DN operations with referential integrity
 * enabled.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testModifyDNWithReferentialIntegrity() throws Exception {
    // Create a directory server instance and configure it for use with
    // referential integrity.
    final InMemoryDirectoryServerConfig cfg = new InMemoryDirectoryServerConfig("dc=example,dc=com");
    cfg.setReferentialIntegrityAttributes("member", "uniqueMember");
    final InMemoryDirectoryServer ds = new InMemoryDirectoryServer(cfg);
    ds.startListening();
    // Populate the server with a set of test data.
    ds.addEntries(generateDomainEntry("example", "dc=com"), generateOrgUnitEntry("People", "dc=example,dc=com"), generateOrgUnitEntry("Groups", "dc=example,dc=com"), generateUserEntry("none", "ou=People,dc=example,dc=com", "No", "Memberships", "password"), generateUserEntry("single", "ou=People,dc=example,dc=com", "Single", "Membership", "password"), generateUserEntry("multiple", "ou=People,dc=example,dc=com", "Multiple", "Memberships", "password"), generateGroupOfNamesEntry("group1", "ou=Groups,dc=example,dc=com", "uid=single,ou=People,dc=example,dc=com", "uid=multiple,ou=People,dc=example,dc=com", "uid=nonexistent,ou=People,dc=example,dc=com"), generateGroupOfNamesEntry("group2", "ou=Groups,dc=example,dc=com", "uid=multiple,ou=People,dc=example,dc=com", "uid=nonexistent,ou=People,dc=example,dc=com"), generateGroupOfUniqueNamesEntry("group3", "ou=Groups,dc=example,dc=com", "uid=multiple,ou=People,dc=example,dc=com"), generateGroupOfUniqueNamesEntry("group4", "ou=Groups,dc=example,dc=com", "uid=nonexistent,ou=People,dc=example,dc=com"));
    ds.assertValueExists("cn=group1,ou=Groups,dc=example,dc=com", "member", "uid=single,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group1,ou=Groups,dc=example,dc=com", "member", "uid=multiple,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group1,ou=Groups,dc=example,dc=com", "member", "uid=nonexistent,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group2,ou=Groups,dc=example,dc=com", "member", "uid=multiple,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group2,ou=Groups,dc=example,dc=com", "member", "uid=nonexistent,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group3,ou=Groups,dc=example,dc=com", "uniqueMember", "uid=multiple,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group4,ou=Groups,dc=example,dc=com", "uniqueMember", "uid=nonexistent,ou=People,dc=example,dc=com");
    // Rename a user that is a member of only one group, and ensure that the
    // reference to it is updated.
    final LDAPConnection conn = ds.getConnection();
    final ModifyDNRequest modifyDNRequest = new ModifyDNRequest("uid=single,ou=People,dc=example,dc=com", "uid=one", true);
    assertResultCodeEquals(conn, modifyDNRequest, ResultCode.SUCCESS);
    ds.assertValueMissing("cn=group1,ou=Groups,dc=example,dc=com", "member", "uid=single,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group1,ou=Groups,dc=example,dc=com", "member", "uid=one,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group1,ou=Groups,dc=example,dc=com", "member", "uid=multiple,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group1,ou=Groups,dc=example,dc=com", "member", "uid=nonexistent,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group2,ou=Groups,dc=example,dc=com", "member", "uid=multiple,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group2,ou=Groups,dc=example,dc=com", "member", "uid=nonexistent,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group3,ou=Groups,dc=example,dc=com", "uniqueMember", "uid=multiple,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group4,ou=Groups,dc=example,dc=com", "uniqueMember", "uid=nonexistent,ou=People,dc=example,dc=com");
    // Rename a user that is not member of any groups, and ensure that no
    // changes are made.
    modifyDNRequest.setDN("uid=none,ou=People,dc=example,dc=com");
    modifyDNRequest.setNewRDN("uid=zero");
    assertResultCodeEquals(conn, modifyDNRequest, ResultCode.SUCCESS);
    ds.assertValueMissing("cn=group1,ou=Groups,dc=example,dc=com", "member", "uid=single,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group1,ou=Groups,dc=example,dc=com", "member", "uid=one,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group1,ou=Groups,dc=example,dc=com", "member", "uid=multiple,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group1,ou=Groups,dc=example,dc=com", "member", "uid=nonexistent,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group2,ou=Groups,dc=example,dc=com", "member", "uid=multiple,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group2,ou=Groups,dc=example,dc=com", "member", "uid=nonexistent,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group3,ou=Groups,dc=example,dc=com", "uniqueMember", "uid=multiple,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group4,ou=Groups,dc=example,dc=com", "uniqueMember", "uid=nonexistent,ou=People,dc=example,dc=com");
    // Rename a user that is a member of multiple groups, and ensure that all
    // appropriate changes are made.
    modifyDNRequest.setDN("uid=multiple,ou=People,dc=example,dc=com");
    modifyDNRequest.setNewRDN("uid=three");
    assertResultCodeEquals(conn, modifyDNRequest, ResultCode.SUCCESS);
    ds.assertValueMissing("cn=group1,ou=Groups,dc=example,dc=com", "member", "uid=single,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group1,ou=Groups,dc=example,dc=com", "member", "uid=one,ou=People,dc=example,dc=com");
    ds.assertValueMissing("cn=group1,ou=Groups,dc=example,dc=com", "member", "uid=multiple,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group1,ou=Groups,dc=example,dc=com", "member", "uid=three,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group1,ou=Groups,dc=example,dc=com", "member", "uid=nonexistent,ou=People,dc=example,dc=com");
    ds.assertValueMissing("cn=group2,ou=Groups,dc=example,dc=com", "member", "uid=multiple,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group2,ou=Groups,dc=example,dc=com", "member", "uid=three,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group2,ou=Groups,dc=example,dc=com", "member", "uid=nonexistent,ou=People,dc=example,dc=com");
    ds.assertValueMissing("cn=group3,ou=Groups,dc=example,dc=com", "uniqueMember", "uid=multiple,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group3,ou=Groups,dc=example,dc=com", "uniqueMember", "uid=three,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group4,ou=Groups,dc=example,dc=com", "uniqueMember", "uid=nonexistent,ou=People,dc=example,dc=com");
    // Rename the entire "ou=People" subtree and ensure that all references to
    // the subordinate entries are updated.
    modifyDNRequest.setDN("ou=People,dc=example,dc=com");
    modifyDNRequest.setNewRDN("ou=Users");
    assertResultCodeEquals(conn, modifyDNRequest, ResultCode.SUCCESS);
    ds.assertValueMissing("cn=group1,ou=Groups,dc=example,dc=com", "member", "uid=single,ou=People,dc=example,dc=com");
    ds.assertValueMissing("cn=group1,ou=Groups,dc=example,dc=com", "member", "uid=one,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group1,ou=Groups,dc=example,dc=com", "member", "uid=one,ou=Users,dc=example,dc=com");
    ds.assertValueMissing("cn=group1,ou=Groups,dc=example,dc=com", "member", "uid=multiple,ou=People,dc=example,dc=com");
    ds.assertValueMissing("cn=group1,ou=Groups,dc=example,dc=com", "member", "uid=three,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group1,ou=Groups,dc=example,dc=com", "member", "uid=three,ou=Users,dc=example,dc=com");
    ds.assertValueExists("cn=group1,ou=Groups,dc=example,dc=com", "member", "uid=nonexistent,ou=People,dc=example,dc=com");
    ds.assertValueMissing("cn=group2,ou=Groups,dc=example,dc=com", "member", "uid=multiple,ou=People,dc=example,dc=com");
    ds.assertValueMissing("cn=group2,ou=Groups,dc=example,dc=com", "member", "uid=three,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group2,ou=Groups,dc=example,dc=com", "member", "uid=three,ou=Users,dc=example,dc=com");
    ds.assertValueExists("cn=group2,ou=Groups,dc=example,dc=com", "member", "uid=nonexistent,ou=People,dc=example,dc=com");
    ds.assertValueMissing("cn=group3,ou=Groups,dc=example,dc=com", "uniqueMember", "uid=multiple,ou=People,dc=example,dc=com");
    ds.assertValueMissing("cn=group3,ou=Groups,dc=example,dc=com", "uniqueMember", "uid=three,ou=People,dc=example,dc=com");
    ds.assertValueExists("cn=group3,ou=Groups,dc=example,dc=com", "uniqueMember", "uid=three,ou=Users,dc=example,dc=com");
    ds.assertValueExists("cn=group4,ou=Groups,dc=example,dc=com", "uniqueMember", "uid=nonexistent,ou=People,dc=example,dc=com");
    // Close the connection and shut down the server.
    conn.close();
    ds.shutDown(true);
}
Also used : ModifyDNRequest(com.unboundid.ldap.sdk.ModifyDNRequest) LDAPConnection(com.unboundid.ldap.sdk.LDAPConnection) Test(org.testng.annotations.Test)

Example 37 with ModifyDNRequest

use of com.unboundid.ldap.sdk.ModifyDNRequest in project ldapsdk by pingidentity.

the class LDAPConnection method rename.

/**
 * Alters the DN of an entry in the directory.
 *
 * @param  dn            The DN of the entry to modify.
 * @param  newRDN        The new RDN to use for the entry.
 * @param  newParentDN   The DN of the new parent, or {@code null} if it
 *                       should not be moved below a new parent.
 * @param  deleteOldRDN  Indicates whether to remove the old RDN value(s).
 * @param  constraints   The constraints to use for the modify operation.
 *
 * @throws  LDAPException  If a problem occurs while processing the delete.
 */
public void rename(@NotNull final String dn, @NotNull final String newRDN, @Nullable final String newParentDN, final boolean deleteOldRDN, @Nullable final LDAPConstraints constraints) throws LDAPException {
    final ModifyDNRequest modifyDNRequest = new ModifyDNRequest(dn, newRDN, deleteOldRDN, newParentDN);
    update(modifyDNRequest, constraints);
    try {
        final LDAPResult result = conn.modifyDN(modifyDNRequest);
        setResponseControls(result);
    } catch (final com.unboundid.ldap.sdk.LDAPException le) {
        Debug.debugException(le);
        setResponseControls(le);
        throw new LDAPException(le);
    }
}
Also used : ModifyDNRequest(com.unboundid.ldap.sdk.ModifyDNRequest) LDAPResult(com.unboundid.ldap.sdk.LDAPResult)

Example 38 with ModifyDNRequest

use of com.unboundid.ldap.sdk.ModifyDNRequest in project ldapsdk by pingidentity.

the class LDAPModify method doModifyDN.

/**
 * Performs the appropriate processing for an LDIF modify DN change record.
 *
 * @param  changeRecord         The LDIF modify DN change record to process.
 * @param  controls             The set of controls to include in the request.
 * @param  pool                 The connection pool to use to communicate with
 *                              the directory server.
 * @param  multiUpdateRequests  The list to which the request should be added
 *                              if it is to be processed as part of a
 *                              multi-update operation.  It may be
 *                              {@code null} if the operation should not be
 *                              processed via the multi-update operation.
 * @param  rejectWriter         The LDIF writer to use for recording
 *                              information about rejected changes.  It may be
 *                              {@code null} if no reject writer is
 *                              configured.
 *
 * @return  The result code obtained from processing.
 *
 * @throws  LDAPException  If the operation did not complete successfully
 *                         and processing should not continue.
 */
@NotNull()
private ResultCode doModifyDN(@NotNull final LDIFModifyDNChangeRecord changeRecord, @NotNull final List<Control> controls, @NotNull final LDAPConnectionPool pool, @Nullable final List<LDAPRequest> multiUpdateRequests, @Nullable final LDIFWriter rejectWriter) throws LDAPException {
    // Create the modify DN request to process.
    final ModifyDNRequest modifyDNRequest = changeRecord.toModifyDNRequest(true);
    for (final Control c : controls) {
        modifyDNRequest.addControl(c);
    }
    // just add the request to the list and return without doing anything else.
    if (multiUpdateErrorBehavior.isPresent()) {
        multiUpdateRequests.add(modifyDNRequest);
        commentToOut(INFO_LDAPMODIFY_MODIFY_DN_ADDED_TO_MULTI_UPDATE.get(modifyDNRequest.getDN()));
        return ResultCode.SUCCESS;
    }
    // Try to determine the new DN that the entry will have after the operation.
    DN newDN = null;
    try {
        newDN = changeRecord.getNewDN();
    } catch (final Exception e) {
        Debug.debugException(e);
    // This should only happen if the provided DN, new RDN, or new superior DN
    // was malformed.  Although we could reject the operation now, we'll go
    // ahead and send the request to the server in case it has some special
    // handling for the DN.
    }
    // If the --dryRun argument was provided, then we'll stop here.
    if (dryRun.isPresent()) {
        if (modifyDNRequest.getNewSuperiorDN() == null) {
            if (newDN == null) {
                commentToOut(INFO_LDAPMODIFY_DRY_RUN_RENAME.get(modifyDNRequest.getDN(), dryRun.getIdentifierString()));
            } else {
                commentToOut(INFO_LDAPMODIFY_DRY_RUN_RENAME_TO.get(modifyDNRequest.getDN(), newDN.toString(), dryRun.getIdentifierString()));
            }
        } else {
            if (newDN == null) {
                commentToOut(INFO_LDAPMODIFY_DRY_RUN_MOVE.get(modifyDNRequest.getDN(), dryRun.getIdentifierString()));
            } else {
                commentToOut(INFO_LDAPMODIFY_DRY_RUN_MOVE_TO.get(modifyDNRequest.getDN(), newDN.toString(), dryRun.getIdentifierString()));
            }
        }
        return ResultCode.SUCCESS;
    }
    // Process the modify DN operation and get the result.
    final String currentDN = modifyDNRequest.getDN();
    if (modifyDNRequest.getNewSuperiorDN() == null) {
        if (newDN == null) {
            commentToOut(INFO_LDAPMODIFY_MOVING_ENTRY.get(currentDN));
        } else {
            commentToOut(INFO_LDAPMODIFY_MOVING_ENTRY_TO.get(currentDN, newDN.toString()));
        }
    } else {
        if (newDN == null) {
            commentToOut(INFO_LDAPMODIFY_RENAMING_ENTRY.get(currentDN));
        } else {
            commentToOut(INFO_LDAPMODIFY_RENAMING_ENTRY_TO.get(currentDN, newDN.toString()));
        }
    }
    if (verbose.isPresent()) {
        for (final String ldifLine : modifyDNRequest.toLDIFChangeRecord().toLDIF(WRAP_COLUMN)) {
            out(ldifLine);
        }
        out();
    }
    LDAPResult modifyDNResult;
    try {
        modifyDNResult = pool.modifyDN(modifyDNRequest);
    } catch (final LDAPException le) {
        Debug.debugException(le);
        modifyDNResult = le.toLDAPResult();
    }
    // Display information about the result.
    displayResult(modifyDNResult, useTransaction.isPresent());
    // should end all processing, then throw an exception.
    switch(modifyDNResult.getResultCode().intValue()) {
        case ResultCode.SUCCESS_INT_VALUE:
        case ResultCode.NO_OPERATION_INT_VALUE:
            break;
        case ResultCode.ASSERTION_FAILED_INT_VALUE:
            writeRejectedChange(rejectWriter, INFO_LDAPMODIFY_ASSERTION_FAILED.get(modifyDNRequest.getDN(), String.valueOf(assertionFilter.getValue())), modifyDNRequest.toLDIFChangeRecord(), modifyDNResult);
            throw new LDAPException(modifyDNResult);
        default:
            writeRejectedChange(rejectWriter, null, modifyDNRequest.toLDIFChangeRecord(), modifyDNResult);
            if (useTransaction.isPresent() || (!continueOnError.isPresent())) {
                throw new LDAPException(modifyDNResult);
            }
            break;
    }
    return modifyDNResult.getResultCode();
}
Also used : ModifyDNRequest(com.unboundid.ldap.sdk.ModifyDNRequest) RouteToServerRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.RouteToServerRequestControl) SubtreeDeleteRequestControl(com.unboundid.ldap.sdk.controls.SubtreeDeleteRequestControl) SimplePagedResultsControl(com.unboundid.ldap.sdk.controls.SimplePagedResultsControl) TransactionSpecificationRequestControl(com.unboundid.ldap.sdk.controls.TransactionSpecificationRequestControl) AssuredReplicationRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.AssuredReplicationRequestControl) PostReadRequestControl(com.unboundid.ldap.sdk.controls.PostReadRequestControl) SuppressOperationalAttributeUpdateRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.SuppressOperationalAttributeUpdateRequestControl) NameWithEntryUUIDRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.NameWithEntryUUIDRequestControl) ReplicationRepairRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.ReplicationRepairRequestControl) ProxiedAuthorizationV1RequestControl(com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV1RequestControl) OperationPurposeRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.OperationPurposeRequestControl) PasswordUpdateBehaviorRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PasswordUpdateBehaviorRequestControl) UndeleteRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.UndeleteRequestControl) GetRecentLoginHistoryRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetRecentLoginHistoryRequestControl) PermissiveModifyRequestControl(com.unboundid.ldap.sdk.controls.PermissiveModifyRequestControl) AuthorizationIdentityRequestControl(com.unboundid.ldap.sdk.controls.AuthorizationIdentityRequestControl) Control(com.unboundid.ldap.sdk.Control) GetUserResourceLimitsRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetUserResourceLimitsRequestControl) HardDeleteRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.HardDeleteRequestControl) IgnoreNoUserModificationRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.IgnoreNoUserModificationRequestControl) GetBackendSetIDRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetBackendSetIDRequestControl) GetAuthorizationEntryRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetAuthorizationEntryRequestControl) PurgePasswordRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PurgePasswordRequestControl) ProxiedAuthorizationV2RequestControl(com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV2RequestControl) SoftDeleteRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.SoftDeleteRequestControl) RetirePasswordRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.RetirePasswordRequestControl) GetServerIDRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GetServerIDRequestControl) NoOpRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.NoOpRequestControl) PasswordPolicyRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PasswordPolicyRequestControl) SuppressReferentialIntegrityUpdatesRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.SuppressReferentialIntegrityUpdatesRequestControl) AssertionRequestControl(com.unboundid.ldap.sdk.controls.AssertionRequestControl) RouteToBackendSetRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.RouteToBackendSetRequestControl) ManageDsaITRequestControl(com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl) PasswordValidationDetailsRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PasswordValidationDetailsRequestControl) UniquenessRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.UniquenessRequestControl) GeneratePasswordRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.GeneratePasswordRequestControl) PreReadRequestControl(com.unboundid.ldap.sdk.controls.PreReadRequestControl) LDAPException(com.unboundid.ldap.sdk.LDAPException) LDAPResult(com.unboundid.ldap.sdk.LDAPResult) DN(com.unboundid.ldap.sdk.DN) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) LDAPSearchException(com.unboundid.ldap.sdk.LDAPSearchException) ArgumentException(com.unboundid.util.args.ArgumentException) LDAPException(com.unboundid.ldap.sdk.LDAPException) IOException(java.io.IOException) LDIFException(com.unboundid.ldif.LDIFException) NotNull(com.unboundid.util.NotNull)

Example 39 with ModifyDNRequest

use of com.unboundid.ldap.sdk.ModifyDNRequest in project ldapsdk by pingidentity.

the class ParallelUpdateOperationThread method run.

/**
 * Operates in a loop, retrieving changes from the operation queue and
 * processing them.
 */
@Override()
public void run() {
    LDIFChangeRecord r = opQueue.getChangeRecord();
    // Various controls that might be present on the requests.
    final Control undeleteRequestControl = new UndeleteRequestControl();
    while (r != null) {
        if (rateLimiter != null) {
            rateLimiter.await();
        }
        DN parsedDN = null;
        DN parsedNewDN = null;
        final long startTime = System.currentTimeMillis();
        try {
            parsedDN = r.getParsedDN();
            if (r instanceof LDIFAddChangeRecord) {
                final AddRequest addRequest = ((LDIFAddChangeRecord) r).toAddRequest();
                addRequest.addControls(addControls);
                if (allowUndelete && addRequest.hasAttribute(ATTR_UNDELETE_FROM_DN)) {
                    addRequest.addControl(undeleteRequestControl);
                }
                connectionPool.add(addRequest);
                parallelUpdate.opCompletedSuccessfully(r, (System.currentTimeMillis() - startTime));
            } else if (r instanceof LDIFDeleteChangeRecord) {
                final DeleteRequest deleteRequest = ((LDIFDeleteChangeRecord) r).toDeleteRequest();
                deleteRequest.addControls(deleteControls);
                connectionPool.delete(deleteRequest);
                parallelUpdate.opCompletedSuccessfully(r, (System.currentTimeMillis() - startTime));
            } else if (r instanceof LDIFModifyChangeRecord) {
                final ModifyRequest modifyRequest = ((LDIFModifyChangeRecord) r).toModifyRequest();
                modifyRequest.addControls(modifyControls);
                connectionPool.modify(modifyRequest);
                parallelUpdate.opCompletedSuccessfully(r, (System.currentTimeMillis() - startTime));
            } else if (r instanceof LDIFModifyDNChangeRecord) {
                final LDIFModifyDNChangeRecord modifyDNChangeRecord = (LDIFModifyDNChangeRecord) r;
                parsedNewDN = modifyDNChangeRecord.getNewDN();
                final ModifyDNRequest modifyDNRequest = modifyDNChangeRecord.toModifyDNRequest();
                modifyDNRequest.addControls(modifyDNControls);
                connectionPool.modifyDN(modifyDNRequest);
                parallelUpdate.opCompletedSuccessfully(r, (System.currentTimeMillis() - startTime));
            } else {
                // This should never happen.
                r.processChange(connectionPool);
                parallelUpdate.opCompletedSuccessfully(r, (System.currentTimeMillis() - startTime));
            }
        } catch (final LDAPException e) {
            Debug.debugException(e);
            parallelUpdate.opFailed(r, e, (System.currentTimeMillis() - startTime));
        }
        if (parsedNewDN == null) {
            r = opQueue.getChangeRecord(parsedDN);
        } else {
            r = opQueue.getChangeRecord(parsedDN, parsedNewDN);
        }
    }
}
Also used : LDIFAddChangeRecord(com.unboundid.ldif.LDIFAddChangeRecord) DN(com.unboundid.ldap.sdk.DN) LDIFModifyChangeRecord(com.unboundid.ldif.LDIFModifyChangeRecord) ModifyRequest(com.unboundid.ldap.sdk.ModifyRequest) LDIFModifyDNChangeRecord(com.unboundid.ldif.LDIFModifyDNChangeRecord) AddRequest(com.unboundid.ldap.sdk.AddRequest) ModifyDNRequest(com.unboundid.ldap.sdk.ModifyDNRequest) LDIFChangeRecord(com.unboundid.ldif.LDIFChangeRecord) Control(com.unboundid.ldap.sdk.Control) UndeleteRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.UndeleteRequestControl) LDAPException(com.unboundid.ldap.sdk.LDAPException) UndeleteRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.UndeleteRequestControl) LDIFDeleteChangeRecord(com.unboundid.ldif.LDIFDeleteChangeRecord) DeleteRequest(com.unboundid.ldap.sdk.DeleteRequest)

Aggregations

ModifyDNRequest (com.unboundid.ldap.sdk.ModifyDNRequest)39 Test (org.testng.annotations.Test)32 AddRequest (com.unboundid.ldap.sdk.AddRequest)21 LDAPConnection (com.unboundid.ldap.sdk.LDAPConnection)21 DeleteRequest (com.unboundid.ldap.sdk.DeleteRequest)20 ModifyRequest (com.unboundid.ldap.sdk.ModifyRequest)20 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)11 Control (com.unboundid.ldap.sdk.Control)11 LDAPResult (com.unboundid.ldap.sdk.LDAPResult)11 CompareRequest (com.unboundid.ldap.sdk.CompareRequest)10 SearchRequest (com.unboundid.ldap.sdk.SearchRequest)10 DN (com.unboundid.ldap.sdk.DN)9 LDAPConnectionOptions (com.unboundid.ldap.sdk.LDAPConnectionOptions)8 LDAPException (com.unboundid.ldap.sdk.LDAPException)8 TransactionSpecificationRequestControl (com.unboundid.ldap.sdk.controls.TransactionSpecificationRequestControl)7 SearchResult (com.unboundid.ldap.sdk.SearchResult)6 TestUnsolicitedNotificationHandler (com.unboundid.ldap.sdk.TestUnsolicitedNotificationHandler)6 ManageDsaITRequestControl (com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl)6 RDN (com.unboundid.ldap.sdk.RDN)5 SimpleBindRequest (com.unboundid.ldap.sdk.SimpleBindRequest)5