Search in sources :

Example 61 with Schema

use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.

the class JarLdifSchemaLoader method loadMatchingRules.

/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadMatchingRules(Schema... schemas) throws LdapException, IOException {
    List<Entry> matchingRuleList = new ArrayList<>();
    if (schemas == null) {
        return matchingRuleList;
    }
    for (Schema schema : schemas) {
        String start = getSchemaDirectoryString(schema) + SchemaConstants.MATCHING_RULES_PATH + "/" + "m-oid=";
        String end = "." + LDIF_EXT;
        for (String resourcePath : RESOURCE_MAP.keySet()) {
            if (resourcePath.startsWith(start) && resourcePath.endsWith(end)) {
                URL resource = getResource(resourcePath, "matchingRules LDIF file");
                LdifReader reader = new LdifReader(resource.openStream());
                LdifEntry entry = reader.next();
                reader.close();
                matchingRuleList.add(entry.getEntry());
            }
        }
    }
    return matchingRuleList;
}
Also used : Entry(org.apache.directory.api.ldap.model.entry.Entry) LdifEntry(org.apache.directory.api.ldap.model.ldif.LdifEntry) LdifReader(org.apache.directory.api.ldap.model.ldif.LdifReader) Schema(org.apache.directory.api.ldap.model.schema.registries.Schema) ArrayList(java.util.ArrayList) URL(java.net.URL) LdifEntry(org.apache.directory.api.ldap.model.ldif.LdifEntry)

Example 62 with Schema

use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.

the class JarLdifSchemaLoader method loadDitContentRules.

/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadDitContentRules(Schema... schemas) throws LdapException, IOException {
    List<Entry> ditContentRulesList = new ArrayList<>();
    if (schemas == null) {
        return ditContentRulesList;
    }
    for (Schema schema : schemas) {
        String start = getSchemaDirectoryString(schema) + SchemaConstants.DIT_CONTENT_RULES_PATH + "/" + "m-oid=";
        String end = "." + LDIF_EXT;
        for (String resourcePath : RESOURCE_MAP.keySet()) {
            if (resourcePath.startsWith(start) && resourcePath.endsWith(end)) {
                URL resource = getResource(resourcePath, "ditContentRule LDIF file");
                LdifReader reader = new LdifReader(resource.openStream());
                LdifEntry entry = reader.next();
                reader.close();
                ditContentRulesList.add(entry.getEntry());
            }
        }
    }
    return ditContentRulesList;
}
Also used : Entry(org.apache.directory.api.ldap.model.entry.Entry) LdifEntry(org.apache.directory.api.ldap.model.ldif.LdifEntry) LdifReader(org.apache.directory.api.ldap.model.ldif.LdifReader) Schema(org.apache.directory.api.ldap.model.schema.registries.Schema) ArrayList(java.util.ArrayList) URL(java.net.URL) LdifEntry(org.apache.directory.api.ldap.model.ldif.LdifEntry)

Example 63 with Schema

use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.

the class LdifSchemaLoader method loadSyntaxCheckers.

/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadSyntaxCheckers(Schema... schemas) throws LdapException, IOException {
    List<Entry> syntaxCheckerList = new ArrayList<>();
    if (schemas == null) {
        return syntaxCheckerList;
    }
    for (Schema schema : schemas) {
        File syntaxCheckersDirectory = new File(getSchemaDirectory(schema), SchemaConstants.SYNTAX_CHECKERS_PATH);
        if (!syntaxCheckersDirectory.exists()) {
            return syntaxCheckerList;
        }
        File[] syntaxCheckerFiles = syntaxCheckersDirectory.listFiles(ldifFilter);
        if (syntaxCheckerFiles != null) {
            for (File ldifFile : syntaxCheckerFiles) {
                LdifReader reader = new LdifReader(ldifFile);
                LdifEntry entry = reader.next();
                reader.close();
                syntaxCheckerList.add(entry.getEntry());
            }
        }
    }
    return syntaxCheckerList;
}
Also used : Entry(org.apache.directory.api.ldap.model.entry.Entry) LdifEntry(org.apache.directory.api.ldap.model.ldif.LdifEntry) LdifReader(org.apache.directory.api.ldap.model.ldif.LdifReader) Schema(org.apache.directory.api.ldap.model.schema.registries.Schema) ArrayList(java.util.ArrayList) File(java.io.File) LdifEntry(org.apache.directory.api.ldap.model.ldif.LdifEntry)

Example 64 with Schema

use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.

the class LdifSchemaLoader method loadNormalizers.

/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadNormalizers(Schema... schemas) throws LdapException, IOException {
    List<Entry> normalizerList = new ArrayList<>();
    if (schemas == null) {
        return normalizerList;
    }
    for (Schema schema : schemas) {
        File normalizersDirectory = new File(getSchemaDirectory(schema), SchemaConstants.NORMALIZERS_PATH);
        if (!normalizersDirectory.exists()) {
            return normalizerList;
        }
        File[] normalizerFiles = normalizersDirectory.listFiles(ldifFilter);
        if (normalizerFiles != null) {
            for (File ldifFile : normalizerFiles) {
                LdifReader reader = new LdifReader(ldifFile);
                LdifEntry entry = reader.next();
                reader.close();
                normalizerList.add(entry.getEntry());
            }
        }
    }
    return normalizerList;
}
Also used : Entry(org.apache.directory.api.ldap.model.entry.Entry) LdifEntry(org.apache.directory.api.ldap.model.ldif.LdifEntry) LdifReader(org.apache.directory.api.ldap.model.ldif.LdifReader) Schema(org.apache.directory.api.ldap.model.schema.registries.Schema) ArrayList(java.util.ArrayList) File(java.io.File) LdifEntry(org.apache.directory.api.ldap.model.ldif.LdifEntry)

Example 65 with Schema

use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.

the class LdifSchemaLoader method loadComparators.

/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadComparators(Schema... schemas) throws LdapException, IOException {
    List<Entry> comparatorList = new ArrayList<>();
    if (schemas == null) {
        return comparatorList;
    }
    for (Schema schema : schemas) {
        File comparatorsDirectory = new File(getSchemaDirectory(schema), SchemaConstants.COMPARATORS_PATH);
        if (!comparatorsDirectory.exists()) {
            return comparatorList;
        }
        File[] comparators = comparatorsDirectory.listFiles(ldifFilter);
        if (comparators != null) {
            for (File ldifFile : comparators) {
                LdifReader reader = new LdifReader(ldifFile);
                LdifEntry entry = reader.next();
                reader.close();
                comparatorList.add(entry.getEntry());
            }
        }
    }
    return comparatorList;
}
Also used : Entry(org.apache.directory.api.ldap.model.entry.Entry) LdifEntry(org.apache.directory.api.ldap.model.ldif.LdifEntry) LdifReader(org.apache.directory.api.ldap.model.ldif.LdifReader) Schema(org.apache.directory.api.ldap.model.schema.registries.Schema) ArrayList(java.util.ArrayList) File(java.io.File) LdifEntry(org.apache.directory.api.ldap.model.ldif.LdifEntry)

Aggregations

Schema (org.apache.directory.api.ldap.model.schema.registries.Schema)74 ArrayList (java.util.ArrayList)34 Entry (org.apache.directory.api.ldap.model.entry.Entry)34 DefaultSchema (org.apache.directory.api.ldap.model.schema.registries.DefaultSchema)28 LdifEntry (org.apache.directory.api.ldap.model.ldif.LdifEntry)26 LdifReader (org.apache.directory.api.ldap.model.ldif.LdifReader)25 File (java.io.File)13 SchemaObject (org.apache.directory.api.ldap.model.schema.SchemaObject)13 SchemaObjectWrapper (org.apache.directory.api.ldap.model.schema.SchemaObjectWrapper)13 URL (java.net.URL)12 LdapUnwillingToPerformException (org.apache.directory.api.ldap.model.exception.LdapUnwillingToPerformException)12 DefaultEntry (org.apache.directory.api.ldap.model.entry.DefaultEntry)11 Attribute (org.apache.directory.api.ldap.model.entry.Attribute)9 DefaultAttribute (org.apache.directory.api.ldap.model.entry.DefaultAttribute)9 Registries (org.apache.directory.api.ldap.model.schema.registries.Registries)9 AttributesFactory (org.apache.directory.api.ldap.model.schema.AttributesFactory)8 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)7 DefaultSchemaManager (org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager)7 Test (org.junit.Test)7 SchemaManager (org.apache.directory.api.ldap.model.schema.SchemaManager)6