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;
}
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;
}
Aggregations