mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Nicolas Capponi
28.20.2016 ab237e7932ad17f99ebf611863d3578b6d3326a1
OPENDJ-2956 Issue warnings during schema validation of a DIT structure rule if it references obsolete elements
3 files modified
38 ■■■■■ changed files
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/DITStructureRule.java 12 ●●●● patch | view | raw | blame | history
opendj-core/src/main/resources/com/forgerock/opendj/ldap/core.properties 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java 22 ●●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/DITStructureRule.java
@@ -17,9 +17,7 @@
package org.forgerock.opendj.ldap.schema;
import static java.util.Arrays.*;
import static org.forgerock.opendj.ldap.schema.SchemaUtils.*;
import static com.forgerock.opendj.ldap.CoreMessages.*;
import java.util.Collection;
@@ -475,18 +473,26 @@
            failValidation(invalidSchemaElements, warnings, message);
            return false;
        }
        if (!isObsolete() && nameForm.isObsolete()) {
            warnings.add(WARN_DIT_SR_HAS_OBSOLETE_NAME_FORM.get(getNameOrRuleID(), nameFormOID));
        }
        if (!superiorRuleIDs.isEmpty()) {
            superiorRules = new HashSet<>(superiorRuleIDs.size());
            for (final Integer id : superiorRuleIDs) {
                DITStructureRule ditStructureRule;
                try {
                    superiorRules.add(schema.getDITStructureRule(id));
                    ditStructureRule = schema.getDITStructureRule(id);
                    superiorRules.add(ditStructureRule);
                } catch (final UnknownSchemaElementException e) {
                    final LocalizableMessage message =
                            ERR_ATTR_SYNTAX_DSR_UNKNOWN_RULE_ID.get(getNameOrRuleID(), id);
                    failValidation(invalidSchemaElements, warnings, message);
                    return false;
                }
                if (!isObsolete() && ditStructureRule.isObsolete()) {
                    warnings.add(WARN_DIT_SR_HAS_OBSOLETE_SUPERIOR_RULE.get(getNameOrRuleID(), nameFormOID));
                }
            }
        }
        superiorRules = Collections.unmodifiableSet(superiorRules);
opendj-core/src/main/resources/com/forgerock/opendj/ldap/core.properties
@@ -1649,6 +1649,10 @@
 optional attribute type "%s" which is marked as OBSOLETE in the schema
WARN_DIT_CR_HAS_OBSOLETE_PROHIBITED_ATTR=The DIT content rule "%s" specifies the \
 prohibited attribute type "%s" which is marked as OBSOLETE in the schema
WARN_DIT_SR_HAS_OBSOLETE_NAME_FORM=The DIT structure rule "%s" specifies the \
 name form "%s" which is marked as OBSOLETE in the schema
WARN_DIT_SR_HAS_OBSOLETE_SUPERIOR_RULE=The DIT structure rule "%s" specifies the \
 superior rule "%s" which is marked as OBSOLETE in the schema
# Labels for generated documentation
DOC_LOCALE_TAG=Code tag: %s
DOC_LOCALE_OID=Collation order object identifier: %s
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
@@ -1685,28 +1685,6 @@
      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
    }
    // Make sure that the new DIT structure rule doesn't reference an undefined
    // name form or superior DIT structure rule.
    NameForm nameForm = ditStructureRule.getNameForm();
    if (nameForm.isObsolete())
    {
      LocalizableMessage message = ERR_SCHEMA_MODIFY_DSR_OBSOLETE_NAME_FORM.get(
          ditStructureRule.getNameOrRuleID(), nameForm.getNameOrOID());
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
    }
    // If there are any superior rules, then make sure none of them are marked
    // OBSOLETE.
    for (DITStructureRule dsr : ditStructureRule.getSuperiorRules())
    {
      if (dsr.isObsolete())
      {
        LocalizableMessage message = ERR_SCHEMA_MODIFY_DSR_OBSOLETE_SUPERIOR_RULE.get(
            ditStructureRule.getNameOrRuleID(), dsr.getNameOrRuleID());
        throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
      }
    }
    // If there is no existing rule, then we're adding a new DIT structure rule.
    // Otherwise, we're replacing an existing one.
    if (existingDSR == null)