@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class SubtreeDeleteRequestControl extends Control
ResultCode.NOT_ALLOWED_ON_NONLEAF
result. In such cases, it is
necessary to first recursively remove all of its subordinates before the
target entry can be deleted. However, this subtree delete request control
can be used to request that the server remove the entry and all subordinates
as a single operation. For servers that support this control, it is
generally much more efficient and convenient than removing all of the
subordinate entries one at a time.
// First, try to delete an entry that has children, but don't include the // subtree delete control. This delete attempt should fail, and the // "NOT_ALLOWED_ON_NONLEAF" result is most appropriate if the failure reason // is that the entry has subordinates. DeleteRequest deleteRequest = new DeleteRequest("ou=entry with children,dc=example,dc=com"); LDAPResult resultWithoutControl; try { resultWithoutControl = connection.delete(deleteRequest); // We shouldn't get here because the delete should fail. } catch (LDAPException le) { // This is expected because the entry has children. resultWithoutControl = le.toLDAPResult(); ResultCode resultCode = le.getResultCode(); String errorMessageFromServer = le.getDiagnosticMessage(); } LDAPTestUtils.assertResultCodeEquals(resultWithoutControl, ResultCode.NOT_ALLOWED_ON_NONLEAF); // Update the delete request to include the subtree delete request control // and try again. deleteRequest.addControl(new SubtreeDeleteRequestControl()); LDAPResult resultWithControl; try { resultWithControl = connection.delete(deleteRequest); // The delete should no longer be rejected just because the target entry // has children. } catch (LDAPException le) { // The delete still failed for some other reason. resultWithControl = le.toLDAPResult(); ResultCode resultCode = le.getResultCode(); String errorMessageFromServer = le.getDiagnosticMessage(); } LDAPTestUtils.assertResultCodeEquals(resultWithControl, ResultCode.SUCCESS);
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
SUBTREE_DELETE_REQUEST_OID
The OID (1.2.840.113556.1.4.805) for the subtree delete request control.
|
Constructor and Description |
---|
SubtreeDeleteRequestControl()
Creates a new subtree delete request control.
|
SubtreeDeleteRequestControl(boolean isCritical)
Creates a new subtree delete request control.
|
SubtreeDeleteRequestControl(Control control)
Creates a new subtree delete request control which is decoded from the
provided generic control.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getControlName()
Retrieves the user-friendly name for this control, if available.
|
void |
toString(java.lang.StringBuilder buffer)
Appends a string representation of this LDAP control to the provided
buffer.
|
decode, decode, decodeControls, deregisterDecodeableControl, encode, encodeControls, equals, getOID, getValue, hashCode, hasValue, isCritical, readFrom, registerDecodeableControl, registerDecodeableControl, toString, writeTo
@NotNull public static final java.lang.String SUBTREE_DELETE_REQUEST_OID
public SubtreeDeleteRequestControl()
public SubtreeDeleteRequestControl(boolean isCritical)
isCritical
- Indicates whether the control should be marked
critical.public SubtreeDeleteRequestControl(@NotNull Control control) throws LDAPException
control
- The generic control to be decoded as a subtree delete
request control.LDAPException
- If the provided control cannot be decoded as a
subtree delete request control.@NotNull public java.lang.String getControlName()
getControlName
in class Control