|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.unboundid.ldap.sdk.Control
com.unboundid.ldap.sdk.controls.SubtreeDeleteRequestControl
@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class SubtreeDeleteRequestControl
This class provides an implementation of the subtree delete request control
as defined in draft-armijo-ldap-treedelete. This can be used to delete an
entry and all subordinate entries in a single operation.
Normally, if an entry has one or more subordinates, a directory server will
refuse to delete it by rejecting the request with a
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);
Field Summary | |
---|---|
static java.lang.String |
SUBTREE_DELETE_REQUEST_OID
The OID (1.2.840.113556.1.4.805) for the subtree delete request control. |
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
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. |
Methods inherited from class com.unboundid.ldap.sdk.Control |
---|
decode, decode, decodeControls, deregisterDecodeableControl, encode, encodeControls, equals, getOID, getValue, hashCode, hasValue, isCritical, readFrom, registerDecodeableControl, toString, writeTo |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String SUBTREE_DELETE_REQUEST_OID
Constructor Detail |
---|
public SubtreeDeleteRequestControl()
public SubtreeDeleteRequestControl(boolean isCritical)
isCritical
- Indicates whether the control should be marked
critical.public SubtreeDeleteRequestControl(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.Method Detail |
---|
public java.lang.String getControlName()
getControlName
in class Control
public void toString(java.lang.StringBuilder buffer)
toString
in class Control
buffer
- The buffer to which to append the string representation of
this buffer.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |