Class AddRequest
- All Implemented Interfaces:
Entry
,ProtocolOp
,Request
,ChangeRecord
The RDN attribute(s) may or may not be included in the Add request.
NO-USER-MODIFICATION attributes such as the createTimestamp
or
creatorsName
attributes must not be included, since the server
maintains these automatically.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.forgerock.opendj.ldap.messages.Request
Request.RequestType
-
Method Summary
Modifier and TypeMethodDescription<R,
P, E extends Exception>
Raccept
(RequestVisitor<R, P, E> v, P p) Applies aRequestVisitor
to thisRequest
.addAttribute
(String attributeDescription, Object... values) Ensures that this entry contains the provided attribute and values (optional operation).boolean
addAttribute
(Attribute attribute) Ensures that this entry contains the provided attribute and values (optional operation).boolean
addAttribute
(Attribute attribute, Collection<? super ByteString> duplicateValues) Ensures that this entry contains the provided attribute and values (optional operation).addAttributeIfAbsent
(Attribute attribute) Adds the provided attribute if it is not already present in this Entry and returnsnull
.final AddRequest
addControl
(Control control) Adds the provided control to this protocol-op.final AddRequest
addControls
(Iterable<? extends Control> controls) Adds the provided controls to this protocol-op.Removes all the attributes from this entry (optional operation).boolean
containsAnyAttributes
(String attributeDescription) Returnstrue
if this entry contains any non-empty attributes having an attribute description which is a sub-type of the provided attribute description.boolean
containsAnyAttributes
(AttributeDescription attributeDescription) Returnstrue
if this entry contains any non-empty attributes having an attribute description which is a sub-type of the provided attribute description.boolean
containsAttribute
(String attributeDescription, Object... values) Returnstrue
if this entry contains all of the attribute values contained invalues
.boolean
containsAttribute
(AttributeDescription attributeDescription, Object... values) Returnstrue
if this entry contains all of the attribute values contained invalues
.boolean
containsAttribute
(Attribute attribute, Collection<? super ByteString> missingValues) Returnstrue
if this entry contains all of the attribute values contained inattribute
.final boolean
containsControl
(String oid) Returnstrue
if this protocol-op contains the specified control.boolean
Returnstrue
ifobject
is an entry which is equal to this entry.Returns anIterable
containing all of the attributes in this entry.getAllAttributes
(String attributeDescription) Returns anIterable
containing all the attributes in this entry having an attribute description which is a sub-type of the provided attribute description.getAllAttributes
(AttributeDescription attributeDescription) Returns anIterable
containing all the attributes in this entry having an attribute description which is a sub-type of the provided attribute description.getAttribute
(String attributeDescription) Returns the named attribute contained in this entry, ornull
if it is not included with this entry.getAttribute
(AttributeDescription attributeDescription) Returns the named attribute contained in this entry, ornull
if it is not included with this entry.int
Returns the number of attributes in this entry.final <C extends Control>
CgetControl
(ControlDecoder<C> decoder, DecodeOptions options) Decodes and returns the first control in this protocol-op having an OID corresponding to the provided control decoder.Returns aList
containing the controls included with this protocol-op.getName()
Returns the distinguished name of the entry being modified by thisChangeRecord
.getType()
Returns the type of this request to avoid expensiveinstanceof
checks.int
hashCode()
Returns the hash code for this entry.mergeAttribute
(Attribute attribute, BiFunction<? super Attribute, ? super Attribute, ? extends Attribute> mergeFunction) Adds the provided attribute if it is not already present in this Entry.parseAttribute
(String attributeDescription) Returns a parser for the named attribute contained in this entry.parseAttribute
(AttributeDescription attributeDescription) Returns a parser for the named attribute contained in this entry.removeAttribute
(String attributeDescription, Object... values) Removes all of the attribute values contained invalues
from the named attribute in this entry if it is present (optional operation).boolean
removeAttribute
(AttributeDescription attributeDescription) Removes the named attribute from this entry if it is present (optional operation).boolean
removeAttribute
(Attribute attribute, Collection<? super ByteString> missingValues) Removes all of the attribute values contained inattribute
from this entry if it is present (optional operation).final AddRequest
removeControls
(String oid) Removes all the controls having the specified OID.replaceAttribute
(String attributeDescription, Object... values) Adds all of the attribute values contained invalues
to this entry, replacing any existing attribute values (optional operation).boolean
replaceAttribute
(Attribute attribute) Adds all of the attribute values contained inattribute
to this entry, replacing any existing attribute values (optional operation).Sets the distinguished name of the entry to be updated.Sets the distinguished name of the entry to be updated.toString()
Returns a string representation of this entry.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.forgerock.opendj.ldif.ChangeRecord
addControl, addControls
Methods inherited from interface org.forgerock.opendj.ldap.messages.ProtocolOp
containsControl, getControl, getControl, getControls
Methods inherited from interface org.forgerock.opendj.ldap.messages.Request
removeControls
-
Method Details
-
accept
Description copied from interface:Request
Applies aRequestVisitor
to thisRequest
.- Specified by:
accept
in interfaceRequest
- Type Parameters:
R
- The return type of the visitor's methods.P
- The type of the additional parameters to the visitor's methods.E
- The type of the exception thrown by the visitor method if it fails, orNeverThrowsException
if the visitor cannot fail.- Parameters:
v
- The request visitor.p
- Optional additional visitor parameter.- Returns:
- A result as specified by the visitor.
- Throws:
E
- If the visitor failed.
-
addAttribute
Description copied from interface:Entry
Ensures that this entry contains the provided attribute and values (optional operation). This method has the following semantics:- If this entry does not already contain an attribute with a
matching
attribute description, then this entry will be modified such that it containsattribute
, even if it is empty. - If this entry already contains an attribute with a
matching
attribute description, then the attribute values contained inattribute
will be merged with the existing attribute values.
NOTE: When
attribute
is non-empty, this method implements LDAP Modify add semantics.- Specified by:
addAttribute
in interfaceEntry
- Parameters:
attribute
- The attribute values to be added to this entry, merging with any existing attribute values.- Returns:
true
if this entry changed as a result of this call.
- If this entry does not already contain an attribute with a
-
addAttribute
Description copied from interface:Entry
Ensures that this entry contains the provided attribute and values (optional operation). This method has the following semantics:- If this entry does not already contain an attribute with a
matching
attribute description, then this entry will be modified such that it containsattribute
, even if it is empty. - If this entry already contains an attribute with a
matching
attribute description, then the attribute values contained inattribute
will be merged with the existing attribute values.
NOTE: When
attribute
is non-empty, this method implements LDAP Modify add semantics.- Specified by:
addAttribute
in interfaceEntry
- Parameters:
attribute
- The attribute values to be added to this entry, merging with any existing attribute values.duplicateValues
- A collection into which duplicate values will be added, ornull
if duplicate values should not be saved.- Returns:
true
if this entry changed as a result of this call.
- If this entry does not already contain an attribute with a
-
addAttribute
Description copied from interface:Entry
Ensures that this entry contains the provided attribute and values (optional operation). This method has the following semantics:- If this entry does not already contain an attribute with a
matching
attribute description, then this entry will be modified such that it containsattribute
, even if it is empty. - If this entry already contains an attribute with a
matching
attribute description, then the attribute values contained inattribute
will be merged with the existing attribute values.
The attribute description will be decoded using the schema associated with this entry (usually the default schema).
Any attribute values which are not instances of
ByteString
will be converted using theByteString.valueOfObject(Object)
method.NOTE: When
attribute
is non-empty, this method implements LDAP Modify add semantics.- Specified by:
addAttribute
in interfaceEntry
- Parameters:
attributeDescription
- The name of the attribute whose values are to be added.values
- The attribute values to be added to this entry, merging any existing attribute values.- Returns:
- This entry.
- If this entry does not already contain an attribute with a
-
addAttributeIfAbsent
Description copied from interface:Entry
Adds the provided attribute if it is not already present in this Entry and returnsnull
. Otherwise returns the existing attribute.NOTE: this method is equivalent to
Map.putIfAbsent(Object, Object)
.- Specified by:
addAttributeIfAbsent
in interfaceEntry
- Parameters:
attribute
- The non-null
attribute to be added if it is not already present.- Returns:
null
if the attribute was added, or the existing attribute (in which case the entry is unchanged).
-
mergeAttribute
public Attribute mergeAttribute(Attribute attribute, BiFunction<? super Attribute, ? super Attribute, ? extends Attribute> mergeFunction) Description copied from interface:Entry
Adds the provided attribute if it is not already present in this Entry. Otherwise, replaces the existing attribute with the results of the remapping function, or removes it if the result isnull
.NOTE: this method is equivalent to
Map.merge(Object, Object, BiFunction)
.- Specified by:
mergeAttribute
in interfaceEntry
- Parameters:
attribute
- The non-null
attribute to be added or merged with the existing attribute.mergeFunction
- The function to recompute the attribute if it is already present in this Entry.- Returns:
- The attribute that was added or merged, or
null
if the attribute was removed.
-
clearAttributes
Description copied from interface:Entry
Removes all the attributes from this entry (optional operation).- Specified by:
clearAttributes
in interfaceEntry
- Returns:
- This entry.
-
containsAnyAttributes
Description copied from interface:Entry
Returnstrue
if this entry contains any non-empty attributes having an attribute description which is a sub-type of the provided attribute description.NOTE: this method performs the matching defined for an LDAP search presence filter. For example, given the attribute description "name" then this method will return
true
if the entry contains "name", "name;option", "cn", or "cn;option". This method is NOT suitable for schema checking, which uses different matching semantics. Specifically, an entry which MUST contain "name" is not valid if it contains "cn", but not "name". See RFC 4512 - Attribute Description Hierarchies.- Specified by:
containsAnyAttributes
in interfaceEntry
- Parameters:
attributeDescription
- The name of the attribute whose presence in this entry is to be tested.- Returns:
true
if this entry contains any non-empty attributes having an attribute description which is a sub-type of the provided attribute description.
-
containsAnyAttributes
Description copied from interface:Entry
Returnstrue
if this entry contains any non-empty attributes having an attribute description which is a sub-type of the provided attribute description.NOTE: this method performs the matching defined for an LDAP search presence filter. For example, given the attribute description "name" then this method will return
true
if the entry contains "name", "name;option", "cn", or "cn;option". This method is NOT suitable for schema checking, which uses different matching semantics. Specifically, an entry which MUST contain "name" is not valid if it contains "cn", but not "name". See RFC 4512 - Attribute Description Hierarchies.- Specified by:
containsAnyAttributes
in interfaceEntry
- Parameters:
attributeDescription
- The name of the attribute whose presence in this entry is to be tested.- Returns:
true
if this entry contains any non-empty attributes having an attribute description which is a sub-type of the provided attribute description.
-
containsAttribute
Description copied from interface:Entry
Returnstrue
if this entry contains all of the attribute values contained inattribute
. Ifattribute
is empty then this method will returntrue
if the attribute is present in this entry, regardless of how many values it contains.- Specified by:
containsAttribute
in interfaceEntry
- Parameters:
attribute
- The attribute values whose presence in this entry is to be tested.missingValues
- A collection into which missing values will be added, ornull
if missing values should not be saved.- Returns:
true
if this entry contains all of the attribute values contained inattribute
.
-
containsAttribute
Description copied from interface:Entry
Returnstrue
if this entry contains all of the attribute values contained invalues
. Ifvalues
isnull
or empty then this method will returntrue
if the attribute is present in this entry, regardless of how many values it contains.The attribute description will be decoded using the schema associated with this entry (usually the default schema).
Any attribute values which are not instances of
ByteString
will be converted using theByteString.valueOfObject(Object)
method.- Specified by:
containsAttribute
in interfaceEntry
- Parameters:
attributeDescription
- The name of the attribute whose presence in this entry is to be tested.values
- The attribute values whose presence in this entry is to be tested, which may benull
.- Returns:
true
if this entry contains all of the attribute values contained invalues
.
-
containsAttribute
Description copied from interface:Entry
Returnstrue
if this entry contains all of the attribute values contained invalues
. Ifvalues
isnull
or empty then this method will returntrue
if the attribute is present in this entry, regardless of how many values it contains.The attribute description will be decoded using the schema associated with this entry (usually the default schema).
Any attribute values which are not instances of
ByteString
will be converted using theByteString.valueOfObject(Object)
method.- Specified by:
containsAttribute
in interfaceEntry
- Parameters:
attributeDescription
- The name of the attribute whose presence in this entry is to be tested.values
- The attribute values whose presence in this entry is to be tested, which may benull
.- Returns:
true
if this entry contains all of the attribute values contained invalues
.
-
equals
Description copied from interface:Entry
Returnstrue
ifobject
is an entry which is equal to this entry. Two entries are considered equal if their distinguished names are equal, they both have the same number of attributes, and every attribute contained in the first entry is also contained in the second entry. -
getAllAttributes
Description copied from interface:Entry
Returns anIterable
containing all of the attributes in this entry. The returnedIterable
may be used to remove attributes if permitted by this entry.- Specified by:
getAllAttributes
in interfaceEntry
- Returns:
- An
Iterable
containing all of the attributes.
-
getAllAttributes
Description copied from interface:Entry
Returns anIterable
containing all the attributes in this entry having an attribute description which is a sub-type of the provided attribute description. The returnedIterable
may be used to remove attributes if permitted by this entry.- Specified by:
getAllAttributes
in interfaceEntry
- Parameters:
attributeDescription
- The name of the attributes to be returned.- Returns:
- An
Iterable
containing the matching attributes.
-
getAllAttributes
Description copied from interface:Entry
Returns anIterable
containing all the attributes in this entry having an attribute description which is a sub-type of the provided attribute description. The returnedIterable
may be used to remove attributes if permitted by this entry.The attribute description will be decoded using the schema associated with this entry (usually the default schema).
- Specified by:
getAllAttributes
in interfaceEntry
- Parameters:
attributeDescription
- The name of the attributes to be returned.- Returns:
- An
Iterable
containing the matching attributes.
-
getAttribute
Description copied from interface:Entry
Returns the named attribute contained in this entry, ornull
if it is not included with this entry.- Specified by:
getAttribute
in interfaceEntry
- Parameters:
attributeDescription
- The name of the attribute to be returned.- Returns:
- The named attribute, or
null
if it is not included with this entry.
-
getAttribute
Description copied from interface:Entry
Returns the named attribute contained in this entry, ornull
if it is not included with this entry.The attribute description will be decoded using the schema associated with this entry (usually the default schema).
- Specified by:
getAttribute
in interfaceEntry
- Parameters:
attributeDescription
- The name of the attribute to be returned.- Returns:
- The named attribute, or
null
if it is not included with this entry.
-
getAttributeCount
public int getAttributeCount()Description copied from interface:Entry
Returns the number of attributes in this entry.- Specified by:
getAttributeCount
in interfaceEntry
- Returns:
- The number of attributes.
-
getName
Description copied from interface:ChangeRecord
Returns the distinguished name of the entry being modified by thisChangeRecord
.- Specified by:
getName
in interfaceChangeRecord
- Specified by:
getName
in interfaceEntry
- Returns:
- The distinguished name of the entry being modified.
-
hashCode
public int hashCode()Description copied from interface:Entry
Returns the hash code for this entry. It will be calculated as the sum of the hash codes of the distinguished name and all of the attributes. -
parseAttribute
Description copied from interface:Entry
Returns a parser for the named attribute contained in this entry.- Specified by:
parseAttribute
in interfaceEntry
- Parameters:
attributeDescription
- The name of the attribute to be parsed.- Returns:
- A parser for the named attribute.
-
parseAttribute
Description copied from interface:Entry
Returns a parser for the named attribute contained in this entry.The attribute description will be decoded using the schema associated with this entry (usually the default schema).
- Specified by:
parseAttribute
in interfaceEntry
- Parameters:
attributeDescription
- The name of the attribute to be parsed.- Returns:
- A parser for the named attribute.
-
removeAttribute
Description copied from interface:Entry
Removes all of the attribute values contained inattribute
from this entry if it is present (optional operation). Ifattribute
is empty then the entire attribute will be removed if it is present.NOTE: This method implements LDAP Modify delete semantics.
- Specified by:
removeAttribute
in interfaceEntry
- Parameters:
attribute
- The attribute values to be removed from this entry, which may be empty if the entire attribute is to be removed.missingValues
- A collection into which missing values will be added, ornull
if missing values should not be saved.- Returns:
true
if this entry changed as a result of this call.
-
removeAttribute
Description copied from interface:Entry
Removes the named attribute from this entry if it is present (optional operation). If this attribute does not contain the attribute, the call leaves this entry unchanged and returnsfalse
.- Specified by:
removeAttribute
in interfaceEntry
- Parameters:
attributeDescription
- The name of the attribute to be removed.- Returns:
true
if this entry changed as a result of this call.
-
removeAttribute
Description copied from interface:Entry
Removes all of the attribute values contained invalues
from the named attribute in this entry if it is present (optional operation). Ifvalues
isnull
or empty then the entire attribute will be removed if it is present.The attribute description will be decoded using the schema associated with this entry (usually the default schema).
Any attribute values which are not instances of
ByteString
will be converted using theByteString.valueOfObject(Object)
method.NOTE: This method implements LDAP Modify delete semantics.
- Specified by:
removeAttribute
in interfaceEntry
- Parameters:
attributeDescription
- The name of the attribute whose values are to be removed.values
- The attribute values to be removed from this entry, which may benull
or empty if the entire attribute is to be removed.- Returns:
- This entry.
-
replaceAttribute
Description copied from interface:Entry
Adds all of the attribute values contained inattribute
to this entry, replacing any existing attribute values (optional operation). Ifattribute
is empty then the entire attribute will be removed if it is present.NOTE: This method implements LDAP Modify replace semantics as described in RFC 4511 - Section 4.6. Modify Operation.
- Specified by:
replaceAttribute
in interfaceEntry
- Parameters:
attribute
- The attribute values to be added to this entry, replacing any existing attribute values, and which may be empty if the entire attribute is to be removed.- Returns:
true
if this entry changed as a result of this call.
-
replaceAttribute
Description copied from interface:Entry
Adds all of the attribute values contained invalues
to this entry, replacing any existing attribute values (optional operation). Ifvalues
isnull
or empty then the entire attribute will be removed if it is present.The attribute description will be decoded using the schema associated with this entry (usually the default schema).
Any attribute values which are not instances of
ByteString
will be converted using theByteString.valueOfObject(Object)
method.NOTE: This method implements LDAP Modify replace semantics as described in RFC 4511 - Section 4.6. Modify Operation.
- Specified by:
replaceAttribute
in interfaceEntry
- Parameters:
attributeDescription
- The name of the attribute whose values are to be replaced.values
- The attribute values to be added to this entry, replacing any existing attribute values, and which may benull
or empty if the entire attribute is to be removed.- Returns:
- This entry.
-
setName
Description copied from interface:ChangeRecord
Sets the distinguished name of the entry to be updated. The server shall not perform any alias dereferencing in determining the object to be updated.- Specified by:
setName
in interfaceChangeRecord
- Specified by:
setName
in interfaceEntry
- Parameters:
dn
- The distinguished name of the entry to be updated.- Returns:
- This change record.
-
setName
Description copied from interface:ChangeRecord
Sets the distinguished name of the entry to be updated. The server shall not perform any alias dereferencing in determining the object to be updated.- Specified by:
setName
in interfaceChangeRecord
- Specified by:
setName
in interfaceEntry
- Parameters:
dn
- The distinguished name of the entry to be updated.- Returns:
- This change record.
-
getType
Description copied from interface:Request
Returns the type of this request to avoid expensiveinstanceof
checks. -
toString
Description copied from interface:Entry
Returns a string representation of this entry. -
addControl
Description copied from interface:ProtocolOp
Adds the provided control to this protocol-op.- Specified by:
addControl
in interfaceProtocolOp
- Parameters:
control
- The control to be added to this protocol-op.- Returns:
- This protocol-op.
-
addControls
Description copied from interface:ProtocolOp
Adds the provided controls to this protocol-op.- Specified by:
addControls
in interfaceProtocolOp
- Parameters:
controls
- The controls to be added to this protocol-op.- Returns:
- This protocol-op.
-
removeControls
Description copied from interface:ProtocolOp
Removes all the controls having the specified OID.- Specified by:
removeControls
in interfaceProtocolOp
- Parameters:
oid
- The numeric OID of the protocol-op control to remove.- Returns:
- This protocol-op.
-
containsControl
Description copied from interface:ProtocolOp
Returnstrue
if this protocol-op contains the specified control.- Specified by:
containsControl
in interfaceProtocolOp
- Parameters:
oid
- The numeric OID of the protocol-op control.- Returns:
true
if this protocol-op contains the specified control.
-
getControl
public final <C extends Control> C getControl(ControlDecoder<C> decoder, DecodeOptions options) throws DecodeException Description copied from interface:ProtocolOp
Decodes and returns the first control in this protocol-op having an OID corresponding to the provided control decoder.- Specified by:
getControl
in interfaceProtocolOp
- Type Parameters:
C
- The type of control to be decoded and returned.- Parameters:
decoder
- The control decoder.options
- The set of decode options which should be used when decoding the control.- Returns:
- The decoded control, or
null
if the control is not included with this protocol-op. - Throws:
DecodeException
- If the control could not be decoded because it was malformed in some way (e.g. the control value was missing, or its content could not be decoded).
-
getControls
Description copied from interface:ProtocolOp
Returns aList
containing the controls included with this protocol-op. The returnedList
may be modified if permitted by this protocol-op.- Specified by:
getControls
in interfaceProtocolOp
- Returns:
- A
List
containing the controls.
-