From 8dca37f29a6cf1e32f889647e173b537ffe7a33b Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 04 Jul 2016 12:59:59 +0000
Subject: [PATCH] SchemaBackend.java: Removed checks already performed in SchemaBuilder

---
 opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java |  106 ----------------------------------------------------
 1 files changed, 1 insertions(+), 105 deletions(-)

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 71cdbe5..38bb08e 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
@@ -25,8 +25,8 @@
 import static org.opends.server.core.DirectoryServer.*;
 import static org.opends.server.schema.GeneralizedTimeSyntax.*;
 import static org.opends.server.util.CollectionUtils.*;
-import static org.opends.server.util.ServerConstants.*;
 import static org.opends.server.util.SchemaUtils.*;
+import static org.opends.server.util.ServerConstants.*;
 import static org.opends.server.util.StaticUtils.*;
 
 import java.io.File;
@@ -1126,44 +1126,6 @@
       }
     }
 
-    // Make sure that the attribute type isn't used as the superior type for
-    // any other attributes.
-    for (AttributeType at : schema.getAttributeTypes())
-    {
-      AttributeType superiorType = at.getSuperiorType();
-      if (superiorType != null && superiorType.equals(removeType))
-      {
-        LocalizableMessage message = ERR_SCHEMA_MODIFY_REMOVE_AT_SUPERIOR_TYPE.get(
-            removeType.getNameOrOID(), superiorType.getNameOrOID());
-        throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
-      }
-    }
-
-    // Make sure that the attribute type isn't used as a required, optional, or
-    // prohibited attribute type in any DIT content rule.
-    for (DITContentRule dcr : schema.getDITContentRules())
-    {
-      if (dcr.getRequiredAttributes().contains(removeType) ||
-          dcr.getOptionalAttributes().contains(removeType) ||
-          dcr.getProhibitedAttributes().contains(removeType))
-      {
-        LocalizableMessage message = ERR_SCHEMA_MODIFY_REMOVE_AT_IN_DCR.get(
-            removeType.getNameOrOID(), dcr.getNameOrOID());
-        throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
-      }
-    }
-
-    // Make sure that the attribute type isn't referenced by any matching rule use.
-    for (MatchingRuleUse mru : schema.getMatchingRuleUses())
-    {
-      if (mru.getAttributes().contains(removeType))
-      {
-        LocalizableMessage message = ERR_SCHEMA_MODIFY_REMOVE_AT_IN_MR_USE.get(
-            removeType.getNameOrOID(), mru.getNameOrOID());
-        throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
-      }
-    }
-
     // If we've gotten here, then it's OK to remove the attribute type from the schema.
     schema.deregisterAttributeType(removeType);
     addIfNotNull(modifiedSchemaFiles, getElementSchemaFile(removeType));
@@ -1309,51 +1271,6 @@
       }
     }
 
-    // Make sure that the objectclass isn't used as the superior class for any
-    // other objectclass.
-    for (ObjectClass oc : schema.getObjectClasses())
-    {
-      for(ObjectClass superiorClass : oc.getSuperiorClasses())
-      {
-        if (superiorClass.equals(removeClass))
-        {
-          LocalizableMessage message = ERR_SCHEMA_MODIFY_REMOVE_OC_SUPERIOR_CLASS.get(
-              removeClass.getNameOrOID(), superiorClass.getNameOrOID());
-          throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
-                  message);
-        }
-      }
-    }
-
-    // Make sure that the objectclass isn't used as the structural class for
-    // any name form.
-    Collection<NameForm> mappedForms = schema.getNameForm(removeClass);
-    if (!mappedForms.isEmpty())
-    {
-      StringBuilder buffer = new StringBuilder();
-      for(NameForm nf : mappedForms)
-      {
-        buffer.append(nf.getNameOrOID());
-        buffer.append("\t");
-      }
-      LocalizableMessage message = ERR_SCHEMA_MODIFY_REMOVE_OC_IN_NF.get(
-          removeClass.getNameOrOID(), buffer);
-      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
-    }
-
-    // Make sure that the objectclass isn't used as a structural or auxiliary
-    // class for any DIT content rule.
-    for (DITContentRule dcr : schema.getDITContentRules())
-    {
-      if (dcr.getStructuralClass().equals(removeClass) ||
-          dcr.getAuxiliaryClasses().contains(removeClass))
-      {
-        LocalizableMessage message = ERR_SCHEMA_MODIFY_REMOVE_OC_IN_DCR.get(
-            removeClass.getNameOrOID(), dcr.getNameOrOID());
-        throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
-      }
-    }
-
     // If we've gotten here, then it's OK to remove the objectclass from the schema.
     schema.deregisterObjectClass(removeClass);
     addIfNotNull(modifiedSchemaFiles, getElementSchemaFile(removeClass));
@@ -1474,15 +1391,6 @@
       }
     }
 
-    // Make sure that the name form isn't referenced by any DIT structure rule.
-    Collection<DITStructureRule> ditRules = schema.getDITStructureRules(removeNF);
-    if (!ditRules.isEmpty())
-    {
-      LocalizableMessage message = ERR_SCHEMA_MODIFY_REMOVE_NF_IN_DSR.get(
-          removeNF.getNameOrOID(), ditRules.iterator().next().getNameOrRuleID());
-      throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
-    }
-
     // Now remove the name form from the schema.
     schema.deregisterNameForm(removeNF);
     addIfNotNull(modifiedSchemaFiles, getElementSchemaFile(removeNF));
@@ -1742,18 +1650,6 @@
       }
     }
 
-    // Make sure that the DIT structure rule isn't the superior for any other
-    // DIT structure rule.
-    for (DITStructureRule dsr : schema.getDITStructureRules())
-    {
-      if (dsr.getSuperiorRules().contains(removeDSR))
-      {
-        LocalizableMessage message = ERR_SCHEMA_MODIFY_REMOVE_DSR_SUPERIOR_RULE.get(
-            removeDSR.getNameOrRuleID(), dsr.getNameOrRuleID());
-        throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
-      }
-    }
-
     // If we've gotten here, then it's OK to remove the DIT structure rule from the schema.
     schema.deregisterDITStructureRule(removeDSR);
     addIfNotNull(modifiedSchemaFiles, getElementSchemaFile(removeDSR));

--
Gitblit v1.10.0