String msg = "Modify operation leaves no structural objectClass for entry " + name;
if ( log.isInfoEnabled() )
{
log.info( msg + ". Raising LdapSchemaViolationException." );
}
throw new LdapSchemaViolationException( msg, ResultCodeEnum.OBJECTCLASSMODSPROHIBITED );
}
// remove all the objectClass attribute values from a cloned copy and then
// we can analyze what remains in this attribute to make sure a structural
// objectClass is present for the entry
Attribute cloned = ( Attribute ) entryObjectClasses.clone();
for ( int ii = 0; ii < objectClass.size(); ii++ )
{
cloned.remove( objectClass.get( ii ) );
}
// check resultant set of objectClass values for a structural objectClass
for ( int ii = 0; ii < cloned.size(); ii++ )
{
ObjectClass ocType = registry.lookup( ( String ) cloned.get( ii ) );
if ( ocType.getType() == ObjectClassTypeEnum.STRUCTURAL )
{
return;
}
}
// no structural object classes exist for the entry after the modifications
// to the objectClass attribute so we need to complain about that
String msg = "Modify operation leaves no structural objectClass for entry " + name;
if ( log.isInfoEnabled() )
{
log.info( msg + ". Raising LdapSchemaViolationException." );
}
throw new LdapSchemaViolationException( msg, ResultCodeEnum.OBJECTCLASSMODSPROHIBITED );
}