Search in sources :

Example 1 with EntryReader

use of org.forgerock.opendj.ldif.EntryReader in project OpenAM by OpenRock.

the class OpenDJUpgrader method findBaseDNs.

private List<DN> findBaseDNs() throws IOException {
    final List<DN> baseDNs = new LinkedList<DN>();
    final SearchRequest request = LDAPRequests.newSearchRequest("cn=backends,cn=config", SearchScope.WHOLE_SUBTREE, "(objectclass=ds-cfg-backend)", "ds-cfg-base-dn");
    try (LDIFEntryReader reader = new LDIFEntryReader(new FileInputStream(installRoot + "/config/config.ldif"))) {
        final EntryReader filteredReader = LDIF.search(reader, request);
        while (filteredReader.hasNext()) {
            final Entry entry = filteredReader.readEntry();
            final Attribute values = entry.getAttribute("ds-cfg-base-dn");
            if (values != null) {
                for (final ByteString value : values) {
                    baseDNs.add(DN.valueOf(value.toString()));
                }
            }
        }
    }
    return baseDNs;
}
Also used : SearchRequest(org.forgerock.opendj.ldap.requests.SearchRequest) EntryReader(org.forgerock.opendj.ldif.EntryReader) LDIFEntryReader(org.forgerock.opendj.ldif.LDIFEntryReader) ZipEntry(java.util.zip.ZipEntry) Entry(org.forgerock.opendj.ldap.Entry) LDIFEntryReader(org.forgerock.opendj.ldif.LDIFEntryReader) Attribute(org.forgerock.opendj.ldap.Attribute) ByteString(org.forgerock.opendj.ldap.ByteString) DN(org.forgerock.opendj.ldap.DN) LinkedList(java.util.LinkedList) FileInputStream(java.io.FileInputStream)

Aggregations

FileInputStream (java.io.FileInputStream)1 LinkedList (java.util.LinkedList)1 ZipEntry (java.util.zip.ZipEntry)1 Attribute (org.forgerock.opendj.ldap.Attribute)1 ByteString (org.forgerock.opendj.ldap.ByteString)1 DN (org.forgerock.opendj.ldap.DN)1 Entry (org.forgerock.opendj.ldap.Entry)1 SearchRequest (org.forgerock.opendj.ldap.requests.SearchRequest)1 EntryReader (org.forgerock.opendj.ldif.EntryReader)1 LDIFEntryReader (org.forgerock.opendj.ldif.LDIFEntryReader)1