catch ( Exception e )
{
// Not allowed.
String msg = I18n.err( I18n.ERR_04303, superiorOid, getName() );
LdapSchemaException ldapSchemaException = new LdapSchemaException(
LdapSchemaExceptionCodes.AT_NONEXISTENT_SUPERIOR, msg );
ldapSchemaException.setSourceObject( this );
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, getName() );
LdapSchemaException ldapSchemaException = new LdapSchemaException(
LdapSchemaExceptionCodes.AT_CANNOT_SUBTYPE_COLLECTIVE_AT, msg );
ldapSchemaException.setSourceObject( this );
errors.add( ldapSchemaException );
LOG.info( msg );
return false;
}
this.superior = 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( this, currentSuperior );
}
catch ( LdapException ne )
{
errors.add( ne );
LOG.info( ne.getMessage() );
return false;
}
// Check for cycles now
Set<String> superiors = new HashSet<String>();
superiors.add( oid );
AttributeType tmp = currentSuperior;
boolean isOk = true;
while ( tmp != null )
{
if ( superiors.contains( tmp.getOid() ) )
{
// There is a cycle : bad bad bad !
// Not allowed.
String msg = I18n.err( I18n.ERR_04304, getName() );
LdapSchemaException ldapSchemaException = new LdapSchemaException(
LdapSchemaExceptionCodes.AT_CYCLE_TYPE_HIERARCHY, msg );
ldapSchemaException.setSourceObject( this );
errors.add( ldapSchemaException );
LOG.info( msg );
isOk = false;
break;
}
else
{
superiors.add( tmp.getOid() );
tmp = tmp.getSuperior();
}
}
superiors.clear();
return isOk;
}
else
{
// Not allowed.
String msg = I18n.err( I18n.ERR_04305, superiorOid, getName() );
LdapSchemaException ldapSchemaException = new LdapSchemaException(
LdapSchemaExceptionCodes.AT_NONEXISTENT_SUPERIOR, msg );
ldapSchemaException.setSourceObject( this );
ldapSchemaException.setRelatedId( superiorOid );
errors.add( ldapSchemaException );
LOG.info( msg );
// Get out now
return false;