Search in sources :

Example 1 with DefaultSchemaLdifExtractor

use of org.apache.directory.shared.ldap.schema.ldif.extractor.impl.DefaultSchemaLdifExtractor in project vertx-auth by vert-x3.

the class EmbeddedADS method initSchemaPartition.

/**
 * initialize the schema manager and add the schema partition to diectory service
 *
 * @throws Exception if the schema LDIF files are not found on the classpath
 */
private void initSchemaPartition() throws Exception {
    SchemaPartition schemaPartition = service.getSchemaService().getSchemaPartition();
    // Init the LdifPartition
    LdifPartition ldifPartition = new LdifPartition();
    String workingDirectory = service.getWorkingDirectory().getPath();
    ldifPartition.setWorkingDirectory(workingDirectory + "/schema");
    // Extract the schema on disk (a brand new one) and load the registries
    File schemaRepository = new File(workingDirectory, "schema");
    SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(new File(workingDirectory));
    extractor.extractOrCopy(true);
    schemaPartition.setWrappedPartition(ldifPartition);
    SchemaLoader loader = new LdifSchemaLoader(schemaRepository);
    SchemaManager schemaManager = new DefaultSchemaManager(loader);
    service.setSchemaManager(schemaManager);
    // 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();
    schemaPartition.setSchemaManager(schemaManager);
    List<Throwable> errors = schemaManager.getErrors();
    if (errors.size() != 0) {
        throw new Exception("Schema load failed : " + errors);
    }
}
Also used : LdifSchemaLoader(org.apache.directory.shared.ldap.schema.loader.ldif.LdifSchemaLoader) SchemaLoader(org.apache.directory.shared.ldap.schema.registries.SchemaLoader) SchemaLdifExtractor(org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor) DefaultSchemaLdifExtractor(org.apache.directory.shared.ldap.schema.ldif.extractor.impl.DefaultSchemaLdifExtractor) DefaultSchemaManager(org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager) SchemaManager(org.apache.directory.shared.ldap.schema.SchemaManager) LdifSchemaLoader(org.apache.directory.shared.ldap.schema.loader.ldif.LdifSchemaLoader) SchemaPartition(org.apache.directory.server.core.schema.SchemaPartition) LdifPartition(org.apache.directory.server.core.partition.ldif.LdifPartition) DefaultSchemaLdifExtractor(org.apache.directory.shared.ldap.schema.ldif.extractor.impl.DefaultSchemaLdifExtractor) File(java.io.File) DefaultSchemaManager(org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager)

Aggregations

File (java.io.File)1 LdifPartition (org.apache.directory.server.core.partition.ldif.LdifPartition)1 SchemaPartition (org.apache.directory.server.core.schema.SchemaPartition)1 SchemaManager (org.apache.directory.shared.ldap.schema.SchemaManager)1 SchemaLdifExtractor (org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor)1 DefaultSchemaLdifExtractor (org.apache.directory.shared.ldap.schema.ldif.extractor.impl.DefaultSchemaLdifExtractor)1 LdifSchemaLoader (org.apache.directory.shared.ldap.schema.loader.ldif.LdifSchemaLoader)1 DefaultSchemaManager (org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager)1 SchemaLoader (org.apache.directory.shared.ldap.schema.registries.SchemaLoader)1