int pos = 0;
for ( Value<?> value : attr )
{
ObjectClass objectClass = null;
try
{
objectClass = objectClassParser.parseObjectClassDescription( value.getString() );
}
catch ( ParseException e )
{
LdapInvalidAttributeValueException iave = new LdapInvalidAttributeValueException( I18n.err( I18n.ERR_417,
value.getString() ), ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
iave.setRootCause( e );
throw iave;
}
// if the super objectClasses are provided make sure it exists in some schema
if ( objectClass.getSuperiorOids() != null && objectClass.getSuperiorOids().size() > 0 )
{
for ( String superiorOid : objectClass.getSuperiorOids() )
{
if ( superiorOid.equals( SchemaConstants.TOP_OC_OID )
|| superiorOid.equalsIgnoreCase( SchemaConstants.TOP_OC ) )
{
continue;
}
if ( !schemaManager.getObjectClassRegistry().contains( superiorOid ) )
{
throw new LdapOperationNotSupportedException( I18n.err( I18n.ERR_418, superiorOid ),
ResultCodeEnum.UNWILLING_TO_PERFORM );
}
}
}
// if the may list is provided make sure attributes exists in some schema
if ( objectClass.getMayAttributeTypeOids() != null && objectClass.getMayAttributeTypeOids().size() > 0 )
{
for ( String mayAttrOid : objectClass.getMayAttributeTypeOids() )
{
if ( !schemaManager.getAttributeTypeRegistry().contains( mayAttrOid ) )
{
throw new LdapOperationNotSupportedException( I18n.err( I18n.ERR_419, mayAttrOid ),
ResultCodeEnum.UNWILLING_TO_PERFORM );
}
}
}
// if the must list is provided make sure attributes exists in some schema
if ( objectClass.getMustAttributeTypeOids() != null && objectClass.getMustAttributeTypeOids().size() > 0 )
{
for ( String mustAttrOid : objectClass.getMustAttributeTypeOids() )
{
if ( !schemaManager.getAttributeTypeRegistry().contains( mustAttrOid ) )
{
throw new LdapOperationNotSupportedException( I18n.err( I18n.ERR_420, mustAttrOid ),
ResultCodeEnum.UNWILLING_TO_PERFORM );
}
}
}
List<Throwable> errors = new ArrayList<Throwable>();
objectClass.setRegistries( schemaManager.getRegistries() );
objectClasses[pos++] = objectClass;
}
return objectClasses;