Search in sources :

Example 21 with Schema

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

the class JarLdifSchemaLoader method loadDitStructureRules.

/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadDitStructureRules(Schema... schemas) throws LdapException, IOException {
    List<Entry> ditStructureRuleList = new ArrayList<>();
    if (schemas == null) {
        return ditStructureRuleList;
    }
    for (Schema schema : schemas) {
        String start = getSchemaDirectoryString(schema) + SchemaConstants.DIT_STRUCTURE_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, "ditStructureRule LDIF file");
                LdifReader reader = new LdifReader(resource.openStream());
                LdifEntry entry = reader.next();
                reader.close();
                ditStructureRuleList.add(entry.getEntry());
            }
        }
    }
    return ditStructureRuleList;
}
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 22 with Schema

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

the class JarLdifSchemaLoader method loadMatchingRuleUses.

/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadMatchingRuleUses(Schema... schemas) throws LdapException, IOException {
    List<Entry> matchingRuleUseList = new ArrayList<>();
    if (schemas == null) {
        return matchingRuleUseList;
    }
    for (Schema schema : schemas) {
        String start = getSchemaDirectoryString(schema) + SchemaConstants.MATCHING_RULE_USE_PATH + "/" + "m-oid=";
        String end = "." + LDIF_EXT;
        for (String resourcePath : RESOURCE_MAP.keySet()) {
            if (resourcePath.startsWith(start) && resourcePath.endsWith(end)) {
                URL resource = getResource(resourcePath, "matchingRuleUse LDIF file");
                LdifReader reader = new LdifReader(resource.openStream());
                LdifEntry entry = reader.next();
                reader.close();
                matchingRuleUseList.add(entry.getEntry());
            }
        }
    }
    return matchingRuleUseList;
}
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 23 with Schema

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

the class JarLdifSchemaLoader 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) {
        String start = getSchemaDirectoryString(schema) + SchemaConstants.NORMALIZERS_PATH + "/" + "m-oid=";
        String end = "." + LDIF_EXT;
        for (String resourcePath : RESOURCE_MAP.keySet()) {
            if (resourcePath.startsWith(start) && resourcePath.endsWith(end)) {
                URL resource = getResource(resourcePath, "normalizer LDIF file");
                LdifReader reader = new LdifReader(resource.openStream());
                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) URL(java.net.URL) LdifEntry(org.apache.directory.api.ldap.model.ldif.LdifEntry)

Example 24 with Schema

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

the class LdifSchemaLoader method loadAttributeTypes.

/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadAttributeTypes(Schema... schemas) throws LdapException, IOException {
    List<Entry> attributeTypeList = new ArrayList<>();
    if (schemas == null) {
        return attributeTypeList;
    }
    for (Schema schema : schemas) {
        // check that the attributeTypes directory exists for the schema
        File attributeTypesDirectory = new File(getSchemaDirectory(schema), SchemaConstants.ATTRIBUTE_TYPES_PATH);
        if (!attributeTypesDirectory.exists()) {
            return attributeTypeList;
        }
        // get list of attributeType LDIF schema files in attributeTypes
        File[] attributeTypeFiles = attributeTypesDirectory.listFiles(ldifFilter);
        if (attributeTypeFiles != null) {
            for (File ldifFile : attributeTypeFiles) {
                LdifReader reader = new LdifReader(ldifFile);
                LdifEntry entry = reader.next();
                reader.close();
                attributeTypeList.add(entry.getEntry());
            }
        }
    }
    return attributeTypeList;
}
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 25 with Schema

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

the class LdifSchemaLoader method loadDitStructureRules.

/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadDitStructureRules(Schema... schemas) throws LdapException, IOException {
    List<Entry> ditStructureRuleList = new ArrayList<>();
    if (schemas == null) {
        return ditStructureRuleList;
    }
    for (Schema schema : schemas) {
        File ditStructureRulesDirectory = new File(getSchemaDirectory(schema), SchemaConstants.DIT_STRUCTURE_RULES_PATH);
        if (!ditStructureRulesDirectory.exists()) {
            return ditStructureRuleList;
        }
        File[] ditStructureRuleFiles = ditStructureRulesDirectory.listFiles(ldifFilter);
        if (ditStructureRuleFiles != null) {
            for (File ldifFile : ditStructureRuleFiles) {
                LdifReader reader = new LdifReader(ldifFile);
                LdifEntry entry = reader.next();
                reader.close();
                ditStructureRuleList.add(entry.getEntry());
            }
        }
    }
    return ditStructureRuleList;
}
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)73 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)27 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