Search in sources :

Example 11 with Registries

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

the class DefaultSchemaManager method unload.

/**
 * {@inheritDoc}
 */
@Override
public boolean unload(Schema... schemas) throws LdapException {
    boolean unloaded = false;
    // Reset the errors if not null
    if (errors != null) {
        errors.clear();
    }
    // Work on a cloned and relaxed registries
    Registries clonedRegistries = cloneRegistries();
    clonedRegistries.setRelaxed();
    // Load the schemas
    for (Schema schema : schemas) {
        unload(clonedRegistries, schema);
    }
    // Build the cross references
    errors = clonedRegistries.buildReferences();
    if (errors.isEmpty()) {
        // Ok no errors. Check the registries now
        errors = clonedRegistries.checkRefInteg();
        if (errors.isEmpty()) {
            // We are golden : let's apply the schema in the real registries
            registries.setRelaxed();
            // Load the schemas
            for (Schema schema : schemas) {
                unload(registries, schema);
                // Update the schema dependences
                for (String dep : schema.getDependencies()) {
                    Set<String> deps = schemaDependencies.get(dep);
                    if (deps != null) {
                        deps.remove(schema.getSchemaName());
                    }
                }
                schemaMap.remove(schema.getSchemaName());
            }
            // Build the cross references
            errors = registries.buildReferences();
            registries.setStrict();
            unloaded = true;
        }
    }
    // clear the cloned registries
    clonedRegistries.clear();
    return unloaded;
}
Also used : Schema(org.apache.directory.api.ldap.model.schema.registries.Schema) Registries(org.apache.directory.api.ldap.model.schema.registries.Registries)

Example 12 with Registries

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

the class DefaultSchemaManager method disable.

// -----------------------------------------------------------------------
// API methods
// -----------------------------------------------------------------------
/**
 * {@inheritDoc}
 */
@Override
public boolean disable(Schema... schemas) throws LdapException {
    boolean disabled = false;
    // Reset the errors if not null
    if (errors != null) {
        errors.clear();
    }
    // Work on a cloned and relaxed registries
    Registries clonedRegistries = cloneRegistries();
    clonedRegistries.setRelaxed();
    for (Schema schema : schemas) {
        unload(clonedRegistries, schema);
    }
    // Build the cross references
    errors = clonedRegistries.buildReferences();
    // Destroy the clonedRegistry
    clonedRegistries.clear();
    if (errors.isEmpty()) {
        // Ok no errors. Check the registries now
        errors = clonedRegistries.checkRefInteg();
        if (errors.isEmpty()) {
            // We are golden : let's apply the schemas in the real registries
            for (Schema schema : schemas) {
                unload(registries, schema);
                schema.disable();
            }
            // Build the cross references
            errors = registries.buildReferences();
            registries.setStrict();
            disabled = true;
        }
    }
    // clear the cloned registries
    clonedRegistries.clear();
    return disabled;
}
Also used : Schema(org.apache.directory.api.ldap.model.schema.registries.Schema) Registries(org.apache.directory.api.ldap.model.schema.registries.Registries)

Aggregations

Registries (org.apache.directory.api.ldap.model.schema.registries.Registries)12 Schema (org.apache.directory.api.ldap.model.schema.registries.Schema)9 LdapOtherException (org.apache.directory.api.ldap.model.exception.LdapOtherException)5 LdapProtocolErrorException (org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException)3 SchemaObject (org.apache.directory.api.ldap.model.schema.SchemaObject)3 IOException (java.io.IOException)2 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)2 LdapSchemaException (org.apache.directory.api.ldap.model.exception.LdapSchemaException)2 LoadableSchemaObject (org.apache.directory.api.ldap.model.schema.LoadableSchemaObject)2 ConnectException (java.net.ConnectException)1 UnresolvedAddressException (java.nio.channels.UnresolvedAddressException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 DecoderException (org.apache.directory.api.asn1.DecoderException)1 MessageEncoderException (org.apache.directory.api.ldap.codec.api.MessageEncoderException)1 CursorException (org.apache.directory.api.ldap.model.cursor.CursorException)1 DefaultAttribute (org.apache.directory.api.ldap.model.entry.DefaultAttribute)1 DefaultEntry (org.apache.directory.api.ldap.model.entry.DefaultEntry)1 Value (org.apache.directory.api.ldap.model.entry.Value)1 LdapAuthenticationException (org.apache.directory.api.ldap.model.exception.LdapAuthenticationException)1