From ab237e7932ad17f99ebf611863d3578b6d3326a1 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Fri, 01 Jul 2016 12:53:43 +0000
Subject: [PATCH] OPENDJ-2956 Issue warnings during schema validation of a DIT structure rule if it references obsolete elements
---
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/DITStructureRule.java | 12 +++++++++---
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java | 22 ----------------------
opendj-core/src/main/resources/com/forgerock/opendj/ldap/core.properties | 4 ++++
3 files changed, 13 insertions(+), 25 deletions(-)
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/DITStructureRule.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/DITStructureRule.java
index 65aac95..46773c5 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/DITStructureRule.java
+++ b/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);
diff --git a/opendj-core/src/main/resources/com/forgerock/opendj/ldap/core.properties b/opendj-core/src/main/resources/com/forgerock/opendj/ldap/core.properties
index 92781df..89c7d84 100644
--- a/opendj-core/src/main/resources/com/forgerock/opendj/ldap/core.properties
+++ b/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
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
index d000ce6..9576fd0 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
+++ b/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)
--
Gitblit v1.10.0