use of org.apache.directory.api.ldap.model.schema.registries.Schema 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;
}
use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.
the class MatchingRuleTest method setup.
@BeforeClass
public static void setup() throws Exception {
workingDirectory = System.getProperty("workingDirectory");
if (workingDirectory == null) {
String path = MatchingRuleTest.class.getResource("").getPath();
int targetPos = path.indexOf("target");
workingDirectory = path.substring(0, targetPos + 6);
}
schemaRepository = new File(workingDirectory, "schema");
// Cleanup the target directory
FileUtils.deleteDirectory(schemaRepository);
SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(new File(workingDirectory));
extractor.extractOrCopy();
LdifSchemaLoader loader = new LdifSchemaLoader(schemaRepository);
schemaManager = new DefaultSchemaManager(loader);
for (Schema schema : loader.getAllSchemas()) {
schema.enable();
}
schemaManager.loadAllEnabled();
}
use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.
the class JarLdifSchemaLoader method loadSyntaxes.
/**
* {@inheritDoc}
*/
@Override
public List<Entry> loadSyntaxes(Schema... schemas) throws LdapException, IOException {
List<Entry> syntaxList = new ArrayList<>();
if (schemas == null) {
return syntaxList;
}
for (Schema schema : schemas) {
String start = getSchemaDirectoryString(schema) + SchemaConstants.SYNTAXES_PATH + "/" + "m-oid=";
String end = "." + LDIF_EXT;
for (String resourcePath : RESOURCE_MAP.keySet()) {
if (resourcePath.startsWith(start) && resourcePath.endsWith(end)) {
URL resource = getResource(resourcePath, "syntax LDIF file");
LdifReader reader = new LdifReader(resource.openStream());
LdifEntry entry = reader.next();
reader.close();
syntaxList.add(entry.getEntry());
}
}
}
return syntaxList;
}
use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.
the class JarLdifSchemaLoader method loadNameForms.
/**
* {@inheritDoc}
*/
@Override
public List<Entry> loadNameForms(Schema... schemas) throws LdapException, IOException {
List<Entry> nameFormList = new ArrayList<>();
if (schemas == null) {
return nameFormList;
}
for (Schema schema : schemas) {
String start = getSchemaDirectoryString(schema) + SchemaConstants.NAME_FORMS_PATH + "/" + "m-oid=";
String end = "." + LDIF_EXT;
for (String resourcePath : RESOURCE_MAP.keySet()) {
if (resourcePath.startsWith(start) && resourcePath.endsWith(end)) {
URL resource = getResource(resourcePath, "nameForm LDIF file");
LdifReader reader = new LdifReader(resource.openStream());
LdifEntry entry = reader.next();
reader.close();
nameFormList.add(entry.getEntry());
}
}
}
return nameFormList;
}
use of org.apache.directory.api.ldap.model.schema.registries.Schema in project directory-ldap-api by apache.
the class JarLdifSchemaLoader method loadObjectClasses.
/**
* {@inheritDoc}
*/
@Override
public List<Entry> loadObjectClasses(Schema... schemas) throws LdapException, IOException {
List<Entry> objectClassList = new ArrayList<>();
if (schemas == null) {
return objectClassList;
}
for (Schema schema : schemas) {
// get objectClasses directory, check if exists, return if not
String start = getSchemaDirectoryString(schema) + SchemaConstants.OBJECT_CLASSES_PATH + "/" + "m-oid=";
String end = "." + LDIF_EXT;
for (String resourcePath : RESOURCE_MAP.keySet()) {
if (resourcePath.startsWith(start) && resourcePath.endsWith(end)) {
URL resource = getResource(resourcePath, "objectClass LDIF file");
LdifReader reader = new LdifReader(resource.openStream());
LdifEntry entry = reader.next();
reader.close();
objectClassList.add(entry.getEntry());
}
}
}
return objectClassList;
}
Aggregations