Modifier and Type | Class and Description |
---|---|
static class |
Entries.DiffStrategy
Defines the available strategy to compute changes.
|
static class |
Entries.ReplaceStrategy
Defines the available strategy to generate changes.
|
Modifier and Type | Field and Description |
---|---|
static Option<AttributeFilter> |
ATTRIBUTE_FILTER
Selects which attributes will be compared.
|
static Option<Entries.DiffStrategy> |
DIFF_STRATEGY
Defines the strategy to use to compute changes.
|
static Option<Entries.ReplaceStrategy> |
REPLACE_STRATEGY
Defines the strategy to use to generate changes.
|
Modifier and Type | Method and Description |
---|---|
static Comparator<Entry> |
compareByName()
Returns a
Comparator which can be used to compare entries by name
using the natural order for DN comparisons (parent before children). |
static boolean |
conformsToSchema(Entry entry,
Schema schema,
SchemaValidationPolicy policy,
Collection<org.forgerock.i18n.LocalizableMessage> errorMessages)
Returns
true if the provided entry is valid according to the
specified schema and schema validation policy. |
static boolean |
conformsToSchema(Entry entry,
SchemaValidationPolicy policy,
Collection<org.forgerock.i18n.LocalizableMessage> errorMessages)
Returns
true if the provided entry is valid according to the
default schema and schema validation policy. |
static boolean |
containsObjectClass(Entry entry,
ObjectClass objectClass)
Check if the provided entry contains the provided object class.
|
static boolean |
containsObjectClass(Entry entry,
Schema schema,
ObjectClass objectClass)
Check if the provided entry contains the provided object class.
|
static ModifyRequest |
diffEntries(Entry fromEntry,
Entry toEntry)
Creates a new modify request containing a list of modifications which can
be used to transform
fromEntry into entry toEntry . |
static ModifyRequest |
diffEntries(Entry fromEntry,
Entry toEntry,
Options options)
Creates a new modify request containing a list of modifications which can
be used to transform
fromEntry into entry toEntry . |
static Set<ObjectClass> |
getObjectClasses(Entry entry)
Returns an unmodifiable set containing the object classes associated with
the provided entry.
|
static Set<ObjectClass> |
getObjectClasses(Entry entry,
Schema schema)
Returns an unmodifiable set containing the object classes associated with
the provided entry.
|
static ObjectClass |
getStructuralObjectClass(Entry entry)
Returns the structural object class associated with the provided entry,
or
null if none was found. |
static ObjectClass |
getStructuralObjectClass(Entry entry,
Schema schema)
Returns the structural object class associated with the provided entry,
or
null if none was found. |
static boolean |
isSubEntry(Entry entry)
Returns whether the provided entry is a sub entry.
|
static List<Entry> |
makeEntries(String... ldifLines)
Builds a list of entries from the provided lines of LDIF.
|
static Entry |
makeEntry(String... ldifLines)
Builds an entry from the provided lines of LDIF.
|
static Entry |
modifyEntry(Entry entry,
Modification change)
Applies the provided modification to an entry.
|
static Entry |
modifyEntry(Entry entry,
Modification change,
Collection<? super ByteString> conflictingValues)
Applies the provided modification to an entry.
|
static Entry |
modifyEntry(Entry entry,
ModifyRequest changes)
Applies the provided modification request to an entry.
|
static Entry |
modifyEntryPermissive(Entry entry,
Collection<Modification> changes)
Applies the provided modifications to an entry using "permissive" modify
semantics.
|
static Entry |
modifyEntryStrict(Entry entry,
Collection<Modification> changes)
Applies the provided modifications to an entry using "strict" modify
semantics.
|
static String |
toLdif(Entry entry)
Returns the LDIF representation of
entry . |
static Entry |
unmodifiableEntry(Entry entry)
Returns a read-only view of
entry and its attributes. |
public static final Option<AttributeFilter> ATTRIBUTE_FILTER
public static final Option<Entries.ReplaceStrategy> REPLACE_STRATEGY
public static final Option<Entries.DiffStrategy> DIFF_STRATEGY
public static Comparator<Entry> compareByName()
Comparator
which can be used to compare entries by name
using the natural order for DN comparisons (parent before children).
In order to sort entries in reverse order (children first) use the following code:
Collections.reverseOrder(Entries.compareByName());For more complex sort orders involving one or more attributes refer to the
SortKey
class.Comparator
.public static boolean conformsToSchema(Entry entry, Schema schema, SchemaValidationPolicy policy, Collection<org.forgerock.i18n.LocalizableMessage> errorMessages)
true
if the provided entry is valid according to the
specified schema and schema validation policy.
If attribute value validation is enabled then following checks will be performed:
entry
- The entry to be validated.schema
- The schema against which the entry will be validated.policy
- The schema validation policy.errorMessages
- A collection into which any schema validation warnings or
error messages can be placed, or null
if they should
not be saved.true
if the provided entry is valid according to the
specified schema and schema validation policy.Schema.validateEntry(Entry, SchemaValidationPolicy, Collection)
public static boolean conformsToSchema(Entry entry, SchemaValidationPolicy policy, Collection<org.forgerock.i18n.LocalizableMessage> errorMessages)
true
if the provided entry is valid according to the
default schema and schema validation policy.
If attribute value validation is enabled then following checks will be performed:
entry
- The entry to be validated.policy
- The schema validation policy.errorMessages
- A collection into which any schema validation warnings or
error messages can be placed, or null
if they should
not be saved.true
if the provided entry is valid according to the
default schema and schema validation policy.Schema.validateEntry(Entry, SchemaValidationPolicy, Collection)
public static boolean containsObjectClass(Entry entry, ObjectClass objectClass)
This method uses the default schema for decoding the object class attribute values.
The provided object class must be recognized by the schema, otherwise the method returns false.
entry
- The entry which is checked against the object class.objectClass
- The object class to check.true
if and only if entry contains the object class and
the object class is recognized by the default schema,
false
otherwisepublic static boolean containsObjectClass(Entry entry, Schema schema, ObjectClass objectClass)
The provided object class must be recognized by the provided schema, otherwise the method returns false.
entry
- The entry which is checked against the object class.schema
- The schema which should be used for decoding the object class
attribute values.objectClass
- The object class to check.true
if and only if entry contains the object class and
the object class is recognized by the provided schema,
false
otherwisepublic static ModifyRequest diffEntries(Entry fromEntry, Entry toEntry)
fromEntry
into entry toEntry
.
The changes will be generated using a default set of options
. More specifically, only user attributes will be compared,
attributes will be compared using their matching rules, and all generated
changes will be reversible: it will contain only modifications of type
DELETE
then ADD
.
Finally, the modify request will use the distinguished name taken from
fromEntry
. This method will not check to see if both
fromEntry
and toEntry
have the same distinguished name.
This method is equivalent to:
ModifyRequest request = Requests.newModifyRequest(fromEntry, toEntry);Or:
ModifyRequest request = diffEntries(fromEntry, toEntry, Options.defaultOptions());
fromEntry
- The source entry.toEntry
- The destination entry.fromEntry
into entry toEntry
.
The returned request will always be non-null
but may not
contain any modifications.NullPointerException
- If fromEntry
or toEntry
were null
.Requests.newModifyRequest(Entry, Entry)
public static ModifyRequest diffEntries(Entry fromEntry, Entry toEntry, Options options)
fromEntry
into entry toEntry
.
The changes will be generated using the provided set of Options
.
Finally, the modify request will use the distinguished name taken from
fromEntry
. This method will not check to see if both
fromEntry
and toEntry
have the same distinguished name.
fromEntry
- The source entry.toEntry
- The destination entry.options
- The set of options which will control which attributes are
compared, how they are compared, and the type of modifications
generated.fromEntry
into entry toEntry
.
The returned request will always be non-null
but may not
contain any modifications.NullPointerException
- If fromEntry
, toEntry
, or options
were null
.public static Set<ObjectClass> getObjectClasses(Entry entry)
This method uses the default schema for decoding the object class attribute values.
entry
- The entry whose object classes are required.public static Set<ObjectClass> getObjectClasses(Entry entry, Schema schema)
entry
- The entry whose object classes are required.schema
- The schema which should be used for decoding the object class
attribute values.public static ObjectClass getStructuralObjectClass(Entry entry)
null
if none was found. If the entry contains multiple
structural object classes then the first will be returned. This method
will ignore unrecognized object classes.
This method uses the default schema for decoding the object class attribute values.
entry
- The entry whose structural object class is required.null
if none was found.public static boolean isSubEntry(Entry entry)
entry
- The entry to be checked.true
if the entry is a sub entry, false
otherwise.public static Entry makeEntry(String... ldifLines)
Sample usage:
Entry john = makeEntry( "dn: cn=John Smith,dc=example,dc=com", "objectclass: inetorgperson", "cn: John Smith", "sn: Smith", "givenname: John");
ldifLines
- LDIF lines that contains entry definition.org.forgerock.i18n.LocalizedIllegalArgumentException
- If ldifLines
did not contain an LDIF entry, or
contained multiple entries, or contained malformed LDIF, or
if the entry could not be decoded using the default schema.NullPointerException
- If ldifLines
was null
.public static List<Entry> makeEntries(String... ldifLines)
Sample usage:
List<Entry> smiths = TestCaseUtils.makeEntries( "dn: cn=John Smith,dc=example,dc=com", "objectclass: inetorgperson", "cn: John Smith", "sn: Smith", "givenname: John", "", "dn: cn=Jane Smith,dc=example,dc=com", "objectclass: inetorgperson", "cn: Jane Smith", "sn: Smith", "givenname: Jane");
ldifLines
- LDIF lines that contains entries definition.
Entries are separated by an empty string: ""
.org.forgerock.i18n.LocalizedIllegalArgumentException
- If ldifLines
did not contain LDIF entries,
or contained malformed LDIF, or if the entries
could not be decoded using the default schema.NullPointerException
- If ldifLines
was null
.public static ObjectClass getStructuralObjectClass(Entry entry, Schema schema)
null
if none was found. If the entry contains multiple
structural object classes then the first will be returned. This method
will ignore unrecognized object classes.entry
- The entry whose structural object class is required.schema
- The schema which should be used for decoding the object class
attribute values.null
if none was found.public static Entry modifyEntry(Entry entry, Modification change) throws LdapException
entry
- The entry to be modified.change
- The modification to be applied to the entry.LdapException
- If an error occurred while performing the change such as an
attempt to increment a value which is not a number. The entry
will not have been modified.public static Entry modifyEntry(Entry entry, Modification change, Collection<? super ByteString> conflictingValues) throws LdapException
entry
- The entry to be modified.change
- The modification to be applied to the entry.conflictingValues
- A collection into which duplicate or missing values will be
added, or null
if conflicting values should not be
saved.LdapException
- If an error occurred while performing the change such as an
attempt to increment a value which is not a number. The entry
will not have been modified.public static Entry modifyEntry(Entry entry, ModifyRequest changes) throws LdapException
PermissiveModifyRequestControl
.entry
- The entry to be modified.changes
- The modification request to be applied to the entry.LdapException
- If an error occurred while performing the changes such as an
attempt to add duplicate values, remove values which do not
exist, or increment a value which is not a number. The entry
may have been modified.public static Entry modifyEntryPermissive(Entry entry, Collection<Modification> changes) throws LdapException
entry
- The entry to be modified.changes
- The modification request to be applied to the entry.LdapException
- If an error occurred while performing the changes such as an
attempt to increment a value which is not a number. The entry
may have been modified.public static Entry modifyEntryStrict(Entry entry, Collection<Modification> changes) throws LdapException
entry
- The entry to be modified.changes
- The modification request to be applied to the entry.LdapException
- If an error occurred while performing the changes such as an
attempt to add duplicate values, remove values which do not
exist, or increment a value which is not a number. The entry
may have been modified.public static String toLdif(Entry entry)
entry
. All attributes will be included and no wrapping will be
performed. This method can be useful when debugging applications.entry
- The entry to be converted to LDIF.entry
.public static Entry unmodifiableEntry(Entry entry)
entry
and its attributes. Query
operations on the returned entry and its attributes "read-through" to the
underlying entry or attribute, and attempts to modify the returned entry
and its attributes either directly or indirectly via an iterator result
in an UnsupportedOperationException
.entry
- The entry for which a read-only view is to be returned.entry
.NullPointerException
- If entry
was null
.Copyright 2011-2017 ForgeRock AS.