Search in sources :

Example 1 with DefaultSchemaLdifExtractor

use of org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor in project directory-ldap-api by apache.

the class SchemaManagerDelTest method setup.

@BeforeClass
public static void setup() throws Exception {
    workingDirectory = System.getProperty("workingDirectory");
    if (workingDirectory == null) {
        String path = SchemaManagerDelTest.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, "SchemaManagerDelTest").getAbsolutePath();
    schemaRepository = new File(workingDirectory, "schema");
    // Cleanup the target directory
    FileUtils.deleteDirectory(schemaRepository);
    SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(new File(workingDirectory));
    extractor.extractOrCopy();
}
Also used : SchemaLdifExtractor(org.apache.directory.api.ldap.schema.extractor.SchemaLdifExtractor) DefaultSchemaLdifExtractor(org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor) DefaultSchemaLdifExtractor(org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 2 with DefaultSchemaLdifExtractor

use of org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor in project directory-ldap-api by apache.

the class SchemaManagerEnableDisableLoadTest method setup.

@BeforeClass
public static void setup() throws Exception {
    workingDirectory = System.getProperty("workingDirectory");
    if (workingDirectory == null) {
        String path = SchemaManagerEnableDisableLoadTest.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, "SchemaManagerEnableDisableLoadTest").getAbsolutePath();
    schemaRepository = new File(workingDirectory, "schema");
    // Cleanup the target directory
    FileUtils.deleteDirectory(schemaRepository);
    SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(new File(workingDirectory));
    extractor.extractOrCopy();
}
Also used : SchemaLdifExtractor(org.apache.directory.api.ldap.schema.extractor.SchemaLdifExtractor) DefaultSchemaLdifExtractor(org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor) DefaultSchemaLdifExtractor(org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 3 with DefaultSchemaLdifExtractor

use of org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor in project directory-ldap-api by apache.

the class LdifSchemaLoaderTest method testLoader.

@Test
public void testLoader() throws Exception {
    SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(new File(workingDirectory));
    extractor.extractOrCopy();
    LdifSchemaLoader loader = new LdifSchemaLoader(new File(workingDirectory, "schema"));
    SchemaManager sm = new DefaultSchemaManager(loader);
    boolean loaded = sm.loadAllEnabled();
    if (!loaded) {
        fail("Schema load failed : " + Exceptions.printErrors(sm.getErrors()));
    }
    assertTrue(sm.getRegistries().getAttributeTypeRegistry().contains("cn"));
}
Also used : DefaultSchemaLdifExtractor(org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor) SchemaLdifExtractor(org.apache.directory.api.ldap.schema.extractor.SchemaLdifExtractor) DefaultSchemaLdifExtractor(org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) File(java.io.File) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) Test(org.junit.Test)

Example 4 with DefaultSchemaLdifExtractor

use of org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor in project directory-ldap-api by apache.

the class SchemaManagerLoadWithDepsTest method setup.

@BeforeClass
public static void setup() throws Exception {
    workingDirectory = System.getProperty("workingDirectory");
    if (workingDirectory == null) {
        String path = SchemaManagerLoadWithDepsTest.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, "SchemaManagerLoadWithDepsTest").getAbsolutePath();
    schemaRepository = new File(workingDirectory, "schema");
    // Cleanup the target directory
    FileUtils.deleteDirectory(schemaRepository);
    SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(new File(workingDirectory));
    extractor.extractOrCopy();
}
Also used : DefaultSchemaLdifExtractor(org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor) SchemaLdifExtractor(org.apache.directory.api.ldap.schema.extractor.SchemaLdifExtractor) DefaultSchemaLdifExtractor(org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 5 with DefaultSchemaLdifExtractor

use of org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor in project syncope by apache.

the class ApacheDSStartStopListener 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
 */
private 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.debug("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 IllegalStateException(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);
}
Also used : InstanceLayout(org.apache.directory.server.core.api.InstanceLayout) SchemaLoader(org.apache.directory.api.ldap.model.schema.registries.SchemaLoader) LdifSchemaLoader(org.apache.directory.api.ldap.schema.loader.LdifSchemaLoader) SchemaLdifExtractor(org.apache.directory.api.ldap.schema.extractor.SchemaLdifExtractor) DefaultSchemaLdifExtractor(org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) LdifSchemaLoader(org.apache.directory.api.ldap.schema.loader.LdifSchemaLoader) SchemaPartition(org.apache.directory.server.core.api.schema.SchemaPartition) LdifPartition(org.apache.directory.server.core.partition.ldif.LdifPartition) DefaultSchemaLdifExtractor(org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor) File(java.io.File) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager)

Aggregations

DefaultSchemaLdifExtractor (org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor)10 File (java.io.File)9 SchemaLdifExtractor (org.apache.directory.api.ldap.schema.extractor.SchemaLdifExtractor)9 BeforeClass (org.junit.BeforeClass)6 DefaultSchemaManager (org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager)4 SchemaManager (org.apache.directory.api.ldap.model.schema.SchemaManager)3 SchemaLoader (org.apache.directory.api.ldap.model.schema.registries.SchemaLoader)2 LdifSchemaLoader (org.apache.directory.api.ldap.schema.loader.LdifSchemaLoader)2 InstanceLayout (org.apache.directory.server.core.api.InstanceLayout)2 SchemaPartition (org.apache.directory.server.core.api.schema.SchemaPartition)2 LdifPartition (org.apache.directory.server.core.partition.ldif.LdifPartition)2 Test (org.junit.Test)2 InvalidNameException (javax.naming.InvalidNameException)1 NamingException (javax.naming.NamingException)1 Schema (org.apache.directory.api.ldap.model.schema.registries.Schema)1