@Mutable @ThreadSafety(level=NOT_THREADSAFE) public final class AddRequest extends UpdatableLDAPRequest implements ReadOnlyAddRequest, ProtocolOp
Entry
object, or as a list of the lines that
comprise the LDIF representation of the entry to add as described in
RFC 2849. For example, the
following code demonstrates creating an add request from the LDIF
representation of the entry:
AddRequest addRequest = new AddRequest( "dn: dc=example,dc=com", "objectClass: top", "objectClass: domain", "dc: example");
AddRequest
objects are mutable and therefore can be altered and
re-used for multiple requests. Note, however, that AddRequest
objects are not threadsafe and therefore a single AddRequest
object
instance should not be used to process multiple requests at the same time.Constructor and Description |
---|
AddRequest(DN dn,
Attribute... attributes)
Creates a new add request with the provided DN and set of attributes.
|
AddRequest(DN dn,
Attribute[] attributes,
Control[] controls)
Creates a new add request with the provided DN and set of attributes.
|
AddRequest(DN dn,
java.util.Collection<Attribute> attributes)
Creates a new add request with the provided DN and set of attributes.
|
AddRequest(DN dn,
java.util.Collection<Attribute> attributes,
Control[] controls)
Creates a new add request with the provided DN and set of attributes.
|
AddRequest(Entry entry)
Creates a new add request to add the provided entry.
|
AddRequest(Entry entry,
Control[] controls)
Creates a new add request to add the provided entry.
|
AddRequest(java.lang.String... ldifLines)
Creates a new add request with the provided entry in LDIF form.
|
AddRequest(java.lang.String dn,
Attribute... attributes)
Creates a new add request with the provided DN and set of attributes.
|
AddRequest(java.lang.String dn,
Attribute[] attributes,
Control[] controls)
Creates a new add request with the provided DN and set of attributes.
|
AddRequest(java.lang.String dn,
java.util.Collection<Attribute> attributes)
Creates a new add request with the provided DN and set of attributes.
|
AddRequest(java.lang.String dn,
java.util.Collection<Attribute> attributes,
Control[] controls)
Creates a new add request with the provided DN and set of attributes.
|
Modifier and Type | Method and Description |
---|---|
void |
addAttribute(Attribute attribute)
Adds the provided attribute to the entry to add.
|
void |
addAttribute(java.lang.String name,
byte[]... values)
Adds the provided attribute to the entry to add.
|
void |
addAttribute(java.lang.String name,
byte[] value)
Adds the provided attribute to the entry to add.
|
void |
addAttribute(java.lang.String name,
java.lang.String... values)
Adds the provided attribute to the entry to add.
|
void |
addAttribute(java.lang.String name,
java.lang.String value)
Adds the provided attribute to the entry to add.
|
AddRequest |
duplicate()
Creates a new instance of this LDAP request that may be modified without
impacting this request.
|
AddRequest |
duplicate(Control[] controls)
Creates a new instance of this LDAP request that may be modified without
impacting this request.
|
ASN1Element |
encodeProtocolOp()
Encodes the add request protocol op to an ASN.1 element.
|
Attribute |
getAttribute(java.lang.String attributeName)
Retrieves the specified attribute from this add request.
|
java.util.List<Attribute> |
getAttributes()
Retrieves the set of attributes for this add request.
|
java.lang.String |
getDN()
Retrieves the DN for this add request.
|
int |
getLastMessageID()
Retrieves the message ID for the last LDAP message sent using this request.
|
OperationType |
getOperationType()
Retrieves the type of operation that is represented by this request.
|
byte |
getProtocolOpType()
Retrieves the BER type for this protocol op.
|
boolean |
hasAttribute(Attribute attribute)
Indicates whether this add request contains the specified attribute.
|
boolean |
hasAttribute(java.lang.String attributeName)
Indicates whether this add request contains the specified attribute.
|
boolean |
hasAttributeValue(java.lang.String attributeName,
byte[] attributeValue)
Indicates whether this add request contains an attribute with the given
name and value.
|
boolean |
hasAttributeValue(java.lang.String attributeName,
byte[] attributeValue,
MatchingRule matchingRule)
Indicates whether this add request contains an attribute with the given
name and value.
|
boolean |
hasAttributeValue(java.lang.String attributeName,
java.lang.String attributeValue)
Indicates whether this add request contains an attribute with the given
name and value.
|
boolean |
hasAttributeValue(java.lang.String attributeName,
java.lang.String attributeValue,
MatchingRule matchingRule)
Indicates whether this add request contains an attribute with the given
name and value.
|
boolean |
hasObjectClass(java.lang.String objectClassName)
Indicates whether this add request contains the specified object class.
|
protected LDAPResult |
process(LDAPConnection connection,
int depth)
Sends this add request to the directory server over the provided connection
and returns the associated response.
|
boolean |
removeAttribute(java.lang.String attributeName)
Removes the attribute with the specified name from the entry to add.
|
boolean |
removeAttribute(java.lang.String name,
byte[] value)
Removes the specified attribute value from this add request.
|
boolean |
removeAttributeValue(java.lang.String name,
java.lang.String value)
Removes the specified attribute value from this add request.
|
void |
replaceAttribute(Attribute attribute)
Replaces the specified attribute in the entry to add.
|
void |
replaceAttribute(java.lang.String name,
byte[]... values)
Replaces the specified attribute in the entry to add.
|
void |
replaceAttribute(java.lang.String name,
byte[] value)
Replaces the specified attribute in the entry to add.
|
void |
replaceAttribute(java.lang.String name,
java.lang.String... values)
Replaces the specified attribute in the entry to add.
|
void |
replaceAttribute(java.lang.String name,
java.lang.String value)
Replaces the specified attribute in the entry to add.
|
void |
responseReceived(LDAPResponse response)
Indicates that the provided LDAP response has been received by from the
server.
|
void |
setAttributes(Attribute[] attributes)
Specifies the set of attributes for this add request.
|
void |
setAttributes(java.util.Collection<Attribute> attributes)
Specifies the set of attributes for this add request.
|
void |
setDN(DN dn)
Specifies the DN for this add request.
|
void |
setDN(java.lang.String dn)
Specifies the DN for this add request.
|
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.
|
Entry |
toEntry()
Retrieves an
Entry object containing the DN and attributes of this
add request. |
java.lang.String[] |
toLDIF()
Retrieves a string array whose lines contain an LDIF representation of the
corresponding add change record.
|
LDIFAddChangeRecord |
toLDIFChangeRecord()
Retrieves an LDIF add change record with the contents of this add request.
|
java.lang.String |
toLDIFString()
Retrieves an LDIF string representation of this add request.
|
void |
toString(java.lang.StringBuilder buffer)
Appends a string representation of this request to the provided buffer.
|
void |
writeTo(ASN1Buffer buffer)
Writes an ASN.1-encoded representation of this LDAP protocol op to the
provided ASN.1 buffer.
|
addControl, addControls, clearControls, removeControl, removeControl, replaceControl, replaceControl, setControls, setControls
followReferrals, getControl, getControlList, getControls, getIntermediateResponseListener, getReferralConnector, getReferralConnectorInternal, getReferralDepth, getResponseTimeoutMillis, hasControl, hasControl, setFollowReferrals, setIntermediateResponseListener, setReferralConnector, setReferralDepth, setResponseTimeoutMillis, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
followReferrals, getControl, getControlList, getControls, getReferralConnector, getResponseTimeoutMillis, hasControl, hasControl, toString
public AddRequest(@NotNull java.lang.String dn, @NotNull Attribute... attributes)
dn
- The DN for the entry to add. It must not be
null
.attributes
- The set of attributes to include in the entry to add.
It must not be null
.public AddRequest(@NotNull java.lang.String dn, @NotNull Attribute[] attributes, @Nullable Control[] controls)
dn
- The DN for the entry to add. It must not be
null
.attributes
- The set of attributes to include in the entry to add.
It must not be null
.controls
- The set of controls to include in the request.public AddRequest(@NotNull java.lang.String dn, @NotNull java.util.Collection<Attribute> attributes)
dn
- The DN for the entry to add. It must not be
null
.attributes
- The set of attributes to include in the entry to add.
It must not be null
.public AddRequest(@NotNull java.lang.String dn, @NotNull java.util.Collection<Attribute> attributes, @Nullable Control[] controls)
dn
- The DN for the entry to add. It must not be
null
.attributes
- The set of attributes to include in the entry to add.
It must not be null
.controls
- The set of controls to include in the request.public AddRequest(@NotNull DN dn, @NotNull Attribute... attributes)
dn
- The DN for the entry to add. It must not be
null
.attributes
- The set of attributes to include in the entry to add.
It must not be null
.public AddRequest(@NotNull DN dn, @NotNull Attribute[] attributes, @Nullable Control[] controls)
dn
- The DN for the entry to add. It must not be
null
.attributes
- The set of attributes to include in the entry to add.
It must not be null
.controls
- The set of controls to include in the request.public AddRequest(@NotNull DN dn, @NotNull java.util.Collection<Attribute> attributes)
dn
- The DN for the entry to add. It must not be
null
.attributes
- The set of attributes to include in the entry to add.
It must not be null
.public AddRequest(@NotNull DN dn, @NotNull java.util.Collection<Attribute> attributes, @Nullable Control[] controls)
dn
- The DN for the entry to add. It must not be
null
.attributes
- The set of attributes to include in the entry to add.
It must not be null
.controls
- The set of controls to include in the request.public AddRequest(@NotNull Entry entry)
entry
- The entry to be added. It must not be null
.public AddRequest(@NotNull Entry entry, @Nullable Control[] controls)
entry
- The entry to be added. It must not be null
.controls
- The set of controls to include in the request.public AddRequest(@NotNull java.lang.String... ldifLines) throws LDIFException
ldifLines
- The lines that comprise the LDIF representation of the
entry to add. It must not be null
or empty. It
may represent a standard LDIF entry, or it may represent
an LDIF add change record (optionally including
controls).LDIFException
- If the provided LDIF data cannot be decoded as an
entry.@NotNull public java.lang.String getDN()
getDN
in interface ReadOnlyAddRequest
public void setDN(@NotNull java.lang.String dn)
dn
- The DN for this add request. It must not be null
.public void setDN(@NotNull DN dn)
dn
- The DN for this add request. It must not be null
.@NotNull public java.util.List<Attribute> getAttributes()
getAttributes
in interface ReadOnlyAddRequest
@Nullable public Attribute getAttribute(@NotNull java.lang.String attributeName)
getAttribute
in interface ReadOnlyAddRequest
attributeName
- The name of the attribute to retrieve. It must not
be null
.null
if it does not exist in
the add request.public boolean hasAttribute(@NotNull java.lang.String attributeName)
hasAttribute
in interface ReadOnlyAddRequest
attributeName
- The name of the attribute for which to make the
determination. It must not be null
.true
if this add request contains the specified attribute,
or false
if not.public boolean hasAttribute(@NotNull Attribute attribute)
true
if this add request contains an attribute
with the same name and exact set of values.hasAttribute
in interface ReadOnlyAddRequest
attribute
- The attribute for which to make the determination. It
must not be null
.true
if this add request contains the specified attribute,
or false
if not.public boolean hasAttributeValue(@NotNull java.lang.String attributeName, @NotNull java.lang.String attributeValue)
hasAttributeValue
in interface ReadOnlyAddRequest
attributeName
- The name of the attribute for which to make the
determination. It must not be null
.attributeValue
- The value for which to make the determination. It
must not be null
.true
if this add request contains an attribute with the
specified name and value, or false
if not.public boolean hasAttributeValue(@NotNull java.lang.String attributeName, @NotNull java.lang.String attributeValue, @NotNull MatchingRule matchingRule)
hasAttributeValue
in interface ReadOnlyAddRequest
attributeName
- The name of the attribute for which to make the
determination. It must not be null
.attributeValue
- The value for which to make the determination. It
must not be null
.matchingRule
- The matching rule to use to make the determination.
It must not be null
.true
if this add request contains an attribute with the
specified name and value, or false
if not.public boolean hasAttributeValue(@NotNull java.lang.String attributeName, @NotNull byte[] attributeValue)
hasAttributeValue
in interface ReadOnlyAddRequest
attributeName
- The name of the attribute for which to make the
determination. It must not be null
.attributeValue
- The value for which to make the determination. It
must not be null
.true
if this add request contains an attribute with the
specified name and value, or false
if not.public boolean hasAttributeValue(@NotNull java.lang.String attributeName, @NotNull byte[] attributeValue, @NotNull MatchingRule matchingRule)
hasAttributeValue
in interface ReadOnlyAddRequest
attributeName
- The name of the attribute for which to make the
determination. It must not be null
.attributeValue
- The value for which to make the determination. It
must not be null
.matchingRule
- The matching rule to use to make the determination.
It must not be null
.true
if this add request contains an attribute with the
specified name and value, or false
if not.public boolean hasObjectClass(@NotNull java.lang.String objectClassName)
hasObjectClass
in interface ReadOnlyAddRequest
objectClassName
- The name of the object class for which to make the
determination. It must not be null
.true
if this add request contains the specified object
class, or false
if not.@NotNull public Entry toEntry()
Entry
object containing the DN and attributes of this
add request.toEntry
in interface ReadOnlyAddRequest
Entry
object containing the DN and attributes of this
add request.public void setAttributes(@NotNull Attribute[] attributes)
null
.attributes
- The set of attributes for this add request.public void setAttributes(@NotNull java.util.Collection<Attribute> attributes)
null
.attributes
- The set of attributes for this add request.public void addAttribute(@NotNull Attribute attribute)
attribute
- The attribute to be added to the entry to add. It must
not be null
.public void addAttribute(@NotNull java.lang.String name, @NotNull java.lang.String value)
name
- The name of the attribute to add. It must not be
null
.value
- The value for the attribute to add. It must not be
null
.public void addAttribute(@NotNull java.lang.String name, @NotNull byte[] value)
name
- The name of the attribute to add. It must not be
null
.value
- The value for the attribute to add. It must not be
null
.public void addAttribute(@NotNull java.lang.String name, @NotNull java.lang.String... values)
name
- The name of the attribute to add. It must not be
null
.values
- The set of values for the attribute to add. It must not be
null
.public void addAttribute(@NotNull java.lang.String name, @NotNull byte[]... values)
name
- The name of the attribute to add. It must not be
null
.values
- The set of values for the attribute to add. It must not be
null
.public boolean removeAttribute(@NotNull java.lang.String attributeName)
attributeName
- The name of the attribute to remove. It must not be
null
.true
if the attribute was removed from this add request,
or false
if the add request did not include the specified
attribute.public boolean removeAttributeValue(@NotNull java.lang.String name, @NotNull java.lang.String value)
name
- The name of the attribute to remove. It must not be
null
.value
- The value of the attribute to remove. It must not be
null
.true
if the attribute value was removed from this add
request, or false
if the add request did not include the
specified attribute value.public boolean removeAttribute(@NotNull java.lang.String name, @NotNull byte[] value)
name
- The name of the attribute to remove. It must not be
null
.value
- The value of the attribute to remove. It must not be
null
.true
if the attribute value was removed from this add
request, or false
if the add request did not include the
specified attribute value.public void replaceAttribute(@NotNull Attribute attribute)
attribute
- The attribute to be replaced in this add request. It
must not be null
.public void replaceAttribute(@NotNull java.lang.String name, @NotNull java.lang.String value)
name
- The name of the attribute to be replaced. It must not be
null
.value
- The new value for the attribute. It must not be
null
.public void replaceAttribute(@NotNull java.lang.String name, @NotNull byte[] value)
name
- The name of the attribute to be replaced. It must not be
null
.value
- The new value for the attribute. It must not be
null
.public void replaceAttribute(@NotNull java.lang.String name, @NotNull java.lang.String... values)
name
- The name of the attribute to be replaced. It must not be
null
.values
- The new set of values for the attribute. It must not be
null
.public void replaceAttribute(@NotNull java.lang.String name, @NotNull byte[]... values)
name
- The name of the attribute to be replaced. It must not be
null
.values
- The new set of values for the attribute. It must not be
null
.public byte getProtocolOpType()
getProtocolOpType
in interface ProtocolOp
public void writeTo(@NotNull ASN1Buffer buffer)
writeTo
in interface ProtocolOp
buffer
- The ASN.1 buffer to which the encoded representation should
be written.@NotNull public ASN1Element encodeProtocolOp()
encodeProtocolOp
in interface ProtocolOp
@NotNull protected LDAPResult process(@NotNull LDAPConnection connection, int depth) throws LDAPException
process
in class LDAPRequest
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.LDAPException
- If a problem occurs while sending the request or
reading the response.public int getLastMessageID()
getLastMessageID
in class LDAPRequest
@NotNull public OperationType getOperationType()
getOperationType
in class LDAPRequest
@NotNull public AddRequest duplicate()
duplicate
in interface ReadOnlyAddRequest
duplicate
in interface ReadOnlyLDAPRequest
@NotNull public AddRequest duplicate(@Nullable Control[] controls)
duplicate
in interface ReadOnlyAddRequest
duplicate
in interface ReadOnlyLDAPRequest
controls
- The set of controls to include in the duplicate request.@InternalUseOnly public void responseReceived(@NotNull LDAPResponse response) throws LDAPException
response
- The LDAP response that has been received from the server.
It may be null
if the connection has been closed
without having received any response.LDAPException
- If a problem occurs while handling the response.@NotNull public LDIFAddChangeRecord toLDIFChangeRecord()
toLDIFChangeRecord
in interface ReadOnlyAddRequest
@NotNull public java.lang.String[] toLDIF()
toLDIF
in interface ReadOnlyAddRequest
@NotNull public java.lang.String toLDIFString()
toLDIFString
in interface ReadOnlyAddRequest
public void toString(@NotNull java.lang.StringBuilder buffer)
toString
in interface ProtocolOp
toString
in interface ReadOnlyLDAPRequest
toString
in class LDAPRequest
buffer
- The buffer to which to append a string representation of
this request.public void toCode(@NotNull java.util.List<java.lang.String> lineList, @NotNull java.lang.String requestID, int indentSpaces, boolean includeProcessing)
toCode
in interface ReadOnlyLDAPRequest
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 is null
or
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 (if true
),
or just to generate the request (if
false
).