Search in sources :

Example 31 with SchemaObject

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

the class DefaultSchemaLoader method loadComparators.

/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadComparators(Schema... schemas) throws LdapException, IOException {
    List<Entry> comparatorEntries = new ArrayList<>();
    if (schemas == null) {
        return comparatorEntries;
    }
    for (Schema schema : schemas) {
        Set<SchemaObjectWrapper> schemaObjectWrappers = schema.getContent();
        for (SchemaObjectWrapper schemaObjectWrapper : schemaObjectWrappers) {
            SchemaObject schemaObject = schemaObjectWrapper.get();
            if (schemaObject instanceof LdapComparatorDescription) {
                LdapComparatorDescription ldapComparatorDescription = (LdapComparatorDescription) schemaObject;
                Entry lcEntry = getEntry(ldapComparatorDescription);
                comparatorEntries.add(lcEntry);
            }
        }
    }
    return comparatorEntries;
}
Also used : SchemaObject(org.apache.directory.api.ldap.model.schema.SchemaObject) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) DefaultSchema(org.apache.directory.api.ldap.model.schema.registries.DefaultSchema) Schema(org.apache.directory.api.ldap.model.schema.registries.Schema) ArrayList(java.util.ArrayList) SchemaObjectWrapper(org.apache.directory.api.ldap.model.schema.SchemaObjectWrapper) LdapComparatorDescription(org.apache.directory.api.ldap.model.schema.parsers.LdapComparatorDescription)

Example 32 with SchemaObject

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

the class DefaultSchemaLoader method loadSyntaxCheckers.

/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadSyntaxCheckers(Schema... schemas) throws LdapException, IOException {
    List<Entry> syntaxCheckerEntries = new ArrayList<>();
    if (schemas == null) {
        return syntaxCheckerEntries;
    }
    for (Schema schema : schemas) {
        Set<SchemaObjectWrapper> schemaObjectWrappers = schema.getContent();
        for (SchemaObjectWrapper schemaObjectWrapper : schemaObjectWrappers) {
            SchemaObject schemaObject = schemaObjectWrapper.get();
            if (schemaObject instanceof SyntaxCheckerDescription) {
                SyntaxCheckerDescription syntaxCheckerDescription = (SyntaxCheckerDescription) schemaObject;
                Entry syntaxCheckerEntry = getEntry(syntaxCheckerDescription);
                syntaxCheckerEntries.add(syntaxCheckerEntry);
            }
        }
    }
    return syntaxCheckerEntries;
}
Also used : SchemaObject(org.apache.directory.api.ldap.model.schema.SchemaObject) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) SyntaxCheckerDescription(org.apache.directory.api.ldap.model.schema.parsers.SyntaxCheckerDescription) DefaultSchema(org.apache.directory.api.ldap.model.schema.registries.DefaultSchema) Schema(org.apache.directory.api.ldap.model.schema.registries.Schema) ArrayList(java.util.ArrayList) SchemaObjectWrapper(org.apache.directory.api.ldap.model.schema.SchemaObjectWrapper)

Example 33 with SchemaObject

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

the class DefaultSchemaLoader method loadDitContentRules.

/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadDitContentRules(Schema... schemas) throws LdapException, IOException {
    List<Entry> ditContentRuleEntries = new ArrayList<>();
    if (schemas == null) {
        return ditContentRuleEntries;
    }
    AttributesFactory factory = new AttributesFactory();
    for (Schema schema : schemas) {
        Set<SchemaObjectWrapper> schemaObjectWrappers = schema.getContent();
        for (SchemaObjectWrapper schemaObjectWrapper : schemaObjectWrappers) {
            SchemaObject schemaObject = schemaObjectWrapper.get();
            if (schemaObject instanceof DitContentRule) {
                DitContentRule ditContentRule = (DitContentRule) schemaObject;
                Entry ditContentRuleEntry = factory.convert(ditContentRule, schema, null);
                ditContentRuleEntries.add(ditContentRuleEntry);
            }
        }
    }
    return ditContentRuleEntries;
}
Also used : SchemaObject(org.apache.directory.api.ldap.model.schema.SchemaObject) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) AttributesFactory(org.apache.directory.api.ldap.model.schema.AttributesFactory) DefaultSchema(org.apache.directory.api.ldap.model.schema.registries.DefaultSchema) Schema(org.apache.directory.api.ldap.model.schema.registries.Schema) ArrayList(java.util.ArrayList) SchemaObjectWrapper(org.apache.directory.api.ldap.model.schema.SchemaObjectWrapper) DitContentRule(org.apache.directory.api.ldap.model.schema.DitContentRule)

Example 34 with SchemaObject

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

the class DefaultSchemaManager method deleteSchemaObjects.

/**
 * Delete all the schemaObjects for a given schema from the registries
 */
private void deleteSchemaObjects(Schema schema, Registries registries) throws LdapException {
    Map<String, Set<SchemaObjectWrapper>> schemaObjects = registries.getObjectBySchemaName();
    Set<SchemaObjectWrapper> content = schemaObjects.get(Strings.toLowerCaseAscii(schema.getSchemaName()));
    List<SchemaObject> toBeDeleted = new ArrayList<>();
    if (content != null) {
        // Build an intermediate list to avoid concurrent modifications
        for (SchemaObjectWrapper schemaObjectWrapper : content) {
            toBeDeleted.add(schemaObjectWrapper.get());
        }
        for (SchemaObject schemaObject : toBeDeleted) {
            registries.delete(errors, schemaObject);
        }
    }
}
Also used : SchemaObject(org.apache.directory.api.ldap.model.schema.SchemaObject) LoadableSchemaObject(org.apache.directory.api.ldap.model.schema.LoadableSchemaObject) Set(java.util.Set) HashSet(java.util.HashSet) ArrayList(java.util.ArrayList) SchemaObjectWrapper(org.apache.directory.api.ldap.model.schema.SchemaObjectWrapper)

Example 35 with SchemaObject

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

the class DefaultSchemaManager method copy.

private SchemaObject copy(SchemaObject schemaObject) {
    SchemaObject copy = null;
    if (!(schemaObject instanceof LoadableSchemaObject)) {
        copy = schemaObject.copy();
    } else {
        // Check the schemaObject here.
        if (((LoadableSchemaObject) schemaObject).isValid()) {
            copy = schemaObject;
        } else {
            // We have an invalid SchemaObject, no need to go any further
            Throwable error = new LdapUnwillingToPerformException(ResultCodeEnum.UNWILLING_TO_PERFORM, I18n.err(I18n.ERR_11007, schemaObject.getOid()));
            errors.add(error);
        }
    }
    return copy;
}
Also used : SchemaObject(org.apache.directory.api.ldap.model.schema.SchemaObject) LoadableSchemaObject(org.apache.directory.api.ldap.model.schema.LoadableSchemaObject) LoadableSchemaObject(org.apache.directory.api.ldap.model.schema.LoadableSchemaObject) LdapUnwillingToPerformException(org.apache.directory.api.ldap.model.exception.LdapUnwillingToPerformException)

Aggregations

SchemaObject (org.apache.directory.api.ldap.model.schema.SchemaObject)37 SchemaObjectWrapper (org.apache.directory.api.ldap.model.schema.SchemaObjectWrapper)14 Schema (org.apache.directory.api.ldap.model.schema.registries.Schema)13 ArrayList (java.util.ArrayList)12 DefaultEntry (org.apache.directory.api.ldap.model.entry.DefaultEntry)12 Entry (org.apache.directory.api.ldap.model.entry.Entry)11 DefaultSchema (org.apache.directory.api.ldap.model.schema.registries.DefaultSchema)11 LoadableSchemaObject (org.apache.directory.api.ldap.model.schema.LoadableSchemaObject)10 AttributesFactory (org.apache.directory.api.ldap.model.schema.AttributesFactory)8 ParseException (java.text.ParseException)6 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)4 DitStructureRule (org.apache.directory.api.ldap.model.schema.DitStructureRule)4 LdapSyntax (org.apache.directory.api.ldap.model.schema.LdapSyntax)4 ObjectClass (org.apache.directory.api.ldap.model.schema.ObjectClass)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Map (java.util.Map)3 Set (java.util.Set)3 AttributeType (org.apache.directory.api.ldap.model.schema.AttributeType)3 DitContentRule (org.apache.directory.api.ldap.model.schema.DitContentRule)3