}
// 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 );
}
}
}
// a syntax is mandatory for an attributeType and if not provided by the description
// must be provided from some ancestor in the attributeType hierarchy; without either
// of these the description definitely cannot resolve a syntax and cannot be allowed.
// if a supertype exists then it must resolve a proper syntax somewhere in the hierarchy.
if ( attributeType.getSyntaxOid() == null && attributeType.getSuperiorOid() == null )
{
throw new LdapOperationNotSupportedException( I18n.err( I18n.ERR_416 ), ResultCodeEnum.UNWILLING_TO_PERFORM );
}
List<Throwable> errors = new ArrayList<Throwable>();
attributeType.setRegistries( schemaManager.getRegistries() );