int pos = 0;
for ( Value<?> value : attr )
{
AttributeType attributeType = null;
try
{
attributeType = attributeTypeParser.parseAttributeTypeDescription( value.getString() );
}
catch ( ParseException e )
{
LdapInvalidAttributeValueException iave = new LdapInvalidAttributeValueException( I18n.err( I18n.ERR_408,
value.getString() ), ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
iave.setRootCause( e );
throw iave;
}
// if the supertype is provided make sure it exists in some schema
if ( ( attributeType.getSuperiorOid() != null ) && !schemaManager.getAttributeTypeRegistry().contains( attributeType.getSuperiorOid() ) )
{
throw new LdapOperationNotSupportedException( I18n.err( I18n.ERR_409, attributeType.getSuperiorOid() ),
ResultCodeEnum.UNWILLING_TO_PERFORM );
}
// if the syntax is provided by the description make sure it exists in some schema
if ( attributeType.getSyntaxOid() != null && !schemaManager.getLdapSyntaxRegistry().contains( attributeType.getSyntaxOid() ) )
{
throw new LdapOperationNotSupportedException( I18n.err( I18n.ERR_410, attributeType.getSyntaxOid() ),
ResultCodeEnum.UNWILLING_TO_PERFORM );
}
// if the matchingRule is provided make sure it exists in some schema
if ( attributeType.getEqualityOid() != null && !schemaManager.getMatchingRuleRegistry().contains( attributeType.getEqualityOid() ) )
{
throw new LdapOperationNotSupportedException( I18n.err( I18n.ERR_411, attributeType.getEqualityOid() ),
ResultCodeEnum.UNWILLING_TO_PERFORM );
}
// if the matchingRule is provided make sure it exists in some schema
if ( attributeType.getOrderingOid() != null && !schemaManager.getMatchingRuleRegistry().contains( attributeType.getOrderingOid() ) )
{
throw new LdapOperationNotSupportedException( I18n.err( I18n.ERR_412, attributeType.getOrderingOid() ),
ResultCodeEnum.UNWILLING_TO_PERFORM );
}
// if the matchingRule is provided make sure it exists in some schema
if ( attributeType.getSubstringOid() != null && !schemaManager.getMatchingRuleRegistry().contains( attributeType.getSubstringOid() ) )
{
throw new LdapOperationNotSupportedException( I18n.err( I18n.ERR_413, attributeType.getSubstringOid() ),
ResultCodeEnum.UNWILLING_TO_PERFORM );
}
// if the equality matching rule is null and no super type is specified then there is
// definitely no equality matchingRule that can be resolved. We cannot use an attribute
// without a matchingRule for search or for building indices not to mention lookups.
if ( attributeType.getEqualityOid() == null )
{
if ( attributeType.getSuperiorOid() == null )
{
throw new LdapOperationNotSupportedException( I18n.err( I18n.ERR_414 ), ResultCodeEnum.UNWILLING_TO_PERFORM );
}
else
{
AttributeType superType = schemaManager
.lookupAttributeTypeRegistry( attributeType.getSuperiorOid() );
if ( superType == null )
{
throw new LdapOperationNotSupportedException( I18n.err( I18n.ERR_415 ), ResultCodeEnum.UNWILLING_TO_PERFORM );