Search in sources :

Example 1 with DefaultSchemaLdifExtractor

use of org.apache.directory.api.ldap.schemaextractor.impl.DefaultSchemaLdifExtractor in project aws-iam-ldap-bridge by denismo.

the class Runner 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 {
    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()) {
        System.out.println("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.size() != 0) {
        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);
}
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.schemaloader.LdifSchemaLoader) DefaultSchemaLdifExtractor(org.apache.directory.api.ldap.schemaextractor.impl.DefaultSchemaLdifExtractor) SchemaLdifExtractor(org.apache.directory.api.ldap.schemaextractor.SchemaLdifExtractor) DefaultSchemaManager(org.apache.directory.api.ldap.schemamanager.impl.DefaultSchemaManager) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) LdifSchemaLoader(org.apache.directory.api.ldap.schemaloader.LdifSchemaLoader) CursorException(org.apache.directory.api.ldap.model.cursor.CursorException) IOException(java.io.IOException) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) SchemaPartition(org.apache.directory.server.core.api.schema.SchemaPartition) LdifPartition(org.apache.directory.server.core.partition.ldif.LdifPartition) SingleFileLdifPartition(org.apache.directory.server.core.partition.ldif.SingleFileLdifPartition) DefaultSchemaLdifExtractor(org.apache.directory.api.ldap.schemaextractor.impl.DefaultSchemaLdifExtractor) File(java.io.File) DefaultSchemaManager(org.apache.directory.api.ldap.schemamanager.impl.DefaultSchemaManager)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 CursorException (org.apache.directory.api.ldap.model.cursor.CursorException)1 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)1 SchemaManager (org.apache.directory.api.ldap.model.schema.SchemaManager)1 SchemaLoader (org.apache.directory.api.ldap.model.schema.registries.SchemaLoader)1 SchemaLdifExtractor (org.apache.directory.api.ldap.schemaextractor.SchemaLdifExtractor)1 DefaultSchemaLdifExtractor (org.apache.directory.api.ldap.schemaextractor.impl.DefaultSchemaLdifExtractor)1 LdifSchemaLoader (org.apache.directory.api.ldap.schemaloader.LdifSchemaLoader)1 DefaultSchemaManager (org.apache.directory.api.ldap.schemamanager.impl.DefaultSchemaManager)1 InstanceLayout (org.apache.directory.server.core.api.InstanceLayout)1 SchemaPartition (org.apache.directory.server.core.api.schema.SchemaPartition)1 LdifPartition (org.apache.directory.server.core.partition.ldif.LdifPartition)1 SingleFileLdifPartition (org.apache.directory.server.core.partition.ldif.SingleFileLdifPartition)1