use of org.apache.directory.api.ldap.model.schema.ObjectClass in project directory-ldap-api by apache.
the class SchemaManagerAddTest method testAddObjectClassNoSuperiorWithExistingOid.
/**
* Addition of an OC with an existing OID
*/
@Test
public void testAddObjectClassNoSuperiorWithExistingOid() throws Exception {
SchemaManager schemaManager = loadSystem();
int ocrSize = schemaManager.getObjectClassRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
ObjectClass objectClass = new ObjectClass("2.5.17.0");
assertFalse(schemaManager.add(objectClass));
assertEquals(1, schemaManager.getErrors().size());
Throwable error = schemaManager.getErrors().get(0);
assertTrue(error instanceof LdapSchemaException);
ObjectClass added = schemaManager.lookupObjectClassRegistry("2.5.17.0");
assertNotNull(added);
assertEquals(ocrSize, schemaManager.getObjectClassRegistry().size());
assertEquals(goidSize, schemaManager.getGlobalOidRegistry().size());
}
use of org.apache.directory.api.ldap.model.schema.ObjectClass in project directory-ldap-api by apache.
the class DefaultSchemaManager method addObjectClasses.
/**
* Add all the Schema's ObjectClasses
*/
private void addObjectClasses(Schema schema, Registries registries) throws LdapException, IOException {
if (schema.getSchemaLoader() == null) {
return;
}
for (Entry entry : schema.getSchemaLoader().loadObjectClasses(schema)) {
ObjectClass objectClass = factory.getObjectClass(this, entry, registries, schema.getSchemaName());
addSchemaObject(registries, objectClass, schema);
}
}
use of org.apache.directory.api.ldap.model.schema.ObjectClass in project directory-ldap-api by apache.
the class NameFormHelper method addToRegistries.
/**
* Inject the NameForm into the registries, updating the references to
* other SchemaObject
*
* @param nameForm The NameForm to add to the Registries
* @param errors The errors we got while adding the NameForm to the Registries
* @param registries The Registries
* @throws LdapException If the addition failed
*/
public static void addToRegistries(NameForm nameForm, List<Throwable> errors, Registries registries) throws LdapException {
if (registries != null) {
try {
nameForm.unlock();
AttributeTypeRegistry atRegistry = registries.getAttributeTypeRegistry();
ObjectClass structuralObjectClass = registries.getObjectClassRegistry().lookup(nameForm.getStructuralObjectClassOid());
nameForm.setStructuralObjectClass(structuralObjectClass);
nameForm.getMayAttributeTypes().clear();
for (String oid : nameForm.getMayAttributeTypeOids()) {
nameForm.getMayAttributeTypes().add(atRegistry.lookup(oid));
}
nameForm.getMustAttributeTypes().clear();
for (String oid : nameForm.getMustAttributeTypeOids()) {
nameForm.getMustAttributeTypes().add(atRegistry.lookup(oid));
}
} finally {
nameForm.lock();
}
}
}
Aggregations