Class Ldif
-
Method Summary
Modifier and TypeMethodDescriptionstatic ChangeRecordWriter
copyTo
(ChangeRecordReader input, ChangeRecordWriter output) Copies the content ofinput
tooutput
.static EntryWriter
copyTo
(EntryReader input, EntryWriter output) Copies the content ofinput
tooutput
.static ChangeRecordReader
diff
(EntryReader source, EntryReader target) Compares the content ofsource
to the content oftarget
and returns the differences in a change record reader.static ChangeRecordReader
diff
(EntryReader source, EntryReader target, Options options) Compares the content ofsource
to the content oftarget
and returns the differences in a change record reader.static ChangeRecord
makeChangeRecord
(String... ldifLines) Parses the provided array of LDIF lines as a single LDIF change record.makeEntries
(String... ldifLines) Builds a list of entries from the provided lines of LDIF.makeEntries
(List<String> ldifLines) Builds a list of entries from the provided lines of LDIF.static Entry
Builds an entry from the provided lines of LDIF.static Entry
Builds an entry from the provided lines of LDIF.static Flowable<ChangeRecord>
newChangeRecordPublisher
(Supplier<? extends ChangeRecordReader> factory) Returns aFlowable
view of aChangeRecordReader
, creating a new reader for each subscriber.static ChangeRecordReader
newChangeRecordReader
(Iterable<? extends ChangeRecord> changes) Returns a change record reader over the provided change record collection.static ChangeRecordReader
newChangeRecordReader
(Iterator<? extends ChangeRecord> changes) Returns a change record reader over the provided change record iterator.newEntryPublisher
(Supplier<? extends EntryReader> factory) Returns aFlowable
view of aEntryReader
, creating a new reader for each subscriber.static EntryReader
newEntryReader
(Iterable<? extends Entry> entries) Returns an entry reader over the provided entry collection.static EntryReader
newEntryReader
(Iterator<? extends Entry> entries) Returns an entry reader over the provided entry iterator.static EntryReader
patch
(EntryReader input, ChangeRecordReader patch) Applies the set of changes contained inpatch
to the content ofinput
and returns the result in an entry reader.static EntryReader
patch
(EntryReader input, ChangeRecordReader patch, RejectedChangeRecordListener listener) Applies the set of changes contained inpatch
to the content ofinput
and returns the result in an entry reader.static EntryReader
search
(EntryReader input, SearchRequest search) Returns a filtered view ofinput
containing only those entries which match the search base DN, scope, and filtered defined insearch
.static EntryReader
search
(EntryReader input, SearchRequest search, Schema schema) Returns a filtered view ofinput
containing only those entries which match the search base DN, scope, and filtered defined insearch
.static String
Returns the LDIF representation ofentry
.static String
toLdif
(ChangeRecord change) Returns the LDIF representation ofchange
.
-
Method Details
-
newChangeRecordPublisher
public static Flowable<ChangeRecord> newChangeRecordPublisher(Supplier<? extends ChangeRecordReader> factory) Returns aFlowable
view of aChangeRecordReader
, creating a new reader for each subscriber.- Parameters:
factory
- The factory which will be invoked for each subscriber.- Returns:
- The
Flowable
view of aChangeRecordReader
.
-
newEntryPublisher
Returns aFlowable
view of aEntryReader
, creating a new reader for each subscriber.- Parameters:
factory
- The factory which will be invoked for each subscriber.- Returns:
- The
Flowable
view of aEntryReader
.
-
copyTo
public static ChangeRecordWriter copyTo(ChangeRecordReader input, ChangeRecordWriter output) throws IOException Copies the content ofinput
tooutput
. This method does not closeinput
oroutput
.- Parameters:
input
- The input change record reader.output
- The output change record reader.- Returns:
- The output change record reader.
- Throws:
IOException
- If an unexpected IO error occurred.
-
copyTo
Copies the content ofinput
tooutput
. This method does not closeinput
oroutput
.- Parameters:
input
- The input entry reader.output
- The output entry reader.- Returns:
- The output entry reader.
- Throws:
IOException
- If an unexpected IO error occurred.
-
diff
Compares the content ofsource
to the content oftarget
and returns the differences in a change record reader. Closing the returned reader will causesource
andtarget
to be closed as well.NOTE: this method reads the content of
source
andtarget
into memory before calculating the differences, and is therefore not suited for use in cases where a very large number of entries are to be compared.- Parameters:
source
- The entry reader containing the source entries to be compared.target
- The entry reader containing the target entries to be compared.- Returns:
- A change record reader containing the differences.
- Throws:
IOException
- If an unexpected IO error occurred.
-
diff
public static ChangeRecordReader diff(EntryReader source, EntryReader target, Options options) throws IOException Compares the content ofsource
to the content oftarget
and returns the differences in a change record reader. Closing the returned reader will causesource
andtarget
to be closed as well.NOTE: this method reads the content of
source
andtarget
into memory before calculating the differences, and is therefore not suited for use in cases where a very large number of entries are to be compared.- Parameters:
source
- The entry reader containing the source entries to be compared.target
- The entry reader containing the target entries to be compared.options
- Options to control how entries are compared.- Returns:
- A change record reader containing the differences.
- Throws:
IOException
- If an unexpected IO error occurred.
-
makeEntry
Builds an entry from the provided lines of LDIF.Sample usage:
Entry john = makeEntry( "dn: cn=John Smith,dc=example,dc=com", "objectclass: inetorgperson", "cn: John Smith", "sn: Smith", "givenname: John");
- Parameters:
ldifLines
- LDIF lines that contains entry definition.- Returns:
- an entry
- Throws:
LocalizedIllegalArgumentException
- IfldifLines
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
- IfldifLines
wasnull
.
-
makeEntry
Builds an entry from the provided lines of LDIF.- Parameters:
ldifLines
- LDIF lines that contains entry definition.- Returns:
- an entry
- Throws:
LocalizedIllegalArgumentException
- IfldifLines
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
- IfldifLines
wasnull
.- See Also:
-
makeEntries
Builds a list of entries from the provided lines of LDIF.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");
- Parameters:
ldifLines
- LDIF lines that contains entries definition. Entries are separated by an empty string:""
.- Returns:
- a non empty list of entries
- Throws:
LocalizedIllegalArgumentException
- IfldifLines
did not contain LDIF entries, or contained malformed LDIF, or if the entries could not be decoded using the default schema.NullPointerException
- IfldifLines
wasnull
.
-
makeEntries
Builds a list of entries from the provided lines of LDIF.- Parameters:
ldifLines
- LDIF lines that contains entries definition. Entries are separated by an empty string:""
.- Returns:
- a non empty list of entries
- Throws:
LocalizedIllegalArgumentException
- IfldifLines
did not contain LDIF entries, or contained malformed LDIF, or if the entries could not be decoded using the default schema.NullPointerException
- IfldifLines
wasnull
.- See Also:
-
newChangeRecordReader
Returns a change record reader over the provided change record collection.- Parameters:
changes
- The change record collection.- Returns:
- A change record reader over the provided change record collection.
-
newChangeRecordReader
Returns a change record reader over the provided change record iterator.- Parameters:
changes
- The change record collection.- Returns:
- A change record reader over the provided change record iterator.
-
newEntryReader
Returns an entry reader over the provided entry collection.- Parameters:
entries
- The entry collection.- Returns:
- An entry reader over the provided entry collection.
-
newEntryReader
Returns an entry reader over the provided entry iterator.- Parameters:
entries
- The entry iterator.- Returns:
- An entry reader over the provided entry iterator.
-
patch
Applies the set of changes contained inpatch
to the content ofinput
and returns the result in an entry reader. This method ignores missing entries, and overwrites existing entries. Closing the returned reader will causeinput
andpatch
to be closed as well.NOTE: this method reads the content of
input
into memory before applying the changes, and is therefore not suited for use in cases where a very large number of entries are to be patched.NOTE: this method will not perform modifications required in order to maintain referential integrity. In particular, if an entry references another entry using a DN valued attribute and the referenced entry is deleted, then the DN reference will not be removed. The same applies to renamed entries and their references.
- Parameters:
input
- The entry reader containing the set of entries to be patched.patch
- The change record reader containing the set of changes to be applied.- Returns:
- An entry reader containing the patched entries.
- Throws:
IOException
- If an unexpected IO error occurred.
-
patch
public static EntryReader patch(EntryReader input, ChangeRecordReader patch, RejectedChangeRecordListener listener) throws IOException Applies the set of changes contained inpatch
to the content ofinput
and returns the result in an entry reader. Closing the returned reader will causeinput
andpatch
to be closed as well.NOTE: this method reads the content of
input
into memory before applying the changes, and is therefore not suited for use in cases where a very large number of entries are to be patched.NOTE: this method will not perform modifications required in order to maintain referential integrity. In particular, if an entry references another entry using a DN valued attribute and the referenced entry is deleted, then the DN reference will not be removed. The same applies to renamed entries and their references.
- Parameters:
input
- The entry reader containing the set of entries to be patched.patch
- The change record reader containing the set of changes to be applied.listener
- The rejected change listener.- Returns:
- An entry reader containing the patched entries.
- Throws:
IOException
- If an unexpected IO error occurred.
-
search
Returns a filtered view ofinput
containing only those entries which match the search base DN, scope, and filtered defined insearch
. In addition, returned entries will be filtered according to any attribute filtering criteria defined in the search request.The filter and attribute descriptions will be decoded using the default schema.
- Parameters:
input
- The entry reader containing the set of entries to be filtered.search
- The search request defining the filtering criteria.- Returns:
- A filtered view of
input
containing only those entries which match the provided search request.
-
search
Returns a filtered view ofinput
containing only those entries which match the search base DN, scope, and filtered defined insearch
. In addition, returned entries will be filtered according to any attribute filtering criteria defined in the search request.The filter and attribute descriptions will be decoded using the provided schema.
- Parameters:
input
- The entry reader containing the set of entries to be filtered.search
- The search request defining the filtering criteria.schema
- The schema which should be used to decode the search filter and attribute descriptions.- Returns:
- A filtered view of
input
containing only those entries which match the provided search request.
-
toLdif
Returns the LDIF representation ofentry
. All attributes will be included and no wrapping will be performed. This method can be useful when debugging applications.- Parameters:
entry
- The entry to be converted to LDIF.- Returns:
- The LDIF representation of
entry
.
-
toLdif
Returns the LDIF representation ofchange
. No wrapping will be performed. This method can be useful when debugging applications.- Parameters:
change
- The change record to be converted to LDIF.- Returns:
- The LDIF representation of
change
.
-
makeChangeRecord
Parses the provided array of LDIF lines as a single LDIF change record.This method is tolerant to missing change types.
- Parameters:
ldifLines
- The lines of LDIF to be parsed.- Returns:
- The parsed LDIF change record.
- Throws:
LocalizedIllegalArgumentException
- IfldifLines
did not contain an LDIF change record, if it contained multiple change records, if contained malformed LDIF, or if the change record could not be decoded using the default schema.NullPointerException
- IfldifLines
wasnull
.
-