Search in sources :

Example 1 with PermissiveModifyRequestControl

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

the class LDIFModifyChangeRecordTestCase method testConstructor1SingleModification.

/**
 * Tests the first constructor with a single modification.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testConstructor1SingleModification() throws Exception {
    Modification[] mods = { new Modification(ModificationType.ADD, "description", "foo") };
    LDIFModifyChangeRecord r = new LDIFModifyChangeRecord("dc=example,dc=com", mods);
    assertNotNull(r.getDN());
    assertEquals(r.getDN(), "dc=example,dc=com");
    assertEquals(r.getParsedDN(), new DN("dc=example,dc=com"));
    assertNotNull(r.getModifications());
    assertEquals(r.getModifications().length, 1);
    ModifyRequest modifyRequest = r.toModifyRequest();
    assertEquals(modifyRequest.getDN(), "dc=example,dc=com");
    assertEquals(r.getChangeType(), ChangeType.MODIFY);
    assertTrue(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
    String[] ldifLines = r.toLDIF();
    assertNotNull(ldifLines);
    assertEquals(ldifLines.length, 5);
    ByteStringBuffer byteBuffer = new ByteStringBuffer();
    r.toLDIF(byteBuffer);
    assertNotNull(byteBuffer.toString());
    byteBuffer = new ByteStringBuffer();
    r.toLDIF(byteBuffer, 10);
    assertNotNull(byteBuffer.toString());
    StringBuilder stringBuffer = new StringBuilder();
    r.toLDIFString(stringBuffer);
    assertNotNull(r.toString());
    stringBuffer = new StringBuilder();
    r.toLDIFString(stringBuffer, 10);
    assertNotNull(r.toString());
    assertNotNull(r.toLDIFString());
    assertNotNull(r.toLDIFString(10));
    assertNotNull(r.toString());
    LDIFModifyChangeRecord.setAlwaysIncludeTrailingDash(false);
    assertFalse(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
    ldifLines = r.toLDIF();
    assertNotNull(ldifLines);
    assertEquals(ldifLines.length, 4);
    LDIFModifyChangeRecord.setAlwaysIncludeTrailingDash(true);
    assertTrue(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
    r.hashCode();
    byteBuffer = new ByteStringBuffer();
    r.toLDIF(byteBuffer);
    assertNotNull(byteBuffer.toString());
    byteBuffer = new ByteStringBuffer();
    r.toLDIF(byteBuffer, 10);
    assertNotNull(byteBuffer.toString());
    stringBuffer = new StringBuilder();
    r.toLDIFString(stringBuffer);
    assertNotNull(r.toString());
    stringBuffer = new StringBuilder();
    r.toLDIFString(stringBuffer, 10);
    assertNotNull(r.toString());
    assertNotNull(r.toLDIFString());
    assertNotNull(r.toLDIFString(10));
    assertNotNull(r.toString());
    assertNotNull(r.getControls());
    assertTrue(r.getControls().isEmpty());
    r = r.duplicate();
    assertNotNull(r.getDN());
    assertEquals(r.getDN(), "dc=example,dc=com");
    assertEquals(r.getParsedDN(), new DN("dc=example,dc=com"));
    assertNotNull(r.getModifications());
    assertEquals(r.getModifications().length, 1);
    modifyRequest = r.toModifyRequest();
    assertEquals(modifyRequest.getDN(), "dc=example,dc=com");
    assertEquals(r.getChangeType(), ChangeType.MODIFY);
    assertTrue(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
    ldifLines = r.toLDIF();
    assertNotNull(ldifLines);
    assertEquals(ldifLines.length, 5);
    byteBuffer = new ByteStringBuffer();
    r.toLDIF(byteBuffer);
    assertNotNull(byteBuffer.toString());
    byteBuffer = new ByteStringBuffer();
    r.toLDIF(byteBuffer, 10);
    assertNotNull(byteBuffer.toString());
    stringBuffer = new StringBuilder();
    r.toLDIFString(stringBuffer);
    assertNotNull(r.toString());
    stringBuffer = new StringBuilder();
    r.toLDIFString(stringBuffer, 10);
    assertNotNull(r.toString());
    assertNotNull(r.toLDIFString());
    assertNotNull(r.toLDIFString(10));
    assertNotNull(r.toString());
    LDIFModifyChangeRecord.setAlwaysIncludeTrailingDash(false);
    assertFalse(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
    ldifLines = r.toLDIF();
    assertNotNull(ldifLines);
    assertEquals(ldifLines.length, 4);
    LDIFModifyChangeRecord.setAlwaysIncludeTrailingDash(true);
    assertTrue(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
    r.hashCode();
    byteBuffer = new ByteStringBuffer();
    r.toLDIF(byteBuffer);
    assertNotNull(byteBuffer.toString());
    byteBuffer = new ByteStringBuffer();
    r.toLDIF(byteBuffer, 10);
    assertNotNull(byteBuffer.toString());
    stringBuffer = new StringBuilder();
    r.toLDIFString(stringBuffer);
    assertNotNull(r.toString());
    stringBuffer = new StringBuilder();
    r.toLDIFString(stringBuffer, 10);
    assertNotNull(r.toString());
    assertNotNull(r.toLDIFString());
    assertNotNull(r.toLDIFString(10));
    assertNotNull(r.toString());
    assertNotNull(r.getControls());
    assertTrue(r.getControls().isEmpty());
    r = r.duplicate((Control[]) null);
    assertNotNull(r.getDN());
    assertEquals(r.getDN(), "dc=example,dc=com");
    assertEquals(r.getParsedDN(), new DN("dc=example,dc=com"));
    assertNotNull(r.getModifications());
    assertEquals(r.getModifications().length, 1);
    modifyRequest = r.toModifyRequest();
    assertEquals(modifyRequest.getDN(), "dc=example,dc=com");
    assertEquals(r.getChangeType(), ChangeType.MODIFY);
    assertTrue(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
    ldifLines = r.toLDIF();
    assertNotNull(ldifLines);
    assertEquals(ldifLines.length, 5);
    byteBuffer = new ByteStringBuffer();
    r.toLDIF(byteBuffer);
    assertNotNull(byteBuffer.toString());
    byteBuffer = new ByteStringBuffer();
    r.toLDIF(byteBuffer, 10);
    assertNotNull(byteBuffer.toString());
    stringBuffer = new StringBuilder();
    r.toLDIFString(stringBuffer);
    assertNotNull(r.toString());
    stringBuffer = new StringBuilder();
    r.toLDIFString(stringBuffer, 10);
    assertNotNull(r.toString());
    assertNotNull(r.toLDIFString());
    assertNotNull(r.toLDIFString(10));
    assertNotNull(r.toString());
    LDIFModifyChangeRecord.setAlwaysIncludeTrailingDash(false);
    assertFalse(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
    ldifLines = r.toLDIF();
    assertNotNull(ldifLines);
    assertEquals(ldifLines.length, 4);
    LDIFModifyChangeRecord.setAlwaysIncludeTrailingDash(true);
    assertTrue(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
    r.hashCode();
    byteBuffer = new ByteStringBuffer();
    r.toLDIF(byteBuffer);
    assertNotNull(byteBuffer.toString());
    byteBuffer = new ByteStringBuffer();
    r.toLDIF(byteBuffer, 10);
    assertNotNull(byteBuffer.toString());
    stringBuffer = new StringBuilder();
    r.toLDIFString(stringBuffer);
    assertNotNull(r.toString());
    stringBuffer = new StringBuilder();
    r.toLDIFString(stringBuffer, 10);
    assertNotNull(r.toString());
    assertNotNull(r.toLDIFString());
    assertNotNull(r.toLDIFString(10));
    assertNotNull(r.toString());
    assertNotNull(r.getControls());
    assertTrue(r.getControls().isEmpty());
    r = r.duplicate(new Control[0]);
    assertNotNull(r.getDN());
    assertEquals(r.getDN(), "dc=example,dc=com");
    assertEquals(r.getParsedDN(), new DN("dc=example,dc=com"));
    assertNotNull(r.getModifications());
    assertEquals(r.getModifications().length, 1);
    modifyRequest = r.toModifyRequest();
    assertEquals(modifyRequest.getDN(), "dc=example,dc=com");
    assertEquals(r.getChangeType(), ChangeType.MODIFY);
    assertTrue(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
    ldifLines = r.toLDIF();
    assertNotNull(ldifLines);
    assertEquals(ldifLines.length, 5);
    byteBuffer = new ByteStringBuffer();
    r.toLDIF(byteBuffer);
    assertNotNull(byteBuffer.toString());
    byteBuffer = new ByteStringBuffer();
    r.toLDIF(byteBuffer, 10);
    assertNotNull(byteBuffer.toString());
    stringBuffer = new StringBuilder();
    r.toLDIFString(stringBuffer);
    assertNotNull(r.toString());
    stringBuffer = new StringBuilder();
    r.toLDIFString(stringBuffer, 10);
    assertNotNull(r.toString());
    assertNotNull(r.toLDIFString());
    assertNotNull(r.toLDIFString(10));
    assertNotNull(r.toString());
    LDIFModifyChangeRecord.setAlwaysIncludeTrailingDash(false);
    assertFalse(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
    ldifLines = r.toLDIF();
    assertNotNull(ldifLines);
    assertEquals(ldifLines.length, 4);
    LDIFModifyChangeRecord.setAlwaysIncludeTrailingDash(true);
    assertTrue(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
    r.hashCode();
    byteBuffer = new ByteStringBuffer();
    r.toLDIF(byteBuffer);
    assertNotNull(byteBuffer.toString());
    byteBuffer = new ByteStringBuffer();
    r.toLDIF(byteBuffer, 10);
    assertNotNull(byteBuffer.toString());
    stringBuffer = new StringBuilder();
    r.toLDIFString(stringBuffer);
    assertNotNull(r.toString());
    stringBuffer = new StringBuilder();
    r.toLDIFString(stringBuffer, 10);
    assertNotNull(r.toString());
    assertNotNull(r.toLDIFString());
    assertNotNull(r.toLDIFString(10));
    assertNotNull(r.toString());
    assertNotNull(r.getControls());
    assertTrue(r.getControls().isEmpty());
    r = r.duplicate(new ManageDsaITRequestControl(false));
    assertNotNull(r.getDN());
    assertEquals(r.getDN(), "dc=example,dc=com");
    assertEquals(r.getParsedDN(), new DN("dc=example,dc=com"));
    assertNotNull(r.getModifications());
    assertEquals(r.getModifications().length, 1);
    modifyRequest = r.toModifyRequest();
    assertEquals(modifyRequest.getDN(), "dc=example,dc=com");
    assertEquals(r.getChangeType(), ChangeType.MODIFY);
    assertTrue(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
    ldifLines = r.toLDIF();
    assertNotNull(ldifLines);
    assertEquals(ldifLines.length, 6);
    byteBuffer = new ByteStringBuffer();
    r.toLDIF(byteBuffer);
    assertNotNull(byteBuffer.toString());
    byteBuffer = new ByteStringBuffer();
    r.toLDIF(byteBuffer, 10);
    assertNotNull(byteBuffer.toString());
    stringBuffer = new StringBuilder();
    r.toLDIFString(stringBuffer);
    assertNotNull(r.toString());
    stringBuffer = new StringBuilder();
    r.toLDIFString(stringBuffer, 10);
    assertNotNull(r.toString());
    assertNotNull(r.toLDIFString());
    assertNotNull(r.toLDIFString(10));
    assertNotNull(r.toString());
    LDIFModifyChangeRecord.setAlwaysIncludeTrailingDash(false);
    assertFalse(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
    ldifLines = r.toLDIF();
    assertNotNull(ldifLines);
    assertEquals(ldifLines.length, 5);
    LDIFModifyChangeRecord.setAlwaysIncludeTrailingDash(true);
    assertTrue(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
    r.hashCode();
    byteBuffer = new ByteStringBuffer();
    r.toLDIF(byteBuffer);
    assertNotNull(byteBuffer.toString());
    byteBuffer = new ByteStringBuffer();
    r.toLDIF(byteBuffer, 10);
    assertNotNull(byteBuffer.toString());
    stringBuffer = new StringBuilder();
    r.toLDIFString(stringBuffer);
    assertNotNull(r.toString());
    stringBuffer = new StringBuilder();
    r.toLDIFString(stringBuffer, 10);
    assertNotNull(r.toString());
    assertNotNull(r.toLDIFString());
    assertNotNull(r.toLDIFString(10));
    assertNotNull(r.toString());
    assertNotNull(r.getControls());
    assertFalse(r.getControls().isEmpty());
    assertEquals(r.getControls(), Collections.singletonList(new ManageDsaITRequestControl(false)));
    r = r.duplicate(new ManageDsaITRequestControl(false), new PermissiveModifyRequestControl(false));
    assertNotNull(r.getDN());
    assertEquals(r.getDN(), "dc=example,dc=com");
    assertEquals(r.getParsedDN(), new DN("dc=example,dc=com"));
    assertNotNull(r.getModifications());
    assertEquals(r.getModifications().length, 1);
    modifyRequest = r.toModifyRequest();
    assertEquals(modifyRequest.getDN(), "dc=example,dc=com");
    assertEquals(r.getChangeType(), ChangeType.MODIFY);
    assertTrue(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
    ldifLines = r.toLDIF();
    assertNotNull(ldifLines);
    assertEquals(ldifLines.length, 7);
    byteBuffer = new ByteStringBuffer();
    r.toLDIF(byteBuffer);
    assertNotNull(byteBuffer.toString());
    byteBuffer = new ByteStringBuffer();
    r.toLDIF(byteBuffer, 10);
    assertNotNull(byteBuffer.toString());
    stringBuffer = new StringBuilder();
    r.toLDIFString(stringBuffer);
    assertNotNull(r.toString());
    stringBuffer = new StringBuilder();
    r.toLDIFString(stringBuffer, 10);
    assertNotNull(r.toString());
    assertNotNull(r.toLDIFString());
    assertNotNull(r.toLDIFString(10));
    assertNotNull(r.toString());
    LDIFModifyChangeRecord.setAlwaysIncludeTrailingDash(false);
    assertFalse(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
    ldifLines = r.toLDIF();
    assertNotNull(ldifLines);
    assertEquals(ldifLines.length, 6);
    LDIFModifyChangeRecord.setAlwaysIncludeTrailingDash(true);
    assertTrue(LDIFModifyChangeRecord.alwaysIncludeTrailingDash());
    r.hashCode();
    byteBuffer = new ByteStringBuffer();
    r.toLDIF(byteBuffer);
    assertNotNull(byteBuffer.toString());
    byteBuffer = new ByteStringBuffer();
    r.toLDIF(byteBuffer, 10);
    assertNotNull(byteBuffer.toString());
    stringBuffer = new StringBuilder();
    r.toLDIFString(stringBuffer);
    assertNotNull(r.toString());
    stringBuffer = new StringBuilder();
    r.toLDIFString(stringBuffer, 10);
    assertNotNull(r.toString());
    assertNotNull(r.toLDIFString());
    assertNotNull(r.toLDIFString(10));
    assertNotNull(r.toString());
    assertNotNull(r.getControls());
    assertFalse(r.getControls().isEmpty());
    assertEquals(r.getControls(), Arrays.asList(new ManageDsaITRequestControl(false), new PermissiveModifyRequestControl(false)));
}
Also used : PermissiveModifyRequestControl(com.unboundid.ldap.sdk.controls.PermissiveModifyRequestControl) Modification(com.unboundid.ldap.sdk.Modification) ManageDsaITRequestControl(com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl) Control(com.unboundid.ldap.sdk.Control) PermissiveModifyRequestControl(com.unboundid.ldap.sdk.controls.PermissiveModifyRequestControl) DN(com.unboundid.ldap.sdk.DN) ModifyRequest(com.unboundid.ldap.sdk.ModifyRequest) ByteStringBuffer(com.unboundid.util.ByteStringBuffer) ManageDsaITRequestControl(com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl) Test(org.testng.annotations.Test)

Example 2 with PermissiveModifyRequestControl

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

the class ParallelUpdate method getOperationControls.

/**
 * Updates the provided lists with the appropriate controls to include in
 * each type of request.
 *
 * @param  addControls       The list that should be updated with controls to
 *                           include in add requests.  It must not be
 *                           {@code null} and must be updatable.
 * @param  deleteControls    The list that should be updated with controls to
 *                           include in delete requests.  It must not be
 *                           {@code null} and must be updatable.
 * @param  modifyControls    The list that should be updated with controls to
 *                           include in modify requests.  It must not be
 *                           {@code null} and must be updatable.
 * @param  modifyDNControls  The list that should be updated with controls to
 *                           include in modify DN requests.  It must not be
 *                           {@code null} and must be updatable.
 *
 * @throws  LDAPException  If a problem is encountered while creating any of
 *                         the controls.
 */
private void getOperationControls(@NotNull final List<Control> addControls, @NotNull final List<Control> deleteControls, @NotNull final List<Control> modifyControls, @NotNull final List<Control> modifyDNControls) throws LDAPException {
    if (addControlArg.isPresent()) {
        addControls.addAll(addControlArg.getValues());
    }
    if (deleteControlArg.isPresent()) {
        deleteControls.addAll(deleteControlArg.getValues());
    }
    if (modifyControlArg.isPresent()) {
        modifyControls.addAll(modifyControlArg.getValues());
    }
    if (modifyDNControlArg.isPresent()) {
        modifyDNControls.addAll(modifyDNControlArg.getValues());
    }
    if (proxyAsArg.isPresent()) {
        final ProxiedAuthorizationV2RequestControl c = new ProxiedAuthorizationV2RequestControl(proxyAsArg.getValue());
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    } else if (proxyV1AsArg.isPresent()) {
        final ProxiedAuthorizationV1RequestControl c = new ProxiedAuthorizationV1RequestControl(proxyV1AsArg.getValue());
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
    if (usePermissiveModifyArg.isPresent()) {
        modifyControls.add(new PermissiveModifyRequestControl(true));
    }
    if (ignoreNoUserModificationArg.isPresent()) {
        final IgnoreNoUserModificationRequestControl c = new IgnoreNoUserModificationRequestControl();
        addControls.add(c);
        modifyControls.add(c);
    }
    if (useManageDsaITArg.isPresent()) {
        final ManageDsaITRequestControl c = new ManageDsaITRequestControl(true);
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
    if (nameWithEntryUUIDArg.isPresent()) {
        addControls.add(new NameWithEntryUUIDRequestControl(true));
    }
    if (softDeleteArg.isPresent()) {
        deleteControls.add(new SoftDeleteRequestControl(true, true));
    } else if (hardDeleteArg.isPresent()) {
        deleteControls.add(new HardDeleteRequestControl(true));
    }
    if (operationPurposeArg.isPresent()) {
        final OperationPurposeRequestControl c = new OperationPurposeRequestControl(false, "parallel-update", Version.NUMERIC_VERSION_STRING, ParallelUpdate.class.getName() + ".getOperationControls", operationPurposeArg.getValue());
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
    if (replicationRepairArg.isPresent()) {
        final ReplicationRepairRequestControl c = new ReplicationRepairRequestControl();
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
    if (suppressReferentialIntegrityUpdatesArg.isPresent()) {
        final SuppressReferentialIntegrityUpdatesRequestControl c = new SuppressReferentialIntegrityUpdatesRequestControl(true);
        deleteControls.add(c);
        modifyDNControls.add(c);
    }
    if (useAssuredReplicationArg.isPresent()) {
        final AssuredReplicationLocalLevel localLevel;
        if (assuredReplicationLocalLevelArg.isPresent()) {
            final String localLevelStr = StaticUtils.toLowerCase(assuredReplicationLocalLevelArg.getValue());
            switch(localLevelStr) {
                case ASSURED_REPLICATION_LOCAL_LEVEL_NONE:
                    localLevel = AssuredReplicationLocalLevel.NONE;
                    break;
                case ASSURED_REPLICATION_LOCAL_LEVEL_RECEIVED_ANY_SERVER:
                    localLevel = AssuredReplicationLocalLevel.RECEIVED_ANY_SERVER;
                    break;
                case ASSURED_REPLICATION_LOCAL_LEVEL_PROCESSED_ALL_SERVERS:
                    localLevel = AssuredReplicationLocalLevel.PROCESSED_ALL_SERVERS;
                    break;
                default:
                    // This should never happen.
                    localLevel = null;
                    break;
            }
        } else {
            localLevel = null;
        }
        final AssuredReplicationRemoteLevel remoteLevel;
        if (assuredReplicationRemoteLevelArg.isPresent()) {
            final String remoteLevelStr = StaticUtils.toLowerCase(assuredReplicationRemoteLevelArg.getValue());
            switch(remoteLevelStr) {
                case ASSURED_REPLICATION_REMOTE_LEVEL_NONE:
                    remoteLevel = AssuredReplicationRemoteLevel.NONE;
                    break;
                case ASSURED_REPLICATION_REMOTE_LEVEL_RECEIVED_ANY_REMOTE_LOCATION:
                    remoteLevel = AssuredReplicationRemoteLevel.RECEIVED_ANY_REMOTE_LOCATION;
                    break;
                case ASSURED_REPLICATION_REMOTE_LEVEL_RECEIVED_ALL_REMOTE_LOCATIONS:
                    remoteLevel = AssuredReplicationRemoteLevel.RECEIVED_ALL_REMOTE_LOCATIONS;
                    break;
                case ASSURED_REPLICATION_REMOTE_LEVEL_PROCESSED_ALL_REMOTE_SERVERS:
                    remoteLevel = AssuredReplicationRemoteLevel.PROCESSED_ALL_REMOTE_SERVERS;
                    break;
                default:
                    // This should never happen.
                    remoteLevel = null;
                    break;
            }
        } else {
            remoteLevel = null;
        }
        final Long timeoutMillis;
        if (assuredReplicationTimeoutArg.isPresent()) {
            timeoutMillis = assuredReplicationTimeoutArg.getValue(TimeUnit.MILLISECONDS);
        } else {
            timeoutMillis = null;
        }
        final AssuredReplicationRequestControl c = new AssuredReplicationRequestControl(true, localLevel, null, remoteLevel, null, timeoutMillis, false);
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
    if (passwordUpdateBehaviorArg.isPresent()) {
        final PasswordUpdateBehaviorRequestControlProperties properties = new PasswordUpdateBehaviorRequestControlProperties();
        for (final String argValue : passwordUpdateBehaviorArg.getValues()) {
            final int equalPos = argValue.indexOf('=');
            if (equalPos < 0) {
                throw new LDAPException(ResultCode.PARAM_ERROR, ERR_PARALLEL_UPDATE_MALFORMED_PW_UPDATE_VALUE.get(argValue, passwordUpdateBehaviorArg.getIdentifierString()));
            }
            final String propertyName = argValue.substring(0, equalPos).trim();
            final String lowerName = StaticUtils.toLowerCase(propertyName);
            switch(lowerName) {
                case PW_UPDATE_BEHAVIOR_NAME_IS_SELF_CHANGE:
                    properties.setIsSelfChange(getBooleanPWUpdateBehaviorValue(argValue));
                    break;
                case PW_UPDATE_BEHAVIOR_NAME_ALLOW_PRE_ENCODED_PW:
                    properties.setAllowPreEncodedPassword(getBooleanPWUpdateBehaviorValue(argValue));
                    break;
                case PW_UPDATE_BEHAVIOR_NAME_SKIP_PW_VALIDATION:
                    properties.setSkipPasswordValidation(getBooleanPWUpdateBehaviorValue(argValue));
                    break;
                case PW_UPDATE_BEHAVIOR_NAME_IGNORE_PW_HISTORY:
                    properties.setIgnorePasswordHistory(getBooleanPWUpdateBehaviorValue(argValue));
                    break;
                case PW_UPDATE_BEHAVIOR_NAME_IGNORE_MIN_PW_AGE:
                    properties.setIgnoreMinimumPasswordAge(getBooleanPWUpdateBehaviorValue(argValue));
                    break;
                case PW_UPDATE_BEHAVIOR_NAME_MUST_CHANGE_PW:
                    properties.setMustChangePassword(getBooleanPWUpdateBehaviorValue(argValue));
                    break;
                case PW_UPDATE_BEHAVIOR_NAME_PW_STORAGE_SCHEME:
                    final String propertyValue = argValue.substring(equalPos + 1).trim();
                    properties.setPasswordStorageScheme(propertyValue);
                    break;
                default:
                    throw new LDAPException(ResultCode.PARAM_ERROR, ERR_PARALLEL_UPDATE_UNKNOWN_PW_UPDATE_PROP.get(argValue, passwordUpdateBehaviorArg.getIdentifierString(), PW_UPDATE_BEHAVIOR_NAME_IS_SELF_CHANGE, PW_UPDATE_BEHAVIOR_NAME_ALLOW_PRE_ENCODED_PW, PW_UPDATE_BEHAVIOR_NAME_SKIP_PW_VALIDATION, PW_UPDATE_BEHAVIOR_NAME_IGNORE_PW_HISTORY, PW_UPDATE_BEHAVIOR_NAME_IGNORE_MIN_PW_AGE, PW_UPDATE_BEHAVIOR_NAME_PW_STORAGE_SCHEME, PW_UPDATE_BEHAVIOR_NAME_MUST_CHANGE_PW));
            }
        }
        final PasswordUpdateBehaviorRequestControl c = new PasswordUpdateBehaviorRequestControl(properties, true);
        addControls.add(c);
        modifyControls.add(c);
    }
    if (suppressOperationalAttributeUpdatesArg.isPresent()) {
        final EnumSet<SuppressType> suppressTypes = EnumSet.noneOf(SuppressType.class);
        for (final String s : suppressOperationalAttributeUpdatesArg.getValues()) {
            if (s.equalsIgnoreCase(SUPPRESS_OP_ATTR_LAST_ACCESS_TIME)) {
                suppressTypes.add(SuppressType.LAST_ACCESS_TIME);
            } else if (s.equalsIgnoreCase(SUPPRESS_OP_ATTR_LAST_LOGIN_TIME)) {
                suppressTypes.add(SuppressType.LAST_LOGIN_TIME);
            } else if (s.equalsIgnoreCase(SUPPRESS_OP_ATTR_LAST_LOGIN_IP)) {
                suppressTypes.add(SuppressType.LAST_LOGIN_IP);
            }
        }
        final SuppressOperationalAttributeUpdateRequestControl c = new SuppressOperationalAttributeUpdateRequestControl(true, suppressTypes);
        addControls.add(c);
        deleteControls.add(c);
        modifyControls.add(c);
        modifyDNControls.add(c);
    }
}
Also used : SuppressReferentialIntegrityUpdatesRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.SuppressReferentialIntegrityUpdatesRequestControl) AssuredReplicationRemoteLevel(com.unboundid.ldap.sdk.unboundidds.controls.AssuredReplicationRemoteLevel) SoftDeleteRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.SoftDeleteRequestControl) AssuredReplicationRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.AssuredReplicationRequestControl) PasswordUpdateBehaviorRequestControlProperties(com.unboundid.ldap.sdk.unboundidds.controls.PasswordUpdateBehaviorRequestControlProperties) ProxiedAuthorizationV2RequestControl(com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV2RequestControl) SuppressType(com.unboundid.ldap.sdk.unboundidds.controls.SuppressType) SuppressOperationalAttributeUpdateRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.SuppressOperationalAttributeUpdateRequestControl) PermissiveModifyRequestControl(com.unboundid.ldap.sdk.controls.PermissiveModifyRequestControl) OperationPurposeRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.OperationPurposeRequestControl) ProxiedAuthorizationV1RequestControl(com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV1RequestControl) NameWithEntryUUIDRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.NameWithEntryUUIDRequestControl) LDAPException(com.unboundid.ldap.sdk.LDAPException) HardDeleteRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.HardDeleteRequestControl) ReplicationRepairRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.ReplicationRepairRequestControl) IgnoreNoUserModificationRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.IgnoreNoUserModificationRequestControl) AtomicLong(java.util.concurrent.atomic.AtomicLong) AssuredReplicationLocalLevel(com.unboundid.ldap.sdk.unboundidds.controls.AssuredReplicationLocalLevel) PasswordUpdateBehaviorRequestControl(com.unboundid.ldap.sdk.unboundidds.controls.PasswordUpdateBehaviorRequestControl) ManageDsaITRequestControl(com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl)

Example 3 with PermissiveModifyRequestControl

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

the class InMemoryDirectoryControlsTestCase method testPermissiveModifyControl.

/**
 * Provides test coverage for the permissive modify request control.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testPermissiveModifyControl() throws Exception {
    final InMemoryDirectoryServer ds = getTestDS(true, true);
    final LDAPConnection conn = ds.getConnection();
    final PermissiveModifyRequestControl c = new PermissiveModifyRequestControl();
    // Try to remove a value that doesn't exist without the control.
    ModifyRequest modifyRequest = new ModifyRequest("dn: uid=test.user,ou=People,dc=example,dc=com", "changetype: modify", "delete: description", "description: foo");
    try {
        conn.modify(modifyRequest);
    } catch (final LDAPException le) {
        assertEquals(le.getResultCode(), ResultCode.NO_SUCH_ATTRIBUTE);
    }
    // Try the same modification with the control.
    modifyRequest.setControls(c);
    LDAPResult modifyResult = conn.modify(modifyRequest);
    assertEquals(modifyResult.getResultCode(), ResultCode.SUCCESS);
    // Try to add a value that already exists without the control.
    modifyRequest = new ModifyRequest("dn: uid=test.user,ou=People,dc=example,dc=com", "changetype: modify", "add: givenName", "givenName: Test");
    try {
        conn.modify(modifyRequest);
    } catch (final LDAPException le) {
        assertEquals(le.getResultCode(), ResultCode.ATTRIBUTE_OR_VALUE_EXISTS);
    }
    // Try the same modification with the control.
    modifyRequest.setControls(c);
    modifyResult = conn.modify(modifyRequest);
    assertEquals(modifyResult.getResultCode(), ResultCode.SUCCESS);
    conn.close();
}
Also used : PermissiveModifyRequestControl(com.unboundid.ldap.sdk.controls.PermissiveModifyRequestControl) LDAPException(com.unboundid.ldap.sdk.LDAPException) LDAPResult(com.unboundid.ldap.sdk.LDAPResult) LDAPConnection(com.unboundid.ldap.sdk.LDAPConnection) ModifyRequest(com.unboundid.ldap.sdk.ModifyRequest) Test(org.testng.annotations.Test)

Example 4 with PermissiveModifyRequestControl

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

the class RequestControlPreProcessorTestCase method testPermissiveModifyControl.

/**
 * Provides test coverage for the permissive modify control.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testPermissiveModifyControl() throws Exception {
    final String oid = PermissiveModifyRequestControl.PERMISSIVE_MODIFY_REQUEST_OID;
    final Control vc = new PermissiveModifyRequestControl(true);
    final Control vn = new PermissiveModifyRequestControl(false);
    final Control ic = new Control(oid, true, new ASN1OctetString("foo"));
    final Control in = new Control(oid, false, new ASN1OctetString("foo"));
    final Class<?> c = PermissiveModifyRequestControl.class;
    // Test with acceptable operation types.
    for (final byte opType : Arrays.asList(LDAPMessage.PROTOCOL_OP_TYPE_MODIFY_REQUEST)) {
        // A valid critical control.
        ensureControlHandled(opType, Arrays.asList(vc), oid, c);
        // A valid non-critical control.
        ensureControlHandled(opType, Arrays.asList(vn), oid, c);
        // Multiple instances of the control.
        ensureException(opType, Arrays.asList(vc, vn));
        // Malformed critical control.
        ensureException(opType, Arrays.asList(ic));
        // Malformed non-critical control.
        ensureException(opType, Arrays.asList(in));
    }
    // Test with unacceptable operation types.
    for (final byte opType : Arrays.asList(LDAPMessage.PROTOCOL_OP_TYPE_ABANDON_REQUEST, LDAPMessage.PROTOCOL_OP_TYPE_ADD_REQUEST, LDAPMessage.PROTOCOL_OP_TYPE_BIND_REQUEST, LDAPMessage.PROTOCOL_OP_TYPE_COMPARE_REQUEST, LDAPMessage.PROTOCOL_OP_TYPE_DELETE_REQUEST, LDAPMessage.PROTOCOL_OP_TYPE_EXTENDED_REQUEST, LDAPMessage.PROTOCOL_OP_TYPE_MODIFY_DN_REQUEST, LDAPMessage.PROTOCOL_OP_TYPE_SEARCH_REQUEST, LDAPMessage.PROTOCOL_OP_TYPE_UNBIND_REQUEST)) {
        // A valid critical control.
        ensureException(opType, Arrays.asList(vc));
        // A valid non-critical control.
        ensureControlIgnored(opType, Arrays.asList(vn), oid);
        // Malformed critical control.
        ensureException(opType, Arrays.asList(ic));
        // Malformed non-critical control.
        ensureControlIgnored(opType, Arrays.asList(in), oid);
    }
}
Also used : PermissiveModifyRequestControl(com.unboundid.ldap.sdk.controls.PermissiveModifyRequestControl) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) VirtualListViewRequestControl(com.unboundid.ldap.sdk.controls.VirtualListViewRequestControl) AuthorizationIdentityRequestControl(com.unboundid.ldap.sdk.controls.AuthorizationIdentityRequestControl) DontUseCopyRequestControl(com.unboundid.ldap.sdk.controls.DontUseCopyRequestControl) Control(com.unboundid.ldap.sdk.Control) ProxiedAuthorizationV1RequestControl(com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV1RequestControl) SubtreeDeleteRequestControl(com.unboundid.ldap.sdk.controls.SubtreeDeleteRequestControl) RFC3672SubentriesRequestControl(com.unboundid.ldap.sdk.controls.RFC3672SubentriesRequestControl) SimplePagedResultsControl(com.unboundid.ldap.sdk.controls.SimplePagedResultsControl) AssertionRequestControl(com.unboundid.ldap.sdk.controls.AssertionRequestControl) TransactionSpecificationRequestControl(com.unboundid.ldap.sdk.controls.TransactionSpecificationRequestControl) ManageDsaITRequestControl(com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl) ProxiedAuthorizationV2RequestControl(com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV2RequestControl) ServerSideSortRequestControl(com.unboundid.ldap.sdk.controls.ServerSideSortRequestControl) PostReadRequestControl(com.unboundid.ldap.sdk.controls.PostReadRequestControl) DraftLDUPSubentriesRequestControl(com.unboundid.ldap.sdk.controls.DraftLDUPSubentriesRequestControl) PreReadRequestControl(com.unboundid.ldap.sdk.controls.PreReadRequestControl) PermissiveModifyRequestControl(com.unboundid.ldap.sdk.controls.PermissiveModifyRequestControl) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Test(org.testng.annotations.Test)

Example 5 with PermissiveModifyRequestControl

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

the class ModRate method doToolProcessing.

/**
 * Performs the actual processing for this tool.  In this case, it gets a
 * connection to the directory server and uses it to perform the requested
 * modifications.
 *
 * @return  The result code for the processing that was performed.
 */
@Override()
@NotNull()
public ResultCode doToolProcessing() {
    // variable rate data file and return.
    if (sampleRateFile.isPresent()) {
        try {
            RateAdjustor.writeSampleVariableRateFile(sampleRateFile.getValue());
            return ResultCode.SUCCESS;
        } catch (final Exception e) {
            Debug.debugException(e);
            err("An error occurred while trying to write sample variable data " + "rate file '", sampleRateFile.getValue().getAbsolutePath(), "':  ", StaticUtils.getExceptionMessage(e));
            return ResultCode.LOCAL_ERROR;
        }
    }
    // Determine the random seed to use.
    final Long seed;
    if (randomSeed.isPresent()) {
        seed = Long.valueOf(randomSeed.getValue());
    } else {
        seed = null;
    }
    // Create the value patterns for the target entry DN and proxied
    // authorization identities.
    final ValuePattern dnPattern;
    try {
        dnPattern = new ValuePattern(entryDN.getValue(), seed);
    } catch (final ParseException pe) {
        Debug.debugException(pe);
        err("Unable to parse the entry DN value pattern:  ", pe.getMessage());
        return ResultCode.PARAM_ERROR;
    }
    final ValuePattern authzIDPattern;
    if (proxyAs.isPresent()) {
        try {
            authzIDPattern = new ValuePattern(proxyAs.getValue(), seed);
        } catch (final ParseException pe) {
            Debug.debugException(pe);
            err("Unable to parse the proxied authorization pattern:  ", pe.getMessage());
            return ResultCode.PARAM_ERROR;
        }
    } else {
        authzIDPattern = null;
    }
    // Get the set of controls to include in modify requests.
    final ArrayList<Control> controlList = new ArrayList<>(5);
    if (assertionFilter.isPresent()) {
        controlList.add(new AssertionRequestControl(assertionFilter.getValue()));
    }
    if (permissiveModify.isPresent()) {
        controlList.add(new PermissiveModifyRequestControl());
    }
    if (preReadAttribute.isPresent()) {
        final List<String> attrList = preReadAttribute.getValues();
        final String[] attrArray = new String[attrList.size()];
        attrList.toArray(attrArray);
        controlList.add(new PreReadRequestControl(attrArray));
    }
    if (postReadAttribute.isPresent()) {
        final List<String> attrList = postReadAttribute.getValues();
        final String[] attrArray = new String[attrList.size()];
        attrList.toArray(attrArray);
        controlList.add(new PostReadRequestControl(attrArray));
    }
    if (control.isPresent()) {
        controlList.addAll(control.getValues());
    }
    final Control[] controlArray = new Control[controlList.size()];
    controlList.toArray(controlArray);
    // Get the names of the attributes to modify.
    final String[] attrs = new String[attribute.getValues().size()];
    attribute.getValues().toArray(attrs);
    // If the --ratePerSecond option was specified, then limit the rate
    // accordingly.
    FixedRateBarrier fixedRateBarrier = null;
    if (ratePerSecond.isPresent() || variableRateData.isPresent()) {
        // We might not have a rate per second if --variableRateData is specified.
        // The rate typically doesn't matter except when we have warm-up
        // intervals.  In this case, we'll run at the max rate.
        final int intervalSeconds = collectionInterval.getValue();
        final int ratePerInterval = (ratePerSecond.getValue() == null) ? Integer.MAX_VALUE : ratePerSecond.getValue() * intervalSeconds;
        fixedRateBarrier = new FixedRateBarrier(1000L * intervalSeconds, ratePerInterval);
    }
    // If --variableRateData was specified, then initialize a RateAdjustor.
    RateAdjustor rateAdjustor = null;
    if (variableRateData.isPresent()) {
        try {
            rateAdjustor = RateAdjustor.newInstance(fixedRateBarrier, ratePerSecond.getValue(), variableRateData.getValue());
        } catch (final IOException | IllegalArgumentException e) {
            Debug.debugException(e);
            err("Initializing the variable rates failed: " + e.getMessage());
            return ResultCode.PARAM_ERROR;
        }
    }
    // Determine whether to include timestamps in the output and if so what
    // format should be used for them.
    final boolean includeTimestamp;
    final String timeFormat;
    if (timestampFormat.getValue().equalsIgnoreCase("with-date")) {
        includeTimestamp = true;
        timeFormat = "dd/MM/yyyy HH:mm:ss";
    } else if (timestampFormat.getValue().equalsIgnoreCase("without-date")) {
        includeTimestamp = true;
        timeFormat = "HH:mm:ss";
    } else {
        includeTimestamp = false;
        timeFormat = null;
    }
    // Determine whether any warm-up intervals should be run.
    final long totalIntervals;
    final boolean warmUp;
    int remainingWarmUpIntervals = warmUpIntervals.getValue();
    if (remainingWarmUpIntervals > 0) {
        warmUp = true;
        totalIntervals = 0L + numIntervals.getValue() + remainingWarmUpIntervals;
    } else {
        warmUp = true;
        totalIntervals = 0L + numIntervals.getValue();
    }
    // Create the table that will be used to format the output.
    final OutputFormat outputFormat;
    if (csvFormat.isPresent()) {
        outputFormat = OutputFormat.CSV;
    } else {
        outputFormat = OutputFormat.COLUMNS;
    }
    final ColumnFormatter formatter = new ColumnFormatter(includeTimestamp, timeFormat, outputFormat, " ", new FormattableColumn(12, HorizontalAlignment.RIGHT, "Recent", "Mods/Sec"), new FormattableColumn(12, HorizontalAlignment.RIGHT, "Recent", "Avg Dur ms"), new FormattableColumn(12, HorizontalAlignment.RIGHT, "Recent", "Errors/Sec"), new FormattableColumn(12, HorizontalAlignment.RIGHT, "Overall", "Mods/Sec"), new FormattableColumn(12, HorizontalAlignment.RIGHT, "Overall", "Avg Dur ms"));
    // Create values to use for statistics collection.
    final AtomicLong modCounter = new AtomicLong(0L);
    final AtomicLong errorCounter = new AtomicLong(0L);
    final AtomicLong modDurations = new AtomicLong(0L);
    final ResultCodeCounter rcCounter = new ResultCodeCounter();
    // Determine the length of each interval in milliseconds.
    final long intervalMillis = 1000L * collectionInterval.getValue();
    // Create the threads to use for the modifications.
    final CyclicBarrier barrier = new CyclicBarrier(numThreads.getValue() + 1);
    final ModRateThread[] threads = new ModRateThread[numThreads.getValue()];
    for (int i = 0; i < threads.length; i++) {
        final LDAPConnection connection;
        try {
            connection = getConnection();
        } catch (final LDAPException le) {
            Debug.debugException(le);
            err("Unable to connect to the directory server:  ", StaticUtils.getExceptionMessage(le));
            return le.getResultCode();
        }
        final String valuePatternString;
        if (valuePattern.isPresent()) {
            valuePatternString = valuePattern.getValue();
        } else {
            final int length;
            if (valueLength.isPresent()) {
                length = valueLength.getValue();
            } else {
                length = 10;
            }
            final String charSet;
            if (characterSet.isPresent()) {
                charSet = characterSet.getValue().replace("]", "]]").replace("[", "[[");
            } else {
                charSet = "abcdefghijklmnopqrstuvwxyz";
            }
            valuePatternString = "[random:" + length + ':' + charSet + ']';
        }
        final ValuePattern parsedValuePattern;
        try {
            parsedValuePattern = new ValuePattern(valuePatternString);
        } catch (final ParseException e) {
            Debug.debugException(e);
            err(e.getMessage());
            return ResultCode.PARAM_ERROR;
        }
        threads[i] = new ModRateThread(this, i, connection, dnPattern, attrs, parsedValuePattern, valueCount.getValue(), increment.isPresent(), incrementAmount.getValue(), controlArray, authzIDPattern, iterationsBeforeReconnect.getValue(), runningThreads, barrier, modCounter, modDurations, errorCounter, rcCounter, fixedRateBarrier);
        threads[i].start();
    }
    // Display the table header.
    for (final String headerLine : formatter.getHeaderLines(true)) {
        out(headerLine);
    }
    // which case, we'll start it after the warm-up is complete.
    if ((rateAdjustor != null) && (remainingWarmUpIntervals <= 0)) {
        rateAdjustor.start();
    }
    // Indicate that the threads can start running.
    try {
        barrier.await();
    } catch (final Exception e) {
        Debug.debugException(e);
    }
    long overallStartTime = System.nanoTime();
    long nextIntervalStartTime = System.currentTimeMillis() + intervalMillis;
    boolean setOverallStartTime = false;
    long lastDuration = 0L;
    long lastNumErrors = 0L;
    long lastNumMods = 0L;
    long lastEndTime = System.nanoTime();
    for (long i = 0; i < totalIntervals; i++) {
        if (rateAdjustor != null) {
            if (!rateAdjustor.isAlive()) {
                out("All of the rates in " + variableRateData.getValue().getName() + " have been completed.");
                break;
            }
        }
        final long startTimeMillis = System.currentTimeMillis();
        final long sleepTimeMillis = nextIntervalStartTime - startTimeMillis;
        nextIntervalStartTime += intervalMillis;
        if (sleepTimeMillis > 0) {
            sleeper.sleep(sleepTimeMillis);
        }
        if (stopRequested.get()) {
            break;
        }
        final long endTime = System.nanoTime();
        final long intervalDuration = endTime - lastEndTime;
        final long numMods;
        final long numErrors;
        final long totalDuration;
        if (warmUp && (remainingWarmUpIntervals > 0)) {
            numMods = modCounter.getAndSet(0L);
            numErrors = errorCounter.getAndSet(0L);
            totalDuration = modDurations.getAndSet(0L);
        } else {
            numMods = modCounter.get();
            numErrors = errorCounter.get();
            totalDuration = modDurations.get();
        }
        final long recentNumMods = numMods - lastNumMods;
        final long recentNumErrors = numErrors - lastNumErrors;
        final long recentDuration = totalDuration - lastDuration;
        final double numSeconds = intervalDuration / 1_000_000_000.0d;
        final double recentModRate = recentNumMods / numSeconds;
        final double recentErrorRate = recentNumErrors / numSeconds;
        final double recentAvgDuration;
        if (recentNumMods > 0L) {
            recentAvgDuration = 1.0d * recentDuration / recentNumMods / 1_000_000;
        } else {
            recentAvgDuration = 0.0d;
        }
        if (warmUp && (remainingWarmUpIntervals > 0)) {
            out(formatter.formatRow(recentModRate, recentAvgDuration, recentErrorRate, "warming up", "warming up"));
            remainingWarmUpIntervals--;
            if (remainingWarmUpIntervals == 0) {
                out("Warm-up completed.  Beginning overall statistics collection.");
                setOverallStartTime = true;
                if (rateAdjustor != null) {
                    rateAdjustor.start();
                }
            }
        } else {
            if (setOverallStartTime) {
                overallStartTime = lastEndTime;
                setOverallStartTime = false;
            }
            final double numOverallSeconds = (endTime - overallStartTime) / 1_000_000_000.0d;
            final double overallAuthRate = numMods / numOverallSeconds;
            final double overallAvgDuration;
            if (numMods > 0L) {
                overallAvgDuration = 1.0d * totalDuration / numMods / 1_000_000;
            } else {
                overallAvgDuration = 0.0d;
            }
            out(formatter.formatRow(recentModRate, recentAvgDuration, recentErrorRate, overallAuthRate, overallAvgDuration));
            lastNumMods = numMods;
            lastNumErrors = numErrors;
            lastDuration = totalDuration;
        }
        final List<ObjectPair<ResultCode, Long>> rcCounts = rcCounter.getCounts(true);
        if ((!suppressErrorsArgument.isPresent()) && (!rcCounts.isEmpty())) {
            err("\tError Results:");
            for (final ObjectPair<ResultCode, Long> p : rcCounts) {
                err("\t", p.getFirst().getName(), ":  ", p.getSecond());
            }
        }
        lastEndTime = endTime;
    }
    // Shut down the RateAdjustor if we have one.
    if (rateAdjustor != null) {
        rateAdjustor.shutDown();
    }
    // Stop all of the threads.
    ResultCode resultCode = ResultCode.SUCCESS;
    for (final ModRateThread t : threads) {
        final ResultCode r = t.stopRunning();
        if (resultCode == ResultCode.SUCCESS) {
            resultCode = r;
        }
    }
    return resultCode;
}
Also used : ValuePattern(com.unboundid.util.ValuePattern) ArrayList(java.util.ArrayList) PreReadRequestControl(com.unboundid.ldap.sdk.controls.PreReadRequestControl) PermissiveModifyRequestControl(com.unboundid.ldap.sdk.controls.PermissiveModifyRequestControl) Control(com.unboundid.ldap.sdk.Control) AssertionRequestControl(com.unboundid.ldap.sdk.controls.AssertionRequestControl) PostReadRequestControl(com.unboundid.ldap.sdk.controls.PostReadRequestControl) PreReadRequestControl(com.unboundid.ldap.sdk.controls.PreReadRequestControl) PermissiveModifyRequestControl(com.unboundid.ldap.sdk.controls.PermissiveModifyRequestControl) AssertionRequestControl(com.unboundid.ldap.sdk.controls.AssertionRequestControl) FormattableColumn(com.unboundid.util.FormattableColumn) ColumnFormatter(com.unboundid.util.ColumnFormatter) OutputFormat(com.unboundid.util.OutputFormat) RateAdjustor(com.unboundid.util.RateAdjustor) IOException(java.io.IOException) LDAPConnection(com.unboundid.ldap.sdk.LDAPConnection) ResultCodeCounter(com.unboundid.util.ResultCodeCounter) ArgumentException(com.unboundid.util.args.ArgumentException) ParseException(java.text.ParseException) LDAPException(com.unboundid.ldap.sdk.LDAPException) IOException(java.io.IOException) CyclicBarrier(java.util.concurrent.CyclicBarrier) AtomicLong(java.util.concurrent.atomic.AtomicLong) LDAPException(com.unboundid.ldap.sdk.LDAPException) AtomicLong(java.util.concurrent.atomic.AtomicLong) FixedRateBarrier(com.unboundid.util.FixedRateBarrier) ParseException(java.text.ParseException) PostReadRequestControl(com.unboundid.ldap.sdk.controls.PostReadRequestControl) ResultCode(com.unboundid.ldap.sdk.ResultCode) ObjectPair(com.unboundid.util.ObjectPair) NotNull(com.unboundid.util.NotNull)

Aggregations

PermissiveModifyRequestControl (com.unboundid.ldap.sdk.controls.PermissiveModifyRequestControl)7 Control (com.unboundid.ldap.sdk.Control)4 LDAPException (com.unboundid.ldap.sdk.LDAPException)4 AssertionRequestControl (com.unboundid.ldap.sdk.controls.AssertionRequestControl)4 ManageDsaITRequestControl (com.unboundid.ldap.sdk.controls.ManageDsaITRequestControl)4 PostReadRequestControl (com.unboundid.ldap.sdk.controls.PostReadRequestControl)4 PreReadRequestControl (com.unboundid.ldap.sdk.controls.PreReadRequestControl)4 LDAPConnection (com.unboundid.ldap.sdk.LDAPConnection)3 ProxiedAuthorizationV1RequestControl (com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV1RequestControl)3 ProxiedAuthorizationV2RequestControl (com.unboundid.ldap.sdk.controls.ProxiedAuthorizationV2RequestControl)3 ArrayList (java.util.ArrayList)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)3 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)2 ModifyRequest (com.unboundid.ldap.sdk.ModifyRequest)2 ResultCode (com.unboundid.ldap.sdk.ResultCode)2 SubtreeDeleteRequestControl (com.unboundid.ldap.sdk.controls.SubtreeDeleteRequestControl)2 AssuredReplicationLocalLevel (com.unboundid.ldap.sdk.unboundidds.controls.AssuredReplicationLocalLevel)2 AssuredReplicationRemoteLevel (com.unboundid.ldap.sdk.unboundidds.controls.AssuredReplicationRemoteLevel)2 AssuredReplicationRequestControl (com.unboundid.ldap.sdk.unboundidds.controls.AssuredReplicationRequestControl)2 ColumnFormatter (com.unboundid.util.ColumnFormatter)2