Search in sources :

Example 21 with SchemaObject

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

the class Registries method delete.

/**
 * Remove the given SchemaObject from the registries
 *
 * @param errors The list of collected errors
 * @param schemaObject The SchemaObject to delete
 * @return The list of errors
 * @throws LdapException If the deletion failed
 */
public List<Throwable> delete(List<Throwable> errors, SchemaObject schemaObject) throws LdapException {
    // Relax the registries
    boolean wasRelaxed = isRelaxed;
    setRelaxed();
    // Remove the SchemaObject from the registries
    SchemaObject removed = unregister(errors, schemaObject);
    // Remove the SchemaObject from its schema
    dissociateFromSchema(errors, removed);
    // Unlink the SchemaObject references
    removeReference(errors, removed);
    if (errors.isEmpty()) {
        // Check the registries now
        List<Throwable> checkErrors = checkRefInteg();
        errors.addAll(checkErrors);
    }
    // Restore the previous registries state
    if (!wasRelaxed) {
        setStrict();
    }
    // return the errors
    return errors;
}
Also used : SchemaObject(org.apache.directory.api.ldap.model.schema.SchemaObject) LoadableSchemaObject(org.apache.directory.api.ldap.model.schema.LoadableSchemaObject)

Example 22 with SchemaObject

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

the class DefaultNormalizerRegistry method unregisterSchemaElements.

/**
 * {@inheritDoc}
 */
@Override
public void unregisterSchemaElements(String schemaName) throws LdapException {
    if (schemaName == null) {
        return;
    }
    // with the give schemaName
    for (Normalizer normalizer : this) {
        if (schemaName.equalsIgnoreCase(normalizer.getSchemaName())) {
            String oid = normalizer.getOid();
            SchemaObject removed = unregister(oid);
            if (DEBUG) {
                LOG.debug(I18n.msg(I18n.MSG_13702_REMOVED_FROM_REGISTRY, removed, oid));
            }
        }
    }
}
Also used : SchemaObject(org.apache.directory.api.ldap.model.schema.SchemaObject) Normalizer(org.apache.directory.api.ldap.model.schema.Normalizer)

Example 23 with SchemaObject

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

the class DefaultObjectClassRegistry method clear.

/**
 * {@inheritDoc}
 */
@Override
public void clear() {
    // Clear the contained SchemaObjects
    for (SchemaObject objectClass : oidRegistry) {
        objectClass.clear();
    }
    // First clear the shared elements
    super.clear();
    // and clear the descendant
    for (Map.Entry<String, Set<ObjectClass>> entry : oidToDescendants.entrySet()) {
        Set<ObjectClass> descendants = entry.getValue();
        if (descendants != null) {
            descendants.clear();
        }
    }
    oidToDescendants.clear();
}
Also used : SchemaObject(org.apache.directory.api.ldap.model.schema.SchemaObject) HashSet(java.util.HashSet) Set(java.util.Set) ObjectClass(org.apache.directory.api.ldap.model.schema.ObjectClass) Map(java.util.Map) HashMap(java.util.HashMap)

Example 24 with SchemaObject

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

the class DefaultDitStructureRuleRegistry method unregisterSchemaElements.

/**
 * {@inheritDoc}
 */
@Override
public void unregisterSchemaElements(String schemaName) {
    if (schemaName == null) {
        return;
    }
    // with the give schemaName
    for (DitStructureRule ditStructureRule : this) {
        if (schemaName.equalsIgnoreCase(ditStructureRule.getSchemaName())) {
            int ruleId = ditStructureRule.getRuleId();
            SchemaObject removed = byRuleId.remove(ruleId);
            if (DEBUG) {
                LOG.debug("Removed {} with ruleId {} from the registry", removed, ruleId);
            }
        }
    }
}
Also used : SchemaObject(org.apache.directory.api.ldap.model.schema.SchemaObject) DitStructureRule(org.apache.directory.api.ldap.model.schema.DitStructureRule)

Example 25 with SchemaObject

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

the class SchemaParserTestUtils method testQuirksMode.

/**
 * Tests quirks mode.
 */
public static void testQuirksMode(AbstractSchemaParser parser, String required) throws ParseException {
    try {
        String value = null;
        SchemaObject asd = null;
        parser.setQuirksMode(true);
        // alphanum OID
        value = "( abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789 " + required + " )";
        asd = parser.parse(value);
        assertEquals("abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789", asd.getOid());
        // start with hypen
        value = "( -oid " + required + " )";
        asd = parser.parse(value);
        assertEquals("-oid", asd.getOid());
        // start with number
        value = "( 1oid " + required + " )";
        asd = parser.parse(value);
        assertEquals("1oid", asd.getOid());
        // start with dot
        value = "( .oid " + required + " )";
        asd = parser.parse(value);
        assertEquals(".oid", asd.getOid());
    } finally {
        parser.setQuirksMode(false);
    }
}
Also used : SchemaObject(org.apache.directory.api.ldap.model.schema.SchemaObject)

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