use of org.apache.directory.api.ldap.model.schema.ObjectClass in project directory-ldap-api by apache.
the class DefaultObjectClassRegistry method hasDescendants.
/**
* {@inheritDoc}
*/
@Override
public boolean hasDescendants(String ancestorId) throws LdapException {
try {
String oid = getOidByName(ancestorId);
Set<ObjectClass> descendants = oidToDescendants.get(oid);
return (descendants != null) && !descendants.isEmpty();
} catch (LdapException ne) {
throw new LdapNoSuchAttributeException(ne.getMessage(), ne);
}
}
use of org.apache.directory.api.ldap.model.schema.ObjectClass in project directory-ldap-api by apache.
the class DefaultObjectClassRegistry method clear.
/**
* {@inheritDoc}
*/
@Override
public void clear() {
// Clear the contained SchemaObjects
for (SchemaObject objectClass : oidRegistry) {
objectClass.clear();
}
// First clear the shared elements
super.clear();
// and clear the descendant
for (Map.Entry<String, Set<ObjectClass>> entry : oidToDescendants.entrySet()) {
Set<ObjectClass> descendants = entry.getValue();
if (descendants != null) {
descendants.clear();
}
}
oidToDescendants.clear();
}
use of org.apache.directory.api.ldap.model.schema.ObjectClass in project directory-ldap-api by apache.
the class QuirkySchemaTest method testLoadMinimalSchema.
/**
* Try to load a very minimal (and correct) schema. It has just 'person' objectclass and all
* the necessary attributes, matching rules and syntaxes. Load it in strict mode.
* This test is here mostly to make sure that the test itself works.
*/
@Test
public void testLoadMinimalSchema() throws Exception {
LdapConnection connection = createFakeConnection("src/test/resources/schema-minimal.ldif");
DefaultSchemaLoader loader = new DefaultSchemaLoader(connection);
Collection<Schema> allEnabled = loader.getAllEnabled();
assertEquals(1, allEnabled.size());
Schema schema = allEnabled.iterator().next();
assertNotNull(schema);
assertEquals(26, schema.getContent().size());
SchemaManager schemaManager = new DefaultSchemaManager(loader);
boolean loaded = schemaManager.loadAllEnabled();
if (!loaded) {
fail("Schema load failed : " + Exceptions.printErrors(schemaManager.getErrors()));
}
assertTrue(schemaManager.getRegistries().getAttributeTypeRegistry().contains("cn"));
ObjectClass person = schemaManager.getRegistries().getObjectClassRegistry().lookup("person");
assertNotNull(person);
assertEquals(2, person.getMustAttributeTypes().size());
assertEquals(4, person.getMayAttributeTypes().size());
}
use of org.apache.directory.api.ldap.model.schema.ObjectClass in project directory-ldap-api by apache.
the class ObjectClassDescriptionSchemaParserTest method testNovellList.
@Test
public void testNovellList() throws ParseException, NamingException {
String value = "( 2.16.840.1.113719.1.1.6.1.30 NAME 'List' SUP Top STRUCTURAL MUST cn MAY ( description $ l $ member $ ou $ o $ eMailAddress $ mailboxLocation $ mailboxID $ owner $ seeAlso $ fullName ) X-NDS_NAMING 'cn' X-NDS_CONTAINMENT ( 'Organization' 'organizationalUnit' 'domain' ) X-NDS_NOT_CONTAINER '1' X-NDS_NONREMOVABLE '1' X-NDS_ACL_TEMPLATES '2#entry#[Root Template]#member' )";
ObjectClass objectClass = parser.parseObjectClassDescription(value);
assertEquals("2.16.840.1.113719.1.1.6.1.30", objectClass.getOid());
assertEquals(1, objectClass.getNames().size());
assertEquals("List", objectClass.getNames().get(0));
assertNull(objectClass.getDescription());
assertEquals(1, objectClass.getSuperiorOids().size());
assertEquals("Top", objectClass.getSuperiorOids().get(0));
assertEquals(ObjectClassTypeEnum.STRUCTURAL, objectClass.getType());
assertEquals(1, objectClass.getMustAttributeTypeOids().size());
assertEquals("cn", objectClass.getMustAttributeTypeOids().get(0));
assertEquals(11, objectClass.getMayAttributeTypeOids().size());
assertEquals("description", objectClass.getMayAttributeTypeOids().get(0));
assertEquals("fullName", objectClass.getMayAttributeTypeOids().get(10));
assertEquals(5, objectClass.getExtensions().size());
assertNotNull(objectClass.getExtension("X-NDS_NAMING"));
assertEquals(1, objectClass.getExtension("X-NDS_NAMING").size());
assertEquals("cn", objectClass.getExtension("X-NDS_NAMING").get(0));
assertNotNull(objectClass.getExtension("X-NDS_NOT_CONTAINER"));
assertEquals(1, objectClass.getExtension("X-NDS_NOT_CONTAINER").size());
assertEquals("1", objectClass.getExtension("X-NDS_NOT_CONTAINER").get(0));
assertNotNull(objectClass.getExtension("X-NDS_NONREMOVABLE"));
assertEquals(1, objectClass.getExtension("X-NDS_NONREMOVABLE").size());
assertEquals("1", objectClass.getExtension("X-NDS_NONREMOVABLE").get(0));
// X-NDS_CONTAINMENT ( 'Organization' 'organizationalUnit' 'domain' )
assertNotNull(objectClass.getExtension("X-NDS_CONTAINMENT"));
assertEquals(3, objectClass.getExtension("X-NDS_CONTAINMENT").size());
assertEquals("Organization", objectClass.getExtension("X-NDS_CONTAINMENT").get(0));
assertEquals("organizationalUnit", objectClass.getExtension("X-NDS_CONTAINMENT").get(1));
assertEquals("domain", objectClass.getExtension("X-NDS_CONTAINMENT").get(2));
// X-NDS_ACL_TEMPLATES '2#entry#[Root Template]#member'
assertNotNull(objectClass.getExtension("X-NDS_ACL_TEMPLATES"));
assertEquals(1, objectClass.getExtension("X-NDS_ACL_TEMPLATES").size());
assertEquals("2#entry#[Root Template]#member", objectClass.getExtension("X-NDS_ACL_TEMPLATES").get(0));
}
use of org.apache.directory.api.ldap.model.schema.ObjectClass in project directory-ldap-api by apache.
the class ObjectClassDescriptionSchemaParserTest method testSiemensDirxX500Subschema.
@Test
public void testSiemensDirxX500Subschema() throws ParseException, NamingException {
String value = "( 2.5.20.1 NAME 'x500subSchema' AUXILIARY MAY (dITStructureRules $ nameForms $ dITContentRules $ x500objectClasses $ x500attributeTypes $ matchingRules $ matchingRuleUse) )";
ObjectClass objectClass = parser.parseObjectClassDescription(value);
assertEquals("2.5.20.1", objectClass.getOid());
assertEquals(1, objectClass.getNames().size());
assertEquals("x500subSchema", objectClass.getNames().get(0));
assertNull(objectClass.getDescription());
assertEquals(0, objectClass.getSuperiorOids().size());
assertEquals(ObjectClassTypeEnum.AUXILIARY, objectClass.getType());
assertEquals(0, objectClass.getMustAttributeTypeOids().size());
assertEquals(7, objectClass.getMayAttributeTypeOids().size());
assertEquals("dITStructureRules", objectClass.getMayAttributeTypeOids().get(0));
assertEquals("matchingRuleUse", objectClass.getMayAttributeTypeOids().get(6));
assertEquals(0, objectClass.getExtensions().size());
}
Aggregations