use of org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor in project camunda-bpm-platform by camunda.
the class LdapTestEnvironment method initSchemaPartition.
/**
* initialize the schema manager and add the schema partition to directory
* service
*
* @throws Exception if the schema LDIF files are not found on the classpath
*/
protected void initSchemaPartition() throws Exception {
InstanceLayout instanceLayout = service.getInstanceLayout();
File schemaPartitionDirectory = new File(instanceLayout.getPartitionsDirectory(), "schema");
// Extract the schema on disk (a brand new one) and load the registries
if (schemaPartitionDirectory.exists()) {
LOG.log(Level.INFO, "schema partition already exists, skipping schema extraction");
} else {
SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(instanceLayout.getPartitionsDirectory());
extractor.extractOrCopy();
}
SchemaLoader loader = new LdifSchemaLoader(schemaPartitionDirectory);
SchemaManager schemaManager = new DefaultSchemaManager(loader);
// We have to load the schema now, otherwise we won't be able
// to initialize the Partitions, as we won't be able to parse
// and normalize their suffix Dn
schemaManager.loadAllEnabled();
List<Throwable> errors = schemaManager.getErrors();
if (!errors.isEmpty()) {
throw new Exception(I18n.err(I18n.ERR_317, Exceptions.printErrors(errors)));
}
service.setSchemaManager(schemaManager);
// Init the LdifPartition with schema
LdifPartition schemaLdifPartition = new LdifPartition(schemaManager, service.getDnFactory());
schemaLdifPartition.setPartitionPath(schemaPartitionDirectory.toURI());
// The schema partition
SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
schemaPartition.setWrappedPartition(schemaLdifPartition);
service.setSchemaPartition(schemaPartition);
}
use of org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor in project directory-ldap-api by apache.
the class SchemaManagerAddTest method setup.
@BeforeClass
public static void setup() throws Exception {
workingDirectory = System.getProperty("workingDirectory");
if (workingDirectory == null) {
String path = SchemaManagerAddTest.class.getResource("").getPath();
int targetPos = path.indexOf("target");
workingDirectory = path.substring(0, targetPos + 6);
}
// Make sure every test class has its own schema directory
workingDirectory = new File(workingDirectory, "SchemaManagerAddTest").getAbsolutePath();
schemaRepository = new File(workingDirectory, "schema");
// Cleanup the target directory
FileUtils.deleteDirectory(schemaRepository);
SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(new File(workingDirectory));
extractor.extractOrCopy();
}
use of org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor in project directory-ldap-api by apache.
the class SchemaManagerLoadTest method setup.
@BeforeClass
public static void setup() throws Exception {
workingDirectory = System.getProperty("workingDirectory");
if (workingDirectory == null) {
String path = SchemaManagerLoadTest.class.getResource("").getPath();
int targetPos = path.indexOf("target");
workingDirectory = path.substring(0, targetPos + 6);
}
// Make sure every test class has its own schema directory
workingDirectory = new File(workingDirectory, "SchemaManagerLoadTest").getAbsolutePath();
schemaRepository = new File(workingDirectory, "schema");
// Cleanup the target directory
FileUtils.deleteDirectory(schemaRepository);
SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(new File(workingDirectory));
extractor.extractOrCopy();
}
use of org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor in project directory-ldap-api by apache.
the class SchemaLdifExtractorTest method testExtract.
@Test
public void testExtract() throws Exception {
SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(new File(workingDirectory));
extractor.extractOrCopy();
}
use of org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor 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();
}
Aggregations