// Get the matching rule for the new matching rule use and see if there's
// already an existing matching rule use that is associated with that
// matching rule. If there is, then it will only be acceptable if it's the
// matching rule use that we are replacing (in which case we really do want
// to use the "!=" operator).
MatchingRule matchingRule = matchingRuleUse.getMatchingRule();
MatchingRuleUse existingMRUForRule =
schema.getMatchingRuleUse(matchingRule);
if ((existingMRUForRule != null) && (existingMRUForRule != existingMRU))
{
Message message = ERR_SCHEMA_MODIFY_MR_CONFLICT_FOR_ADD_MR_USE.
get(matchingRuleUse.getName(), matchingRule.getNameOrOID(),
existingMRUForRule.getName());
throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
}
if (matchingRule.isObsolete())
{
Message message = ERR_SCHEMA_MODIFY_MRU_OBSOLETE_MR.get(
matchingRuleUse.getName(), matchingRule.getNameOrOID());
throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
}
// Make sure that the new matching rule use doesn't reference an undefined
// attribute type.
for (AttributeType at : matchingRuleUse.getAttributes())
{
if (! schema.hasAttributeType(at.getOID()))
{
Message message = ERR_SCHEMA_MODIFY_MRU_UNDEFINED_ATTR.get(
matchingRuleUse.getName(), at.getNameOrOID());
throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
}
else if (at.isObsolete())
{
Message message = ERR_SCHEMA_MODIFY_MRU_OBSOLETE_ATTR.get(
matchingRuleUse.getName(), matchingRule.getNameOrOID());
throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
}
}