{
// Clone, apply, check, then apply again if ok
// The new schemaObject's OID must exist
if ( !checkOidExist( schemaObject ) )
{
Throwable error = new LdapProtocolErrorException( I18n.err( I18n.ERR_11011, schemaObject.getOid() ) );
errors.add( error );
return false;
}
// Get the SchemaObject to delete if it's not a LoadableSchemaObject
SchemaObject toDelete = getSchemaObject( schemaObject );
// First check that this SchemaObject does not have any referencing SchemaObjects
Set<SchemaObjectWrapper> referencing = registries.getReferencing( toDelete );
if ( ( referencing != null ) && !referencing.isEmpty() )
{
String msg = I18n.err( I18n.ERR_11012, schemaObject.getOid(), Strings.setToString( referencing ) );
Throwable error = new LdapProtocolErrorException( msg );
errors.add( error );
return false;
}
String schemaName = getSchemaName( toDelete );
// At this point, the deleted AttributeType may be referenced, it will be checked
// there, if the schema and the AttributeType are both enabled.
Schema schema = getLoadedSchema( schemaName );
if ( schema == null )
{
// The SchemaObject must be associated with an existing schema
String msg = I18n.err( I18n.ERR_11013, schemaObject.getOid() );
LOG.info( msg );
Throwable error = new LdapProtocolErrorException( msg );
errors.add( error );
return false;
}
if ( schema.isEnabled() && schemaObject.isEnabled() )