Package com.unboundid.ldap.sdk
Class DeleteRequest
- java.lang.Object
-
- com.unboundid.ldap.sdk.LDAPRequest
-
- com.unboundid.ldap.sdk.UpdatableLDAPRequest
-
- com.unboundid.ldap.sdk.DeleteRequest
-
- All Implemented Interfaces:
ProtocolOp,ReadOnlyDeleteRequest,ReadOnlyLDAPRequest,java.io.Serializable
@Mutable @ThreadSafety(level=NOT_THREADSAFE) public final class DeleteRequest extends UpdatableLDAPRequest implements ReadOnlyDeleteRequest, ProtocolOp
This class implements the processing necessary to perform an LDAPv3 delete operation, which removes an entry from the directory. A delete request contains the DN of the entry to remove. It may also include a set of controls to send to the server.DeleteRequestobjects are mutable and therefore can be altered and re-used for multiple requests. Note, however, thatDeleteRequestobjects are not threadsafe and therefore a singleDeleteRequestobject instance should not be used to process multiple requests at the same time.
Example
The following example demonstrates the process for performing a delete operation:DeleteRequest deleteRequest = new DeleteRequest("cn=entry to delete,dc=example,dc=com"); LDAPResult deleteResult; try { deleteResult = connection.delete(deleteRequest); // If we get here, the delete was successful. } catch (LDAPException le) { // The delete operation failed. deleteResult = le.toLDAPResult(); ResultCode resultCode = le.getResultCode(); String errorMessageFromServer = le.getDiagnosticMessage(); }- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DeleteRequest(DN dn)Creates a new delete request with the provided DN.DeleteRequest(DN dn, Control[] controls)Creates a new delete request with the provided DN.DeleteRequest(java.lang.String dn)Creates a new delete request with the provided DN.DeleteRequest(java.lang.String dn, Control[] controls)Creates a new delete request with the provided DN.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DeleteRequestduplicate()Creates a new instance of this LDAP request that may be modified without impacting this request.DeleteRequestduplicate(Control[] controls)Creates a new instance of this LDAP request that may be modified without impacting this request.ASN1ElementencodeProtocolOp()Encodes the delete request protocol op to an ASN.1 element.java.lang.StringgetDN()Retrieves the DN of the entry to delete.intgetLastMessageID()Retrieves the message ID for the last LDAP message sent using this request.OperationTypegetOperationType()Retrieves the type of operation that is represented by this request.bytegetProtocolOpType()Retrieves the BER type for this protocol op.protected LDAPResultprocess(LDAPConnection connection, int depth)Sends this delete request to the directory server over the provided connection and returns the associated response.voidresponseReceived(LDAPResponse response)voidsetDN(DN dn)Specifies the DN of the entry to delete.voidsetDN(java.lang.String dn)Specifies the DN of the entry to delete.voidtoCode(java.util.List<java.lang.String> lineList, java.lang.String requestID, int indentSpaces, boolean includeProcessing)Appends a number of lines comprising the Java source code that can be used to recreate this request to the given list.java.lang.String[]toLDIF()Retrieves a string array whose lines contain an LDIF representation of the corresponding delete change record.LDIFDeleteChangeRecordtoLDIFChangeRecord()Retrieves an LDIF delete change record with the contents of this delete request.java.lang.StringtoLDIFString()Retrieves an LDIF string representation of this delete request.voidtoString(java.lang.StringBuilder buffer)Appends a string representation of this request to the provided buffer.voidwriteTo(ASN1Buffer buffer)Writes an ASN.1-encoded representation of this LDAP protocol op to the provided ASN.1 buffer.-
Methods inherited from class com.unboundid.ldap.sdk.UpdatableLDAPRequest
addControl, addControls, clearControls, removeControl, removeControl, replaceControl, replaceControl, setControls, setControls
-
Methods inherited from class com.unboundid.ldap.sdk.LDAPRequest
followReferrals, getControl, getControlList, getControls, getIntermediateResponseListener, getReferralConnector, getResponseTimeoutMillis, hasControl, hasControl, setFollowReferrals, setIntermediateResponseListener, setReferralConnector, setResponseTimeoutMillis, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.unboundid.ldap.sdk.ReadOnlyLDAPRequest
followReferrals, getControl, getControlList, getReferralConnector, getResponseTimeoutMillis, hasControl, hasControl, toString
-
-
-
-
Constructor Detail
-
DeleteRequest
public DeleteRequest(java.lang.String dn)
Creates a new delete request with the provided DN.- Parameters:
dn- The DN of the entry to delete. It must not benull.
-
DeleteRequest
public DeleteRequest(java.lang.String dn, Control[] controls)
Creates a new delete request with the provided DN.- Parameters:
dn- The DN of the entry to delete. It must not benull.controls- The set of controls to include in the request.
-
DeleteRequest
public DeleteRequest(DN dn)
Creates a new delete request with the provided DN.- Parameters:
dn- The DN of the entry to delete. It must not benull.
-
DeleteRequest
public DeleteRequest(DN dn, Control[] controls)
Creates a new delete request with the provided DN.- Parameters:
dn- The DN of the entry to delete. It must not benull.controls- The set of controls to include in the request.
-
-
Method Detail
-
getDN
public java.lang.String getDN()
Retrieves the DN of the entry to delete.- Specified by:
getDNin interfaceReadOnlyDeleteRequest- Returns:
- The DN of the entry to delete.
-
setDN
public void setDN(java.lang.String dn)
Specifies the DN of the entry to delete.- Parameters:
dn- The DN of the entry to delete. It must not benull.
-
setDN
public void setDN(DN dn)
Specifies the DN of the entry to delete.- Parameters:
dn- The DN of the entry to delete. It must not benull.
-
getProtocolOpType
public byte getProtocolOpType()
Retrieves the BER type for this protocol op.- Specified by:
getProtocolOpTypein interfaceProtocolOp- Returns:
- The BER type for this protocol op.
-
writeTo
public void writeTo(ASN1Buffer buffer)
Writes an ASN.1-encoded representation of this LDAP protocol op to the provided ASN.1 buffer. This method is intended for internal use only and should not be used by third-party code.- Specified by:
writeToin interfaceProtocolOp- Parameters:
buffer- The ASN.1 buffer to which the encoded representation should be written.
-
encodeProtocolOp
public ASN1Element encodeProtocolOp()
Encodes the delete request protocol op to an ASN.1 element.- Specified by:
encodeProtocolOpin interfaceProtocolOp- Returns:
- The ASN.1 element with the encoded delete request protocol op.
-
process
protected LDAPResult process(LDAPConnection connection, int depth) throws LDAPException
Sends this delete request to the directory server over the provided connection and returns the associated response.- Specified by:
processin classLDAPRequest- Parameters:
connection- The connection to use to communicate with the directory server.depth- The current referral depth for this request. It should always be one for the initial request, and should only be incremented when following referrals.- Returns:
- An LDAP result object that provides information about the result of the delete processing.
- Throws:
LDAPException- If a problem occurs while sending the request or reading the response.
-
responseReceived
@InternalUseOnly public void responseReceived(LDAPResponse response) throws LDAPException
- Throws:
LDAPException
-
getLastMessageID
public int getLastMessageID()
Retrieves the message ID for the last LDAP message sent using this request.- Specified by:
getLastMessageIDin classLDAPRequest- Returns:
- The message ID for the last LDAP message sent using this request, or -1 if it no LDAP messages have yet been sent using this request.
-
getOperationType
public OperationType getOperationType()
Retrieves the type of operation that is represented by this request.- Specified by:
getOperationTypein classLDAPRequest- Returns:
- The type of operation that is represented by this request.
-
duplicate
public DeleteRequest duplicate()
Creates a new instance of this LDAP request that may be modified without impacting this request.- Specified by:
duplicatein interfaceReadOnlyDeleteRequest- Specified by:
duplicatein interfaceReadOnlyLDAPRequest- Returns:
- A new instance of this LDAP request that may be modified without impacting this request.
-
duplicate
public DeleteRequest duplicate(Control[] controls)
Creates a new instance of this LDAP request that may be modified without impacting this request. The provided controls will be used for the new request instead of duplicating the controls from this request.- Specified by:
duplicatein interfaceReadOnlyDeleteRequest- Specified by:
duplicatein interfaceReadOnlyLDAPRequest- Parameters:
controls- The set of controls to include in the duplicate request.- Returns:
- A new instance of this LDAP request that may be modified without impacting this request.
-
toLDIFChangeRecord
public LDIFDeleteChangeRecord toLDIFChangeRecord()
Retrieves an LDIF delete change record with the contents of this delete request.- Specified by:
toLDIFChangeRecordin interfaceReadOnlyDeleteRequest- Returns:
- An LDIF delete change record with the contents of this delete request.
-
toLDIF
public java.lang.String[] toLDIF()
Retrieves a string array whose lines contain an LDIF representation of the corresponding delete change record.- Specified by:
toLDIFin interfaceReadOnlyDeleteRequest- Returns:
- A string array whose lines contain an LDIF representation of the corresponding delete change record.
-
toLDIFString
public java.lang.String toLDIFString()
Retrieves an LDIF string representation of this delete request.- Specified by:
toLDIFStringin interfaceReadOnlyDeleteRequest- Returns:
- An LDIF string representation of this delete request.
-
toString
public void toString(java.lang.StringBuilder buffer)
Appends a string representation of this request to the provided buffer.- Specified by:
toStringin interfaceProtocolOp- Specified by:
toStringin interfaceReadOnlyLDAPRequest- Specified by:
toStringin classLDAPRequest- Parameters:
buffer- The buffer to which to append a string representation of this request.
-
toCode
public void toCode(java.util.List<java.lang.String> lineList, java.lang.String requestID, int indentSpaces, boolean includeProcessing)
Appends a number of lines comprising the Java source code that can be used to recreate this request to the given list.- Specified by:
toCodein interfaceReadOnlyLDAPRequest- Parameters:
lineList- The list to which the source code lines should be added.requestID- The name that should be used as an identifier for the request. If this isnullor empty, then a generic ID will be used.indentSpaces- The number of spaces that should be used to indent the generated code. It must not be negative.includeProcessing- Indicates whether the generated code should include code required to actually process the request and handle the result (iftrue), or just to generate the request (iffalse).
-
-