use of com.unboundid.ldap.sdk.unboundidds.controls.SuppressReferentialIntegrityUpdatesRequestControl 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);
}
}
use of com.unboundid.ldap.sdk.unboundidds.controls.SuppressReferentialIntegrityUpdatesRequestControl in project ldapsdk by pingidentity.
the class MoveSubtree method moveEntryWithInteractiveTransaction.
/**
* <BLOCKQUOTE>
* <B>NOTE:</B> The use of interactive transactions is strongly discouraged
* because it can create conditions which are prone to deadlocks between
* operations that may significantly affect performance and will result in
* the cancellation of one or both operations. Use one of the
* {@code moveSubtreeWithRestrictedAccessibility} methods instead.
* </BLOCKQUOTE>
* Moves a single leaf entry using a pair of interactive transactions. The
* logic used to accomplish this is as follows:
* <OL>
* <LI>Start an interactive transaction in the source server.</LI>
* <LI>Start an interactive transaction in the target server.</LI>
* <LI>Read the entry from the source server. The search request will have
* a subtree scope with a size limit of one, a filter of
* "(objectClass=*)", will request all user and operational attributes,
* and will include the following request controls: interactive
* transaction specification, ManageDsaIT, LDAP subentries, return
* conflict entries, soft-deleted entry access, real attributes only,
* and operation purpose.</LI>
* <LI>Add the entry to the target server. The add request will include the
* following controls: interactive transaction specification, ignore
* NO-USER-MODIFICATION, and operation purpose.</LI>
* <LI>Delete the entry from the source server. The delete request will
* include the following controls: interactive transaction
* specification, ManageDsaIT, and operation purpose.</LI>
* <LI>Commit the interactive transaction in the target server.</LI>
* <LI>Commit the interactive transaction in the source server.</LI>
* </OL>
* Conditions which could result in an incomplete move include:
* <UL>
* <LI>The commit in the target server succeeds but the commit in the
* source server fails. In this case, the entry may end up in both
* servers, requiring manual cleanup. If this occurs, then the result
* returned from this method will indicate this condition.</LI>
* <LI>The account used to read entries from the source server does not have
* permission to see all attributes in all entries. In this case, the
* target server will include only a partial representation of the entry
* in the source server. To avoid this problem, ensure that the account
* used to read from the source server has sufficient access rights to
* see all attributes in the entry to move.</LI>
* <LI>The source server participates in replication and a change occurs to
* the entry in a different server in the replicated environment while
* the move is in progress. In this case, those changes may not be
* reflected in the target server. To avoid this problem, it is
* strongly recommended that all write access in the replication
* environment containing the source server be directed to the source
* server during the time that the move is in progress (e.g., using a
* failover load-balancing algorithm in the Directory Proxy
* Server).</LI>
* </UL>
*
* @param sourceConnection A connection established to the source server.
* It should be authenticated as a user with
* permission to perform all of the operations
* against the source server as referenced above.
* @param targetConnection A connection established to the target server.
* It should be authenticated as a user with
* permission to perform all of the operations
* against the target server as referenced above.
* @param entryDN The base DN for the subtree to move.
* @param opPurposeControl An optional operation purpose request control
* that may be included in all requests sent to the
* source and target servers.
* @param suppressRefInt Indicates whether to include a request control
* causing referential integrity updates to be
* suppressed on the source server.
* @param listener An optional listener that may be invoked during
* the course of moving entries from the source
* server to the target server.
*
* @return An object with information about the result of the attempted
* subtree move.
*
* @deprecated The use of interactive transactions is strongly discouraged
* because it can create conditions which are prone to deadlocks
* between operations that may significantly affect performance
* and will result in the cancellation of one or both operations.
*/
@Deprecated()
@SuppressWarnings("deprecation")
@NotNull()
public static MoveSubtreeResult moveEntryWithInteractiveTransaction(@NotNull final LDAPConnection sourceConnection, @NotNull final LDAPConnection targetConnection, @NotNull final String entryDN, @Nullable final OperationPurposeRequestControl opPurposeControl, final boolean suppressRefInt, @Nullable final MoveSubtreeListener listener) {
final StringBuilder errorMsg = new StringBuilder();
final StringBuilder adminMsg = new StringBuilder();
final ReverseComparator<DN> reverseComparator = new ReverseComparator<>();
final TreeSet<DN> sourceEntryDNs = new TreeSet<>(reverseComparator);
final AtomicInteger entriesReadFromSource = new AtomicInteger(0);
final AtomicInteger entriesAddedToTarget = new AtomicInteger(0);
final AtomicInteger entriesDeletedFromSource = new AtomicInteger(0);
final AtomicReference<ResultCode> resultCode = new AtomicReference<>();
ASN1OctetString sourceTxnID = null;
ASN1OctetString targetTxnID = null;
boolean sourceServerAltered = false;
boolean targetServerAltered = false;
processingBlock: try {
// Start an interactive transaction in the source server.
final com.unboundid.ldap.sdk.unboundidds.controls.InteractiveTransactionSpecificationRequestControl sourceTxnControl;
try {
final com.unboundid.ldap.sdk.unboundidds.extensions.StartInteractiveTransactionExtendedRequest startTxnRequest;
if (opPurposeControl == null) {
startTxnRequest = new com.unboundid.ldap.sdk.unboundidds.extensions.StartInteractiveTransactionExtendedRequest(entryDN);
} else {
startTxnRequest = new com.unboundid.ldap.sdk.unboundidds.extensions.StartInteractiveTransactionExtendedRequest(entryDN, new Control[] { opPurposeControl });
}
final com.unboundid.ldap.sdk.unboundidds.extensions.StartInteractiveTransactionExtendedResult startTxnResult = (com.unboundid.ldap.sdk.unboundidds.extensions.StartInteractiveTransactionExtendedResult) sourceConnection.processExtendedOperation(startTxnRequest);
if (startTxnResult.getResultCode() == ResultCode.SUCCESS) {
sourceTxnID = startTxnResult.getTransactionID();
sourceTxnControl = new com.unboundid.ldap.sdk.unboundidds.controls.InteractiveTransactionSpecificationRequestControl(sourceTxnID, true, true);
} else {
resultCode.compareAndSet(null, startTxnResult.getResultCode());
append(ERR_MOVE_ENTRY_CANNOT_START_SOURCE_TXN.get(startTxnResult.getDiagnosticMessage()), errorMsg);
break processingBlock;
}
} catch (final LDAPException le) {
Debug.debugException(le);
resultCode.compareAndSet(null, le.getResultCode());
append(ERR_MOVE_ENTRY_CANNOT_START_SOURCE_TXN.get(StaticUtils.getExceptionMessage(le)), errorMsg);
break processingBlock;
}
// Start an interactive transaction in the target server.
final com.unboundid.ldap.sdk.unboundidds.controls.InteractiveTransactionSpecificationRequestControl targetTxnControl;
try {
final com.unboundid.ldap.sdk.unboundidds.extensions.StartInteractiveTransactionExtendedRequest startTxnRequest;
if (opPurposeControl == null) {
startTxnRequest = new com.unboundid.ldap.sdk.unboundidds.extensions.StartInteractiveTransactionExtendedRequest(entryDN);
} else {
startTxnRequest = new com.unboundid.ldap.sdk.unboundidds.extensions.StartInteractiveTransactionExtendedRequest(entryDN, new Control[] { opPurposeControl });
}
final com.unboundid.ldap.sdk.unboundidds.extensions.StartInteractiveTransactionExtendedResult startTxnResult = (com.unboundid.ldap.sdk.unboundidds.extensions.StartInteractiveTransactionExtendedResult) targetConnection.processExtendedOperation(startTxnRequest);
if (startTxnResult.getResultCode() == ResultCode.SUCCESS) {
targetTxnID = startTxnResult.getTransactionID();
targetTxnControl = new com.unboundid.ldap.sdk.unboundidds.controls.InteractiveTransactionSpecificationRequestControl(targetTxnID, true, true);
} else {
resultCode.compareAndSet(null, startTxnResult.getResultCode());
append(ERR_MOVE_ENTRY_CANNOT_START_TARGET_TXN.get(startTxnResult.getDiagnosticMessage()), errorMsg);
break processingBlock;
}
} catch (final LDAPException le) {
Debug.debugException(le);
resultCode.compareAndSet(null, le.getResultCode());
append(ERR_MOVE_ENTRY_CANNOT_START_TARGET_TXN.get(StaticUtils.getExceptionMessage(le)), errorMsg);
break processingBlock;
}
// Perform a search to find all entries in the target subtree, and include
// a search listener that will add each entry to the target server as it
// is returned from the source server.
final Control[] searchControls;
if (opPurposeControl == null) {
searchControls = new Control[] { sourceTxnControl, new DraftLDUPSubentriesRequestControl(true), new ManageDsaITRequestControl(true), new ReturnConflictEntriesRequestControl(true), new SoftDeletedEntryAccessRequestControl(true, true, false), new RealAttributesOnlyRequestControl(true) };
} else {
searchControls = new Control[] { sourceTxnControl, new DraftLDUPSubentriesRequestControl(true), new ManageDsaITRequestControl(true), new ReturnConflictEntriesRequestControl(true), new SoftDeletedEntryAccessRequestControl(true, true, false), new RealAttributesOnlyRequestControl(true), opPurposeControl };
}
final MoveSubtreeTxnSearchListener searchListener = new MoveSubtreeTxnSearchListener(targetConnection, resultCode, errorMsg, entriesReadFromSource, entriesAddedToTarget, sourceEntryDNs, targetTxnControl, opPurposeControl, listener);
final SearchRequest searchRequest = new SearchRequest(searchListener, searchControls, entryDN, SearchScope.SUB, DereferencePolicy.NEVER, 1, 0, false, Filter.createPresenceFilter("objectClass"), "*", "+");
SearchResult searchResult;
try {
searchResult = sourceConnection.search(searchRequest);
} catch (final LDAPSearchException lse) {
Debug.debugException(lse);
searchResult = lse.getSearchResult();
}
if (searchResult.getResultCode() == ResultCode.SUCCESS) {
try {
final com.unboundid.ldap.sdk.unboundidds.controls.InteractiveTransactionSpecificationResponseControl txnResult = com.unboundid.ldap.sdk.unboundidds.controls.InteractiveTransactionSpecificationResponseControl.get(searchResult);
if ((txnResult == null) || (!txnResult.transactionValid())) {
resultCode.compareAndSet(null, ResultCode.LOCAL_ERROR);
append(ERR_MOVE_ENTRY_SEARCH_TXN_NO_LONGER_VALID.get(), errorMsg);
break processingBlock;
}
} catch (final LDAPException le) {
Debug.debugException(le);
resultCode.compareAndSet(null, le.getResultCode());
append(ERR_MOVE_ENTRY_CANNOT_DECODE_SEARCH_TXN_CONTROL.get(StaticUtils.getExceptionMessage(le)), errorMsg);
break processingBlock;
}
} else {
resultCode.compareAndSet(null, searchResult.getResultCode());
append(ERR_MOVE_SUBTREE_SEARCH_FAILED.get(entryDN, searchResult.getDiagnosticMessage()), errorMsg);
try {
final com.unboundid.ldap.sdk.unboundidds.controls.InteractiveTransactionSpecificationResponseControl txnResult = com.unboundid.ldap.sdk.unboundidds.controls.InteractiveTransactionSpecificationResponseControl.get(searchResult);
if ((txnResult != null) && (!txnResult.transactionValid())) {
sourceTxnID = null;
}
} catch (final LDAPException le) {
Debug.debugException(le);
}
if (!searchListener.targetTransactionValid()) {
targetTxnID = null;
}
break processingBlock;
}
// If an error occurred during add processing, then fail.
if (resultCode.get() == null) {
targetServerAltered = true;
} else {
break processingBlock;
}
// Delete each of the entries in the source server. The map should
// already be sorted in reverse order (as a result of the comparator used
// when creating it), so it will guarantee children are deleted before
// their parents.
final ArrayList<Control> deleteControlList = new ArrayList<>(4);
deleteControlList.add(sourceTxnControl);
deleteControlList.add(new ManageDsaITRequestControl(true));
if (opPurposeControl != null) {
deleteControlList.add(opPurposeControl);
}
if (suppressRefInt) {
deleteControlList.add(new SuppressReferentialIntegrityUpdatesRequestControl(false));
}
final Control[] deleteControls = new Control[deleteControlList.size()];
deleteControlList.toArray(deleteControls);
for (final DN dn : sourceEntryDNs) {
if (listener != null) {
try {
listener.doPreDeleteProcessing(dn);
} catch (final Exception e) {
Debug.debugException(e);
resultCode.compareAndSet(null, ResultCode.LOCAL_ERROR);
append(ERR_MOVE_SUBTREE_PRE_DELETE_FAILURE.get(dn.toString(), StaticUtils.getExceptionMessage(e)), errorMsg);
break processingBlock;
}
}
LDAPResult deleteResult;
try {
deleteResult = sourceConnection.delete(new DeleteRequest(dn, deleteControls));
} catch (final LDAPException le) {
Debug.debugException(le);
deleteResult = le.toLDAPResult();
}
if (deleteResult.getResultCode() == ResultCode.SUCCESS) {
sourceServerAltered = true;
entriesDeletedFromSource.incrementAndGet();
try {
final com.unboundid.ldap.sdk.unboundidds.controls.InteractiveTransactionSpecificationResponseControl txnResult = com.unboundid.ldap.sdk.unboundidds.controls.InteractiveTransactionSpecificationResponseControl.get(deleteResult);
if ((txnResult == null) || (!txnResult.transactionValid())) {
resultCode.compareAndSet(null, ResultCode.LOCAL_ERROR);
append(ERR_MOVE_ENTRY_DELETE_TXN_NO_LONGER_VALID.get(dn.toString()), errorMsg);
break processingBlock;
}
} catch (final LDAPException le) {
Debug.debugException(le);
resultCode.compareAndSet(null, le.getResultCode());
append(ERR_MOVE_ENTRY_CANNOT_DECODE_DELETE_TXN_CONTROL.get(dn.toString(), StaticUtils.getExceptionMessage(le)), errorMsg);
break processingBlock;
}
} else {
resultCode.compareAndSet(null, deleteResult.getResultCode());
append(ERR_MOVE_SUBTREE_DELETE_FAILURE.get(dn.toString(), deleteResult.getDiagnosticMessage()), errorMsg);
try {
final com.unboundid.ldap.sdk.unboundidds.controls.InteractiveTransactionSpecificationResponseControl txnResult = com.unboundid.ldap.sdk.unboundidds.controls.InteractiveTransactionSpecificationResponseControl.get(deleteResult);
if ((txnResult != null) && (!txnResult.transactionValid())) {
sourceTxnID = null;
}
} catch (final LDAPException le) {
Debug.debugException(le);
}
break processingBlock;
}
if (listener != null) {
try {
listener.doPostDeleteProcessing(dn);
} catch (final Exception e) {
Debug.debugException(e);
resultCode.compareAndSet(null, ResultCode.LOCAL_ERROR);
append(ERR_MOVE_SUBTREE_POST_DELETE_FAILURE.get(dn.toString(), StaticUtils.getExceptionMessage(e)), errorMsg);
break processingBlock;
}
}
}
// Commit the transaction in the target server.
try {
final com.unboundid.ldap.sdk.unboundidds.extensions.EndInteractiveTransactionExtendedRequest commitRequest;
if (opPurposeControl == null) {
commitRequest = new com.unboundid.ldap.sdk.unboundidds.extensions.EndInteractiveTransactionExtendedRequest(targetTxnID, true);
} else {
commitRequest = new com.unboundid.ldap.sdk.unboundidds.extensions.EndInteractiveTransactionExtendedRequest(targetTxnID, true, new Control[] { opPurposeControl });
}
final ExtendedResult commitResult = targetConnection.processExtendedOperation(commitRequest);
if (commitResult.getResultCode() == ResultCode.SUCCESS) {
targetTxnID = null;
} else {
resultCode.compareAndSet(null, commitResult.getResultCode());
append(ERR_MOVE_ENTRY_CANNOT_COMMIT_TARGET_TXN.get(commitResult.getDiagnosticMessage()), errorMsg);
break processingBlock;
}
} catch (final LDAPException le) {
Debug.debugException(le);
resultCode.compareAndSet(null, le.getResultCode());
append(ERR_MOVE_ENTRY_CANNOT_COMMIT_TARGET_TXN.get(StaticUtils.getExceptionMessage(le)), errorMsg);
break processingBlock;
}
// Commit the transaction in the source server.
try {
final com.unboundid.ldap.sdk.unboundidds.extensions.EndInteractiveTransactionExtendedRequest commitRequest;
if (opPurposeControl == null) {
commitRequest = new com.unboundid.ldap.sdk.unboundidds.extensions.EndInteractiveTransactionExtendedRequest(sourceTxnID, true);
} else {
commitRequest = new com.unboundid.ldap.sdk.unboundidds.extensions.EndInteractiveTransactionExtendedRequest(sourceTxnID, true, new Control[] { opPurposeControl });
}
final ExtendedResult commitResult = sourceConnection.processExtendedOperation(commitRequest);
if (commitResult.getResultCode() == ResultCode.SUCCESS) {
sourceTxnID = null;
} else {
resultCode.compareAndSet(null, commitResult.getResultCode());
append(ERR_MOVE_ENTRY_CANNOT_COMMIT_SOURCE_TXN.get(commitResult.getDiagnosticMessage()), errorMsg);
break processingBlock;
}
} catch (final LDAPException le) {
Debug.debugException(le);
resultCode.compareAndSet(null, le.getResultCode());
append(ERR_MOVE_ENTRY_CANNOT_COMMIT_SOURCE_TXN.get(StaticUtils.getExceptionMessage(le)), errorMsg);
append(ERR_MOVE_ENTRY_EXISTS_IN_BOTH_SERVERS.get(entryDN), adminMsg);
break processingBlock;
}
} finally {
// If the transaction is still active in the target server, then abort it.
if (targetTxnID != null) {
try {
final com.unboundid.ldap.sdk.unboundidds.extensions.EndInteractiveTransactionExtendedRequest abortRequest;
if (opPurposeControl == null) {
abortRequest = new com.unboundid.ldap.sdk.unboundidds.extensions.EndInteractiveTransactionExtendedRequest(targetTxnID, false);
} else {
abortRequest = new com.unboundid.ldap.sdk.unboundidds.extensions.EndInteractiveTransactionExtendedRequest(targetTxnID, false, new Control[] { opPurposeControl });
}
final ExtendedResult abortResult = targetConnection.processExtendedOperation(abortRequest);
if (abortResult.getResultCode() == ResultCode.INTERACTIVE_TRANSACTION_ABORTED) {
targetServerAltered = false;
entriesAddedToTarget.set(0);
append(INFO_MOVE_ENTRY_TARGET_ABORT_SUCCEEDED.get(), errorMsg);
} else {
append(ERR_MOVE_ENTRY_TARGET_ABORT_FAILURE.get(abortResult.getDiagnosticMessage()), errorMsg);
append(ERR_MOVE_ENTRY_TARGET_ABORT_FAILURE_ADMIN_ACTION.get(entryDN), adminMsg);
}
} catch (final Exception e) {
Debug.debugException(e);
append(ERR_MOVE_ENTRY_TARGET_ABORT_FAILURE.get(StaticUtils.getExceptionMessage(e)), errorMsg);
append(ERR_MOVE_ENTRY_TARGET_ABORT_FAILURE_ADMIN_ACTION.get(entryDN), adminMsg);
}
}
// If the transaction is still active in the source server, then abort it.
if (sourceTxnID != null) {
try {
final com.unboundid.ldap.sdk.unboundidds.extensions.EndInteractiveTransactionExtendedRequest abortRequest;
if (opPurposeControl == null) {
abortRequest = new com.unboundid.ldap.sdk.unboundidds.extensions.EndInteractiveTransactionExtendedRequest(sourceTxnID, false);
} else {
abortRequest = new com.unboundid.ldap.sdk.unboundidds.extensions.EndInteractiveTransactionExtendedRequest(sourceTxnID, false, new Control[] { opPurposeControl });
}
final ExtendedResult abortResult = sourceConnection.processExtendedOperation(abortRequest);
if (abortResult.getResultCode() == ResultCode.INTERACTIVE_TRANSACTION_ABORTED) {
sourceServerAltered = false;
entriesDeletedFromSource.set(0);
append(INFO_MOVE_ENTRY_SOURCE_ABORT_SUCCEEDED.get(), errorMsg);
} else {
append(ERR_MOVE_ENTRY_SOURCE_ABORT_FAILURE.get(abortResult.getDiagnosticMessage()), errorMsg);
append(ERR_MOVE_ENTRY_SOURCE_ABORT_FAILURE_ADMIN_ACTION.get(entryDN), adminMsg);
}
} catch (final Exception e) {
Debug.debugException(e);
append(ERR_MOVE_ENTRY_SOURCE_ABORT_FAILURE.get(StaticUtils.getExceptionMessage(e)), errorMsg);
append(ERR_MOVE_ENTRY_SOURCE_ABORT_FAILURE_ADMIN_ACTION.get(entryDN), adminMsg);
}
}
}
// Construct the result to return to the client.
resultCode.compareAndSet(null, ResultCode.SUCCESS);
final String errorMessage;
if (errorMsg.length() > 0) {
errorMessage = errorMsg.toString();
} else {
errorMessage = null;
}
final String adminActionRequired;
if (adminMsg.length() > 0) {
adminActionRequired = adminMsg.toString();
} else {
adminActionRequired = null;
}
return new MoveSubtreeResult(resultCode.get(), errorMessage, adminActionRequired, sourceServerAltered, targetServerAltered, entriesReadFromSource.get(), entriesAddedToTarget.get(), entriesDeletedFromSource.get());
}
use of com.unboundid.ldap.sdk.unboundidds.controls.SuppressReferentialIntegrityUpdatesRequestControl in project ldapsdk by pingidentity.
the class MoveSubtree method deleteEntries.
/**
* Deletes a specified set of entries from the indicated server.
*
* @param connection The connection to use to communicate with the
* server.
* @param isSource Indicates whether the connection is to the source
* or target server.
* @param entryDNs The set of DNs of the entries to be deleted.
* @param opPurposeControl An optional operation purpose request control
* that may be included in the requests.
* @param suppressRefInt Indicates whether to include a request control
* causing referential integrity updates to be
* suppressed on the source server.
* @param listener An optional listener that may be invoked during
* the course of moving entries from the source
* server to the target server.
* @param deleteCount A counter to increment for each delete operation
* processed.
* @param resultCode A reference to the result code to use for the
* move subtree operation.
* @param errorMsg A buffer to which any appropriate error messages
* may be appended.
*
* @return {@code true} if the delete was completely successful, or
* {@code false} if any errors were encountered.
*/
private static boolean deleteEntries(@NotNull final LDAPConnection connection, final boolean isSource, @NotNull final TreeSet<DN> entryDNs, @Nullable final OperationPurposeRequestControl opPurposeControl, final boolean suppressRefInt, @Nullable final MoveSubtreeListener listener, @NotNull final AtomicInteger deleteCount, @NotNull final AtomicReference<ResultCode> resultCode, @NotNull final StringBuilder errorMsg) {
final ArrayList<Control> deleteControlList = new ArrayList<>(3);
deleteControlList.add(new ManageDsaITRequestControl(true));
if (opPurposeControl != null) {
deleteControlList.add(opPurposeControl);
}
if (suppressRefInt) {
deleteControlList.add(new SuppressReferentialIntegrityUpdatesRequestControl(false));
}
final Control[] deleteControls = new Control[deleteControlList.size()];
deleteControlList.toArray(deleteControls);
boolean successful = true;
for (final DN dn : entryDNs) {
if (isSource && (listener != null)) {
try {
listener.doPreDeleteProcessing(dn);
} catch (final Exception e) {
Debug.debugException(e);
resultCode.compareAndSet(null, ResultCode.LOCAL_ERROR);
append(ERR_MOVE_SUBTREE_PRE_DELETE_FAILURE.get(dn.toString(), StaticUtils.getExceptionMessage(e)), errorMsg);
successful = false;
continue;
}
}
LDAPResult deleteResult;
try {
deleteResult = connection.delete(new DeleteRequest(dn, deleteControls));
} catch (final LDAPException le) {
Debug.debugException(le);
deleteResult = le.toLDAPResult();
}
if (deleteResult.getResultCode() == ResultCode.SUCCESS) {
deleteCount.incrementAndGet();
} else {
resultCode.compareAndSet(null, deleteResult.getResultCode());
append(ERR_MOVE_SUBTREE_DELETE_FAILURE.get(dn.toString(), deleteResult.getDiagnosticMessage()), errorMsg);
successful = false;
continue;
}
if (isSource && (listener != null)) {
try {
listener.doPostDeleteProcessing(dn);
} catch (final Exception e) {
Debug.debugException(e);
resultCode.compareAndSet(null, ResultCode.LOCAL_ERROR);
append(ERR_MOVE_SUBTREE_POST_DELETE_FAILURE.get(dn.toString(), StaticUtils.getExceptionMessage(e)), errorMsg);
successful = false;
}
}
}
return successful;
}
use of com.unboundid.ldap.sdk.unboundidds.controls.SuppressReferentialIntegrityUpdatesRequestControl in project ldapsdk by pingidentity.
the class LDAPDelete method getDeleteControls.
/**
* Retrieves the set of controls that should be included in delete requests.
*
* @return The set of controls that should be included in delete requests.
*/
@NotNull()
private List<Control> getDeleteControls() {
final List<Control> controlList = new ArrayList<>(10);
if (deleteControl.isPresent()) {
controlList.addAll(deleteControl.getValues());
}
controlList.addAll(routeToBackendSetRequestControls);
if (serverSideSubtreeDelete.isPresent()) {
controlList.add(new SubtreeDeleteRequestControl(true));
}
if (softDelete.isPresent()) {
controlList.add(new SoftDeleteRequestControl(true, true));
}
if (hardDelete.isPresent() && (!clientSideSubtreeDelete.isPresent())) {
controlList.add(new HardDeleteRequestControl(true));
}
if (proxyAs.isPresent()) {
controlList.add(new ProxiedAuthorizationV2RequestControl(proxyAs.getValue()));
}
if (proxyV1As.isPresent()) {
controlList.add(new ProxiedAuthorizationV1RequestControl(proxyV1As.getValue().toString()));
}
if (manageDsaIT.isPresent() && (!clientSideSubtreeDelete.isPresent())) {
controlList.add(new ManageDsaITRequestControl(true));
}
if (assertionFilter.isPresent()) {
controlList.add(new AssertionRequestControl(assertionFilter.getValue(), true));
}
if (preReadAttribute.isPresent()) {
controlList.add(new PreReadRequestControl(true, preReadAttribute.getValues().toArray(StaticUtils.NO_STRINGS)));
}
if (noOperation.isPresent()) {
controlList.add(new NoOpRequestControl());
}
if (getBackendSetID.isPresent()) {
controlList.add(new GetBackendSetIDRequestControl(true));
}
if (getServerID.isPresent()) {
controlList.add(new GetServerIDRequestControl(true));
}
if (routeToServer.isPresent()) {
controlList.add(new RouteToServerRequestControl(true, routeToServer.getValue(), false, false, false));
}
if (useAssuredReplication.isPresent()) {
AssuredReplicationLocalLevel localLevel = null;
if (assuredReplicationLocalLevel.isPresent()) {
final String level = assuredReplicationLocalLevel.getValue();
if (level.equalsIgnoreCase("none")) {
localLevel = AssuredReplicationLocalLevel.NONE;
} else if (level.equalsIgnoreCase("received-any-server")) {
localLevel = AssuredReplicationLocalLevel.RECEIVED_ANY_SERVER;
} else if (level.equalsIgnoreCase("processed-all-servers")) {
localLevel = AssuredReplicationLocalLevel.PROCESSED_ALL_SERVERS;
}
}
AssuredReplicationRemoteLevel remoteLevel = null;
if (assuredReplicationRemoteLevel.isPresent()) {
final String level = assuredReplicationRemoteLevel.getValue();
if (level.equalsIgnoreCase("none")) {
remoteLevel = AssuredReplicationRemoteLevel.NONE;
} else if (level.equalsIgnoreCase("received-any-remote-location")) {
remoteLevel = AssuredReplicationRemoteLevel.RECEIVED_ANY_REMOTE_LOCATION;
} else if (level.equalsIgnoreCase("received-all-remote-locations")) {
remoteLevel = AssuredReplicationRemoteLevel.RECEIVED_ALL_REMOTE_LOCATIONS;
} else if (level.equalsIgnoreCase("processed-all-remote-servers")) {
remoteLevel = AssuredReplicationRemoteLevel.PROCESSED_ALL_REMOTE_SERVERS;
}
}
Long timeoutMillis = null;
if (assuredReplicationTimeout.isPresent()) {
timeoutMillis = assuredReplicationTimeout.getValue(TimeUnit.MILLISECONDS);
}
final AssuredReplicationRequestControl c = new AssuredReplicationRequestControl(true, localLevel, localLevel, remoteLevel, remoteLevel, timeoutMillis, false);
controlList.add(c);
}
if (replicationRepair.isPresent()) {
controlList.add(new ReplicationRepairRequestControl());
}
if (suppressReferentialIntegrityUpdates.isPresent()) {
controlList.add(new SuppressReferentialIntegrityUpdatesRequestControl(true));
}
if (operationPurpose.isPresent()) {
controlList.add(new OperationPurposeRequestControl(true, "ldapdelete", Version.NUMERIC_VERSION_STRING, LDAPDelete.class.getName() + ".getDeleteControls", operationPurpose.getValue()));
}
return Collections.unmodifiableList(controlList);
}
use of com.unboundid.ldap.sdk.unboundidds.controls.SuppressReferentialIntegrityUpdatesRequestControl in project ldapsdk by pingidentity.
the class LDAPModify method createRequestControls.
/**
* Populates lists of request controls that should be included in requests
* of various types.
*
* @param addControls The list of controls to include in add requests.
* @param deleteControls The list of controls to include in delete
* requests.
* @param modifyControls The list of controls to include in modify
* requests.
* @param modifyDNControls The list of controls to include in modify DN
* requests.
* @param searchControls The list of controls to include in search
* requests.
*
* @throws LDAPException If a problem is encountered while creating any of
* the requested controls.
*/
private void createRequestControls(@NotNull final List<Control> addControls, @NotNull final List<Control> deleteControls, @NotNull final List<Control> modifyControls, @NotNull final List<Control> modifyDNControls, @NotNull final List<Control> searchControls) throws LDAPException {
if (addControl.isPresent()) {
addControls.addAll(addControl.getValues());
}
if (deleteControl.isPresent()) {
deleteControls.addAll(deleteControl.getValues());
}
if (modifyControl.isPresent()) {
modifyControls.addAll(modifyControl.getValues());
}
if (modifyDNControl.isPresent()) {
modifyDNControls.addAll(modifyDNControl.getValues());
}
if (operationControl.isPresent()) {
addControls.addAll(operationControl.getValues());
deleteControls.addAll(operationControl.getValues());
modifyControls.addAll(operationControl.getValues());
modifyDNControls.addAll(operationControl.getValues());
}
addControls.addAll(routeToBackendSetRequestControls);
deleteControls.addAll(routeToBackendSetRequestControls);
modifyControls.addAll(routeToBackendSetRequestControls);
modifyDNControls.addAll(routeToBackendSetRequestControls);
if (noOperation.isPresent()) {
final NoOpRequestControl c = new NoOpRequestControl();
addControls.add(c);
deleteControls.add(c);
modifyControls.add(c);
modifyDNControls.add(c);
}
if (generatePassword.isPresent()) {
addControls.add(new GeneratePasswordRequestControl());
}
if (getBackendSetID.isPresent()) {
final GetBackendSetIDRequestControl c = new GetBackendSetIDRequestControl(false);
addControls.add(c);
deleteControls.add(c);
modifyControls.add(c);
modifyDNControls.add(c);
}
if (getServerID.isPresent()) {
final GetServerIDRequestControl c = new GetServerIDRequestControl(false);
addControls.add(c);
deleteControls.add(c);
modifyControls.add(c);
modifyDNControls.add(c);
}
if (ignoreNoUserModification.isPresent()) {
addControls.add(new IgnoreNoUserModificationRequestControl(false));
modifyControls.add(new IgnoreNoUserModificationRequestControl(false));
}
if (nameWithEntryUUID.isPresent()) {
addControls.add(new NameWithEntryUUIDRequestControl(true));
}
if (permissiveModify.isPresent()) {
modifyControls.add(new PermissiveModifyRequestControl(false));
}
if (routeToServer.isPresent()) {
final RouteToServerRequestControl c = new RouteToServerRequestControl(false, routeToServer.getValue(), false, false, false);
addControls.add(c);
deleteControls.add(c);
modifyControls.add(c);
modifyDNControls.add(c);
}
if (suppressReferentialIntegrityUpdates.isPresent()) {
final SuppressReferentialIntegrityUpdatesRequestControl c = new SuppressReferentialIntegrityUpdatesRequestControl(true);
deleteControls.add(c);
modifyDNControls.add(c);
}
if (suppressOperationalAttributeUpdates.isPresent()) {
final EnumSet<SuppressType> suppressTypes = EnumSet.noneOf(SuppressType.class);
for (final String s : suppressOperationalAttributeUpdates.getValues()) {
if (s.equalsIgnoreCase("last-access-time")) {
suppressTypes.add(SuppressType.LAST_ACCESS_TIME);
} else if (s.equalsIgnoreCase("last-login-time")) {
suppressTypes.add(SuppressType.LAST_LOGIN_TIME);
} else if (s.equalsIgnoreCase("last-login-ip")) {
suppressTypes.add(SuppressType.LAST_LOGIN_IP);
} else if (s.equalsIgnoreCase("lastmod")) {
suppressTypes.add(SuppressType.LASTMOD);
}
}
final SuppressOperationalAttributeUpdateRequestControl c = new SuppressOperationalAttributeUpdateRequestControl(suppressTypes);
addControls.add(c);
deleteControls.add(c);
modifyControls.add(c);
modifyDNControls.add(c);
}
if (usePasswordPolicyControl.isPresent()) {
final PasswordPolicyRequestControl c = new PasswordPolicyRequestControl();
addControls.add(c);
modifyControls.add(c);
}
if (assuredReplication.isPresent()) {
AssuredReplicationLocalLevel localLevel = null;
if (assuredReplicationLocalLevel.isPresent()) {
final String level = assuredReplicationLocalLevel.getValue();
if (level.equalsIgnoreCase("none")) {
localLevel = AssuredReplicationLocalLevel.NONE;
} else if (level.equalsIgnoreCase("received-any-server")) {
localLevel = AssuredReplicationLocalLevel.RECEIVED_ANY_SERVER;
} else if (level.equalsIgnoreCase("processed-all-servers")) {
localLevel = AssuredReplicationLocalLevel.PROCESSED_ALL_SERVERS;
}
}
AssuredReplicationRemoteLevel remoteLevel = null;
if (assuredReplicationRemoteLevel.isPresent()) {
final String level = assuredReplicationRemoteLevel.getValue();
if (level.equalsIgnoreCase("none")) {
remoteLevel = AssuredReplicationRemoteLevel.NONE;
} else if (level.equalsIgnoreCase("received-any-remote-location")) {
remoteLevel = AssuredReplicationRemoteLevel.RECEIVED_ANY_REMOTE_LOCATION;
} else if (level.equalsIgnoreCase("received-all-remote-locations")) {
remoteLevel = AssuredReplicationRemoteLevel.RECEIVED_ALL_REMOTE_LOCATIONS;
} else if (level.equalsIgnoreCase("processed-all-remote-servers")) {
remoteLevel = AssuredReplicationRemoteLevel.PROCESSED_ALL_REMOTE_SERVERS;
}
}
Long timeoutMillis = null;
if (assuredReplicationTimeout.isPresent()) {
timeoutMillis = assuredReplicationTimeout.getValue(TimeUnit.MILLISECONDS);
}
final AssuredReplicationRequestControl c = new AssuredReplicationRequestControl(true, localLevel, localLevel, remoteLevel, remoteLevel, timeoutMillis, false);
addControls.add(c);
deleteControls.add(c);
modifyControls.add(c);
modifyDNControls.add(c);
}
if (hardDelete.isPresent() && (!clientSideSubtreeDelete.isPresent())) {
deleteControls.add(new HardDeleteRequestControl(true));
}
if (replicationRepair.isPresent()) {
final ReplicationRepairRequestControl c = new ReplicationRepairRequestControl();
addControls.add(c);
deleteControls.add(c);
modifyControls.add(c);
modifyDNControls.add(c);
}
if (softDelete.isPresent()) {
deleteControls.add(new SoftDeleteRequestControl(true, true));
}
if (serverSideSubtreeDelete.isPresent()) {
deleteControls.add(new SubtreeDeleteRequestControl());
}
if (assertionFilter.isPresent()) {
final AssertionRequestControl c = new AssertionRequestControl(assertionFilter.getValue(), true);
addControls.add(c);
deleteControls.add(c);
modifyControls.add(c);
modifyDNControls.add(c);
}
if (operationPurpose.isPresent()) {
final OperationPurposeRequestControl c = new OperationPurposeRequestControl(false, "ldapmodify", Version.NUMERIC_VERSION_STRING, LDAPModify.class.getName() + ".createRequestControls", operationPurpose.getValue());
addControls.add(c);
deleteControls.add(c);
modifyControls.add(c);
modifyDNControls.add(c);
}
if (manageDsaIT.isPresent()) {
final ManageDsaITRequestControl c = new ManageDsaITRequestControl(true);
addControls.add(c);
if (!clientSideSubtreeDelete.isPresent()) {
deleteControls.add(c);
}
modifyControls.add(c);
modifyDNControls.add(c);
}
if (passwordUpdateBehavior.isPresent()) {
final PasswordUpdateBehaviorRequestControl c = createPasswordUpdateBehaviorRequestControl(passwordUpdateBehavior.getIdentifierString(), passwordUpdateBehavior.getValues());
addControls.add(c);
modifyControls.add(c);
}
if (preReadAttribute.isPresent()) {
final ArrayList<String> attrList = new ArrayList<>(10);
for (final String value : preReadAttribute.getValues()) {
final StringTokenizer tokenizer = new StringTokenizer(value, ", ");
while (tokenizer.hasMoreTokens()) {
attrList.add(tokenizer.nextToken());
}
}
final String[] attrArray = attrList.toArray(StaticUtils.NO_STRINGS);
final PreReadRequestControl c = new PreReadRequestControl(attrArray);
deleteControls.add(c);
modifyControls.add(c);
modifyDNControls.add(c);
}
if (postReadAttribute.isPresent()) {
final ArrayList<String> attrList = new ArrayList<>(10);
for (final String value : postReadAttribute.getValues()) {
final StringTokenizer tokenizer = new StringTokenizer(value, ", ");
while (tokenizer.hasMoreTokens()) {
attrList.add(tokenizer.nextToken());
}
}
final String[] attrArray = attrList.toArray(StaticUtils.NO_STRINGS);
final PostReadRequestControl c = new PostReadRequestControl(attrArray);
addControls.add(c);
modifyControls.add(c);
modifyDNControls.add(c);
}
if (proxyAs.isPresent() && (!useTransaction.isPresent()) && (!multiUpdateErrorBehavior.isPresent())) {
final ProxiedAuthorizationV2RequestControl c = new ProxiedAuthorizationV2RequestControl(proxyAs.getValue());
addControls.add(c);
deleteControls.add(c);
modifyControls.add(c);
modifyDNControls.add(c);
searchControls.add(c);
}
if (proxyV1As.isPresent() && (!useTransaction.isPresent()) && (!multiUpdateErrorBehavior.isPresent())) {
final ProxiedAuthorizationV1RequestControl c = new ProxiedAuthorizationV1RequestControl(proxyV1As.getValue());
addControls.add(c);
deleteControls.add(c);
modifyControls.add(c);
modifyDNControls.add(c);
searchControls.add(c);
}
if (uniquenessAttribute.isPresent() || uniquenessFilter.isPresent()) {
final UniquenessRequestControlProperties uniquenessProperties;
if (uniquenessAttribute.isPresent()) {
uniquenessProperties = new UniquenessRequestControlProperties(uniquenessAttribute.getValues());
if (uniquenessFilter.isPresent()) {
uniquenessProperties.setFilter(uniquenessFilter.getValue());
}
} else {
uniquenessProperties = new UniquenessRequestControlProperties(uniquenessFilter.getValue());
}
if (uniquenessBaseDN.isPresent()) {
uniquenessProperties.setBaseDN(uniquenessBaseDN.getStringValue());
}
if (uniquenessMultipleAttributeBehavior.isPresent()) {
final String value = uniquenessMultipleAttributeBehavior.getValue().toLowerCase();
switch(value) {
case "unique-within-each-attribute":
uniquenessProperties.setMultipleAttributeBehavior(UniquenessMultipleAttributeBehavior.UNIQUE_WITHIN_EACH_ATTRIBUTE);
break;
case "unique-across-all-attributes-including-in-same-entry":
uniquenessProperties.setMultipleAttributeBehavior(UniquenessMultipleAttributeBehavior.UNIQUE_ACROSS_ALL_ATTRIBUTES_INCLUDING_IN_SAME_ENTRY);
break;
case "unique-across-all-attributes-except-in-same-entry":
uniquenessProperties.setMultipleAttributeBehavior(UniquenessMultipleAttributeBehavior.UNIQUE_ACROSS_ALL_ATTRIBUTES_EXCEPT_IN_SAME_ENTRY);
break;
case "unique-in-combination":
uniquenessProperties.setMultipleAttributeBehavior(UniquenessMultipleAttributeBehavior.UNIQUE_IN_COMBINATION);
break;
}
}
if (uniquenessPreCommitValidationLevel.isPresent()) {
final String value = uniquenessPreCommitValidationLevel.getValue().toLowerCase();
switch(value) {
case "none":
uniquenessProperties.setPreCommitValidationLevel(UniquenessValidationLevel.NONE);
break;
case "all-subtree-views":
uniquenessProperties.setPreCommitValidationLevel(UniquenessValidationLevel.ALL_SUBTREE_VIEWS);
break;
case "all-backend-sets":
uniquenessProperties.setPreCommitValidationLevel(UniquenessValidationLevel.ALL_BACKEND_SETS);
break;
case "all-available-backend-servers":
uniquenessProperties.setPreCommitValidationLevel(UniquenessValidationLevel.ALL_AVAILABLE_BACKEND_SERVERS);
break;
}
}
if (uniquenessPostCommitValidationLevel.isPresent()) {
final String value = uniquenessPostCommitValidationLevel.getValue().toLowerCase();
switch(value) {
case "none":
uniquenessProperties.setPostCommitValidationLevel(UniquenessValidationLevel.NONE);
break;
case "all-subtree-views":
uniquenessProperties.setPostCommitValidationLevel(UniquenessValidationLevel.ALL_SUBTREE_VIEWS);
break;
case "all-backend-sets":
uniquenessProperties.setPostCommitValidationLevel(UniquenessValidationLevel.ALL_BACKEND_SETS);
break;
case "all-available-backend-servers":
uniquenessProperties.setPostCommitValidationLevel(UniquenessValidationLevel.ALL_AVAILABLE_BACKEND_SERVERS);
break;
}
}
final UniquenessRequestControl c = new UniquenessRequestControl(true, null, uniquenessProperties);
addControls.add(c);
modifyControls.add(c);
modifyDNControls.add(c);
}
}
Aggregations