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"));
}
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);
}
}
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");
}
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");
}
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");
}
Aggregations