Package com.unboundid.ldap.sdk
Class ModifyDNRequest
- java.lang.Object
-
- com.unboundid.ldap.sdk.LDAPRequest
-
- com.unboundid.ldap.sdk.UpdatableLDAPRequest
-
- com.unboundid.ldap.sdk.ModifyDNRequest
-
- All Implemented Interfaces:
ProtocolOp,ReadOnlyLDAPRequest,ReadOnlyModifyDNRequest,java.io.Serializable
@Mutable @ThreadSafety(level=NOT_THREADSAFE) public final class ModifyDNRequest extends UpdatableLDAPRequest implements ReadOnlyModifyDNRequest, ProtocolOp
This class implements the processing necessary to perform an LDAPv3 modify DN operation, which can be used to rename and/or move an entry or subtree in the directory. A modify DN request contains the DN of the target entry, the new RDN to use for that entry, and a flag which indicates whether to remove the current RDN attribute value(s) from the entry. It may optionally contain a new superior DN, which will cause the entry to be moved below that new parent entry.
Note that some directory servers may not support all possible uses of the modify DN operation. In particular, some servers may not support the use of a new superior DN, especially if it may cause the entry to be moved to a different database or another server. Also, some servers may not support renaming or moving non-leaf entries (i.e., entries that have one or more subordinates).
ModifyDNRequestobjects are mutable and therefore can be altered and re-used for multiple requests. Note, however, thatModifyDNRequestobjects are not threadsafe and therefore a singleModifyDNRequestobject instance should not be used to process multiple requests at the same time.
Example
The following example demonstrates the process for performing a modify DN operation. In this case, it will rename "ou=People,dc=example,dc=com" to "ou=Users,dc=example,dc=com". It will not move the entry below a new parent.ModifyDNRequest modifyDNRequest = new ModifyDNRequest("ou=People,dc=example,dc=com", "ou=Users", true); LDAPResult modifyDNResult; try { modifyDNResult = connection.modifyDN(modifyDNRequest); // If we get here, the delete was successful. } catch (LDAPException le) { // The modify DN operation failed. modifyDNResult = le.toLDAPResult(); ResultCode resultCode = le.getResultCode(); String errorMessageFromServer = le.getDiagnosticMessage(); }- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ModifyDNRequest(DN dn, RDN newRDN, boolean deleteOldRDN)Creates a new modify DN request that will rename the entry but will not move it below a new entry.ModifyDNRequest(DN dn, RDN newRDN, boolean deleteOldRDN, Control[] controls)Creates a new modify DN request that will rename the entry but will not move it below a new entry.ModifyDNRequest(DN dn, RDN newRDN, boolean deleteOldRDN, DN newSuperiorDN)Creates a new modify DN request that will rename the entry and will optionally move it below a new entry.ModifyDNRequest(DN dn, RDN newRDN, boolean deleteOldRDN, DN newSuperiorDN, Control[] controls)Creates a new modify DN request that will rename the entry and will optionally move it below a new entry.ModifyDNRequest(java.lang.String dn, java.lang.String newRDN, boolean deleteOldRDN)Creates a new modify DN request that will rename the entry but will not move it below a new entry.ModifyDNRequest(java.lang.String dn, java.lang.String newRDN, boolean deleteOldRDN, Control[] controls)Creates a new modify DN request that will rename the entry but will not move it below a new entry.ModifyDNRequest(java.lang.String dn, java.lang.String newRDN, boolean deleteOldRDN, java.lang.String newSuperiorDN)Creates a new modify DN request that will rename the entry and will optionally move it below a new entry.ModifyDNRequest(java.lang.String dn, java.lang.String newRDN, boolean deleteOldRDN, java.lang.String newSuperiorDN, Control[] controls)Creates a new modify DN request that will rename the entry and will optionally move it below a new entry.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandeleteOldRDN()Indicates whether the current RDN value should be removed from the entry.ModifyDNRequestduplicate()Creates a new instance of this LDAP request that may be modified without impacting this request.ModifyDNRequestduplicate(Control[] controls)Creates a new instance of this LDAP request that may be modified without impacting this request.ASN1ElementencodeProtocolOp()Encodes the modify DN request protocol op to an ASN.1 element.java.lang.StringgetDN()Retrieves the current DN of the entry to move/rename.intgetLastMessageID()Retrieves the message ID for the last LDAP message sent using this request.java.lang.StringgetNewRDN()Retrieves the new RDN for the entry.java.lang.StringgetNewSuperiorDN()Retrieves the new superior DN for the entry.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 modify DN request to the directory server over the provided connection and returns the associated response.voidresponseReceived(LDAPResponse response)voidsetDeleteOldRDN(boolean deleteOldRDN)Specifies whether the current RDN value should be removed from the entry.voidsetDN(DN dn)Specifies the current DN of the entry to move/rename.voidsetDN(java.lang.String dn)Specifies the current DN of the entry to move/rename.voidsetNewRDN(RDN newRDN)Specifies the new RDN for the entry.voidsetNewRDN(java.lang.String newRDN)Specifies the new RDN for the entry.voidsetNewSuperiorDN(DN newSuperiorDN)Specifies the new superior DN for the entry.voidsetNewSuperiorDN(java.lang.String newSuperiorDN)Specifies the new superior DN for the entry.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 modify DN change record.LDIFModifyDNChangeRecordtoLDIFChangeRecord()Retrieves an LDIF modify DN change record with the contents of this modify DN request.java.lang.StringtoLDIFString()Retrieves an LDIF string representation of this modify DN request.voidtoString(java.lang.StringBuilder buffer)Appends a string representation of this request to the provided buffer.voidwriteTo(ASN1Buffer writer)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, getControls, getReferralConnector, getResponseTimeoutMillis, hasControl, hasControl, toString
-
-
-
-
Constructor Detail
-
ModifyDNRequest
public ModifyDNRequest(@NotNull java.lang.String dn, @NotNull java.lang.String newRDN, boolean deleteOldRDN)
Creates a new modify DN request that will rename the entry but will not move it below a new entry.- Parameters:
dn- The current DN for the entry to rename. It must not benull.newRDN- The new RDN for the target entry. It must not benull.deleteOldRDN- Indicates whether to delete the current RDN value from the target entry.
-
ModifyDNRequest
public ModifyDNRequest(@NotNull DN dn, @NotNull RDN newRDN, boolean deleteOldRDN)
Creates a new modify DN request that will rename the entry but will not move it below a new entry.- Parameters:
dn- The current DN for the entry to rename. It must not benull.newRDN- The new RDN for the target entry. It must not benull.deleteOldRDN- Indicates whether to delete the current RDN value from the target entry.
-
ModifyDNRequest
public ModifyDNRequest(@NotNull java.lang.String dn, @NotNull java.lang.String newRDN, boolean deleteOldRDN, @Nullable java.lang.String newSuperiorDN)
Creates a new modify DN request that will rename the entry and will optionally move it below a new entry.- Parameters:
dn- The current DN for the entry to rename. It must not benull.newRDN- The new RDN for the target entry. It must not benull.deleteOldRDN- Indicates whether to delete the current RDN value from the target entry.newSuperiorDN- The new superior DN for the entry. It may benullif the entry is not to be moved below a new parent.
-
ModifyDNRequest
public ModifyDNRequest(@NotNull DN dn, @NotNull RDN newRDN, boolean deleteOldRDN, @Nullable DN newSuperiorDN)
Creates a new modify DN request that will rename the entry and will optionally move it below a new entry.- Parameters:
dn- The current DN for the entry to rename. It must not benull.newRDN- The new RDN for the target entry. It must not benull.deleteOldRDN- Indicates whether to delete the current RDN value from the target entry.newSuperiorDN- The new superior DN for the entry. It may benullif the entry is not to be moved below a new parent.
-
ModifyDNRequest
public ModifyDNRequest(@NotNull java.lang.String dn, @NotNull java.lang.String newRDN, boolean deleteOldRDN, @Nullable Control[] controls)
Creates a new modify DN request that will rename the entry but will not move it below a new entry.- Parameters:
dn- The current DN for the entry to rename. It must not benull.newRDN- The new RDN for the target entry. It must not benull.deleteOldRDN- Indicates whether to delete the current RDN value from the target entry.controls- The set of controls to include in the request.
-
ModifyDNRequest
public ModifyDNRequest(@NotNull DN dn, @NotNull RDN newRDN, boolean deleteOldRDN, @Nullable Control[] controls)
Creates a new modify DN request that will rename the entry but will not move it below a new entry.- Parameters:
dn- The current DN for the entry to rename. It must not benull.newRDN- The new RDN for the target entry. It must not benull.deleteOldRDN- Indicates whether to delete the current RDN value from the target entry.controls- The set of controls to include in the request.
-
ModifyDNRequest
public ModifyDNRequest(@NotNull java.lang.String dn, @NotNull java.lang.String newRDN, boolean deleteOldRDN, @Nullable java.lang.String newSuperiorDN, @Nullable Control[] controls)
Creates a new modify DN request that will rename the entry and will optionally move it below a new entry.- Parameters:
dn- The current DN for the entry to rename. It must not benull.newRDN- The new RDN for the target entry. It must not benull.deleteOldRDN- Indicates whether to delete the current RDN value from the target entry.newSuperiorDN- The new superior DN for the entry. It may benullif the entry is not to be moved below a new parent.controls- The set of controls to include in the request.
-
ModifyDNRequest
public ModifyDNRequest(@NotNull DN dn, @NotNull RDN newRDN, boolean deleteOldRDN, @Nullable DN newSuperiorDN, @Nullable Control[] controls)
Creates a new modify DN request that will rename the entry and will optionally move it below a new entry.- Parameters:
dn- The current DN for the entry to rename. It must not benull.newRDN- The new RDN for the target entry. It must not benull.deleteOldRDN- Indicates whether to delete the current RDN value from the target entry.newSuperiorDN- The new superior DN for the entry. It may benullif the entry is not to be moved below a new parent.controls- The set of controls to include in the request.
-
-
Method Detail
-
getDN
@NotNull public java.lang.String getDN()
Retrieves the current DN of the entry to move/rename.- Specified by:
getDNin interfaceReadOnlyModifyDNRequest- Returns:
- The current DN of the entry to move/rename.
-
setDN
public void setDN(@NotNull java.lang.String dn)
Specifies the current DN of the entry to move/rename.- Parameters:
dn- The current DN of the entry to move/rename. It must not benull.
-
setDN
public void setDN(@NotNull DN dn)
Specifies the current DN of the entry to move/rename.- Parameters:
dn- The current DN of the entry to move/rename. It must not benull.
-
getNewRDN
@NotNull public java.lang.String getNewRDN()
Retrieves the new RDN for the entry.- Specified by:
getNewRDNin interfaceReadOnlyModifyDNRequest- Returns:
- The new RDN for the entry.
-
setNewRDN
public void setNewRDN(@NotNull java.lang.String newRDN)
Specifies the new RDN for the entry.- Parameters:
newRDN- The new RDN for the entry. It must not benull.
-
setNewRDN
public void setNewRDN(@NotNull RDN newRDN)
Specifies the new RDN for the entry.- Parameters:
newRDN- The new RDN for the entry. It must not benull.
-
deleteOldRDN
public boolean deleteOldRDN()
Indicates whether the current RDN value should be removed from the entry.- Specified by:
deleteOldRDNin interfaceReadOnlyModifyDNRequest- Returns:
trueif the current RDN value should be removed from the entry, orfalseif not.
-
setDeleteOldRDN
public void setDeleteOldRDN(boolean deleteOldRDN)
Specifies whether the current RDN value should be removed from the entry.- Parameters:
deleteOldRDN- Specifies whether the current RDN value should be removed from the entry.
-
getNewSuperiorDN
@Nullable public java.lang.String getNewSuperiorDN()
Retrieves the new superior DN for the entry.- Specified by:
getNewSuperiorDNin interfaceReadOnlyModifyDNRequest- Returns:
- The new superior DN for the entry, or
nullif the entry is not to be moved below a new parent.
-
setNewSuperiorDN
public void setNewSuperiorDN(@Nullable java.lang.String newSuperiorDN)
Specifies the new superior DN for the entry.- Parameters:
newSuperiorDN- The new superior DN for the entry. It may benullif the entry is not to be removed below a new parent.
-
setNewSuperiorDN
public void setNewSuperiorDN(@Nullable DN newSuperiorDN)
Specifies the new superior DN for the entry.- Parameters:
newSuperiorDN- The new superior DN for the entry. It may benullif the entry is not to be removed below a new parent.
-
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(@NotNull ASN1Buffer writer)
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:
writer- The ASN.1 buffer to which the encoded representation should be written.
-
encodeProtocolOp
@NotNull public ASN1Element encodeProtocolOp()
Encodes the modify DN request protocol op to an ASN.1 element.- Specified by:
encodeProtocolOpin interfaceProtocolOp- Returns:
- The ASN.1 element with the encoded modify DN request protocol op.
-
process
@NotNull protected LDAPResult process(@NotNull LDAPConnection connection, int depth) throws LDAPException
Sends this modify DN 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 modify DN processing.
- Throws:
LDAPException- If a problem occurs while sending the request or reading the response.
-
responseReceived
@InternalUseOnly public void responseReceived(@NotNull 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
@NotNull 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
@NotNull public ModifyDNRequest duplicate()
Creates a new instance of this LDAP request that may be modified without impacting this request.- Specified by:
duplicatein interfaceReadOnlyLDAPRequest- Specified by:
duplicatein interfaceReadOnlyModifyDNRequest- Returns:
- A new instance of this LDAP request that may be modified without impacting this request.
-
duplicate
@NotNull public ModifyDNRequest duplicate(@NotNull 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 interfaceReadOnlyLDAPRequest- Specified by:
duplicatein interfaceReadOnlyModifyDNRequest- 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
@NotNull public LDIFModifyDNChangeRecord toLDIFChangeRecord()
Retrieves an LDIF modify DN change record with the contents of this modify DN request.- Specified by:
toLDIFChangeRecordin interfaceReadOnlyModifyDNRequest- Returns:
- An LDIF modify DN change record with the contents of this modify DN request.
-
toLDIF
@NotNull public java.lang.String[] toLDIF()
Retrieves a string array whose lines contain an LDIF representation of the corresponding modify DN change record.- Specified by:
toLDIFin interfaceReadOnlyModifyDNRequest- Returns:
- A string array whose lines contain an LDIF representation of the corresponding modify DN change record.
-
toLDIFString
@NotNull public java.lang.String toLDIFString()
Retrieves an LDIF string representation of this modify DN request.- Specified by:
toLDIFStringin interfaceReadOnlyModifyDNRequest- Returns:
- An LDIF string representation of this modify DN request.
-
toString
public void toString(@NotNull 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(@NotNull java.util.List<java.lang.String> lineList, @NotNull 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).
-
-