* Build the Superior AttributeType reference for an AttributeType
*/
private static boolean buildSuperior( AttributeType attributeType, List<Throwable> errors, Registries registries )
{
AttributeType currentSuperior = null;
AttributeTypeRegistry attributeTypeRegistry = registries.getAttributeTypeRegistry();
String superiorOid = attributeType.getSuperiorOid();
if ( superiorOid != null )
{
// This AT has a superior
try
{
currentSuperior = attributeTypeRegistry.lookup( superiorOid );
}
catch ( Exception e )
{
// Not allowed.
String msg = I18n.err( I18n.ERR_04303, superiorOid, attributeType.getName() );
LdapSchemaException ldapSchemaException = new LdapSchemaException(
LdapSchemaExceptionCodes.AT_NONEXISTENT_SUPERIOR, msg, e );
ldapSchemaException.setSourceObject( attributeType );
ldapSchemaException.setRelatedId( superiorOid );
errors.add( ldapSchemaException );
LOG.info( msg );
// Get out now
return false;
}
if ( currentSuperior != null )
{
// a special case : if the superior is collective, this is an error
if ( currentSuperior.isCollective() )
{
String msg = I18n.err( I18n.ERR_04482_CANNOT_SUBTYPE_COLLECTIVE,
currentSuperior, attributeType.getName() );
LdapSchemaException ldapSchemaException = new LdapSchemaException(
LdapSchemaExceptionCodes.AT_CANNOT_SUBTYPE_COLLECTIVE_AT, msg );
ldapSchemaException.setSourceObject( attributeType );
errors.add( ldapSchemaException );
LOG.info( msg );
return false;
}
attributeType.setSuperior( currentSuperior );
// Recursively update the superior if not already done. We don't recurse
// if the superior's superior is not null, as it means it has already been
// handled.
if ( currentSuperior.getSuperior() == null )
{
registries.buildReference( errors, currentSuperior );
}
// Update the descendant MAP
try
{
attributeTypeRegistry.registerDescendants( attributeType, currentSuperior );
}
catch ( LdapException ne )
{
errors.add( ne );
LOG.info( ne.getMessage() );