Search in sources :

Example 26 with DefaultSchemaManager

use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project directory-ldap-api by apache.

the class SchemaManagerLoadWithDepsTest method testLoadCosine.

/**
 * test loading the "cosine" schema, which depends on "system" and "core"
 */
@Test
public void testLoadCosine() throws Exception {
    LdifSchemaLoader loader = new LdifSchemaLoader(schemaRepository);
    SchemaManager schemaManager = new DefaultSchemaManager(loader.getAllSchemas());
    schemaManager.loadWithDeps("cosine");
    assertTrue(schemaManager.getErrors().isEmpty());
    assertEquals(133, schemaManager.getAttributeTypeRegistry().size());
    assertEquals(36, schemaManager.getComparatorRegistry().size());
    assertEquals(42, schemaManager.getMatchingRuleRegistry().size());
    assertEquals(35, schemaManager.getNormalizerRegistry().size());
    assertEquals(49, schemaManager.getObjectClassRegistry().size());
    assertEquals(59, schemaManager.getSyntaxCheckerRegistry().size());
    assertEquals(66, schemaManager.getLdapSyntaxRegistry().size());
    assertEquals(290, schemaManager.getGlobalOidRegistry().size());
    assertEquals(3, schemaManager.getRegistries().getLoadedSchemas().size());
    assertNotNull(schemaManager.getRegistries().getLoadedSchema("system"));
    assertNotNull(schemaManager.getRegistries().getLoadedSchema("core"));
    assertNotNull(schemaManager.getRegistries().getLoadedSchema("cosine"));
}
Also used : SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) Test(org.junit.Test)

Example 27 with DefaultSchemaManager

use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project directory-ldap-api by apache.

the class LdapNetworkConnection method loadSchema.

/**
 * loads schema using the specified schema loader
 *
 * @param loader the {@link SchemaLoader} to be used to load schema
 * @throws LdapException If the schema loading failed
 */
public void loadSchema(SchemaLoader loader) throws LdapException {
    try {
        SchemaManager tmp = new DefaultSchemaManager(loader);
        tmp.loadAllEnabled();
        if (!tmp.getErrors().isEmpty() && loader.isStrict()) {
            String msg = I18n.err(I18n.ERR_03204_ERROR_LOADING_SCHEMA);
            if (LOG.isErrorEnabled()) {
                LOG.error("{} {}", msg, Strings.listToString(tmp.getErrors()));
            }
            throw new LdapException(msg);
        }
        schemaManager = tmp;
        // Change the container's BinaryDetector
        ldapSession.setAttribute(LdapDecoder.MESSAGE_CONTAINER_ATTR, new LdapMessageContainer<MessageDecorator<? extends Message>>(codec, new SchemaBinaryAttributeDetector(schemaManager)));
    } catch (LdapException le) {
        throw le;
    } catch (Exception e) {
        LOG.error(I18n.err(I18n.ERR_03205_FAIL_LOAD_SCHEMA), e);
        throw new LdapException(e);
    }
}
Also used : MessageDecorator(org.apache.directory.api.ldap.codec.api.MessageDecorator) Message(org.apache.directory.api.ldap.model.message.Message) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) SchemaBinaryAttributeDetector(org.apache.directory.api.ldap.codec.api.SchemaBinaryAttributeDetector) UnresolvedAddressException(java.nio.channels.UnresolvedAddressException) ConnectException(java.net.ConnectException) IOException(java.io.IOException) LdapInvalidDnException(org.apache.directory.api.ldap.model.exception.LdapInvalidDnException) InvalidConnectionException(org.apache.directory.ldap.client.api.exception.InvalidConnectionException) LdapOperationException(org.apache.directory.api.ldap.model.exception.LdapOperationException) LdapAuthenticationException(org.apache.directory.api.ldap.model.exception.LdapAuthenticationException) MessageEncoderException(org.apache.directory.api.ldap.codec.api.MessageEncoderException) CursorException(org.apache.directory.api.ldap.model.cursor.CursorException) DecoderException(org.apache.directory.api.asn1.DecoderException) LdapNoPermissionException(org.apache.directory.api.ldap.model.exception.LdapNoPermissionException) LdapOtherException(org.apache.directory.api.ldap.model.exception.LdapOtherException) ProtocolEncoderException(org.apache.mina.filter.codec.ProtocolEncoderException) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager)

Example 28 with DefaultSchemaManager

use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project directory-ldap-api by apache.

the class SchemaAwareAttributeSerializationTest method setup.

/**
 * Initialize OIDs maps for normalization
 */
@BeforeClass
public static void setup() throws Exception {
    schemaManager = new DefaultSchemaManager();
    cn = schemaManager.getAttributeType("cn");
    userCertificate = schemaManager.getAttributeType("userCertificate");
}
Also used : DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) BeforeClass(org.junit.BeforeClass)

Example 29 with DefaultSchemaManager

use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project directory-ldap-api by apache.

the class SchemaAwareModificationSerializationTest method setup.

/**
 * Initialize OIDs maps for normalization
 */
@BeforeClass
public static void setup() throws Exception {
    schemaManager = new DefaultSchemaManager();
    cnAT = schemaManager.getAttributeType("cn");
}
Also used : DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) BeforeClass(org.junit.BeforeClass)

Example 30 with DefaultSchemaManager

use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project directory-ldap-api by apache.

the class SubtreeSpecificationParserTest method init.

/**
 * Initialization
 */
@BeforeClass
public static void init() throws Exception {
    JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
    schemaManager = new DefaultSchemaManager(loader);
    schemaManager.loadAllEnabled();
    parser = new SubtreeSpecificationParser(schemaManager);
    topOC = schemaManager.lookupObjectClassRegistry("top");
    aliasOC = schemaManager.lookupObjectClassRegistry("alias");
    countryOC = schemaManager.lookupObjectClassRegistry("country");
    personOC = schemaManager.lookupObjectClassRegistry("person");
}
Also used : SubtreeSpecificationParser(org.apache.directory.api.ldap.model.subtree.SubtreeSpecificationParser) JarLdifSchemaLoader(org.apache.directory.api.ldap.schema.loader.JarLdifSchemaLoader) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) BeforeClass(org.junit.BeforeClass)

Aggregations

DefaultSchemaManager (org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager)64 SchemaManager (org.apache.directory.api.ldap.model.schema.SchemaManager)55 Test (org.junit.Test)41 BeforeClass (org.junit.BeforeClass)11 JarLdifSchemaLoader (org.apache.directory.api.ldap.schema.loader.JarLdifSchemaLoader)9 File (java.io.File)7 Schema (org.apache.directory.api.ldap.model.schema.registries.Schema)7 InstanceLayout (org.apache.directory.server.core.api.InstanceLayout)6 SchemaPartition (org.apache.directory.server.core.api.schema.SchemaPartition)6 IOException (java.io.IOException)5 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)4 LdapUnwillingToPerformException (org.apache.directory.api.ldap.model.exception.LdapUnwillingToPerformException)4 SchemaLoader (org.apache.directory.api.ldap.model.schema.registries.SchemaLoader)4 DefaultSchema (org.apache.directory.api.ldap.model.schema.registries.DefaultSchema)3 SchemaLdifExtractor (org.apache.directory.api.ldap.schema.extractor.SchemaLdifExtractor)3 DefaultSchemaLdifExtractor (org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor)3 CacheService (org.apache.directory.server.core.api.CacheService)3 CacheManager (net.sf.ehcache.CacheManager)2 CacheConfiguration (net.sf.ehcache.config.CacheConfiguration)2 Configuration (net.sf.ehcache.config.Configuration)2