From 73fb5702321f67764e325edfd4e44cebf78786e7 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 03 Mar 2014 14:31:57 +0000
Subject: [PATCH] OPENDJ-1308 Migrate schema support

---
 opendj3-server-dev/src/server/org/opends/server/types/DITStructureRule.java         |   61 +-------------
 opendj3-server-dev/src/server/org/opends/server/types/MatchingRuleUse.java          |   61 +-------------
 opendj3-server-dev/src/server/org/opends/server/tools/ConfigureWindowsService.java  |   21 +----
 opendj3-server-dev/src/server/org/opends/server/types/SearchFilter.java             |    2 
 opendj3-server-dev/src/server/org/opends/server/core/MatchingRuleConfigManager.java |    4 
 opendj3-server-dev/src/server/org/opends/server/types/NameForm.java                 |   56 +------------
 opendj3-server-dev/src/server/org/opends/server/backends/SchemaBackend.java         |   20 ++--
 opendj3-server-dev/src/server/org/opends/server/types/CommonSchemaElements.java     |    5 
 opendj3-server-dev/src/server/org/opends/server/types/Schema.java                   |    4 
 9 files changed, 41 insertions(+), 193 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/SchemaBackend.java b/opendj3-server-dev/src/server/org/opends/server/backends/SchemaBackend.java
index d1c890c..8cf2f4a 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/SchemaBackend.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/SchemaBackend.java
@@ -1920,7 +1920,7 @@
       if (mru.getAttributes().contains(removeType))
       {
         LocalizableMessage message = ERR_SCHEMA_MODIFY_REMOVE_AT_IN_MR_USE.get(
-            removeType.getNameOrOID(), mru.getName());
+            removeType.getNameOrOID(), mru.getNameOrOID());
         throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
       }
     }
@@ -3090,9 +3090,9 @@
           {
             LocalizableMessage message =
                     ERR_SCHEMA_MODIFY_MULTIPLE_CONFLICTS_FOR_ADD_MR_USE.get(
-                            matchingRuleUse.getName(),
-                            existingMRU.getName(),
-                            mru.getName());
+                            matchingRuleUse.getNameOrOID(),
+                            existingMRU.getNameOrOID(),
+                            mru.getNameOrOID());
             throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
                                          message);
           }
@@ -3112,15 +3112,15 @@
     if ((existingMRUForRule != null) && (existingMRUForRule != existingMRU))
     {
       LocalizableMessage message = ERR_SCHEMA_MODIFY_MR_CONFLICT_FOR_ADD_MR_USE.
-          get(matchingRuleUse.getName(), matchingRule.getNameOrOID(),
-              existingMRUForRule.getName());
+          get(matchingRuleUse.getNameOrOID(), matchingRule.getNameOrOID(),
+              existingMRUForRule.getNameOrOID());
       throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
     }
 
     if (matchingRule.isObsolete())
     {
       LocalizableMessage message = ERR_SCHEMA_MODIFY_MRU_OBSOLETE_MR.get(
-          matchingRuleUse.getName(), matchingRule.getNameOrOID());
+          matchingRuleUse.getNameOrOID(), matchingRule.getNameOrOID());
       throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
     }
 
@@ -3132,13 +3132,13 @@
       if (! schema.hasAttributeType(at.getOID()))
       {
         LocalizableMessage message = ERR_SCHEMA_MODIFY_MRU_UNDEFINED_ATTR.get(
-            matchingRuleUse.getName(), at.getNameOrOID());
+            matchingRuleUse.getNameOrOID(), at.getNameOrOID());
         throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
       }
       else if (at.isObsolete())
       {
         LocalizableMessage message = ERR_SCHEMA_MODIFY_MRU_OBSOLETE_ATTR.get(
-            matchingRuleUse.getName(), matchingRule.getNameOrOID());
+            matchingRuleUse.getNameOrOID(), matchingRule.getNameOrOID());
         throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
       }
     }
@@ -3236,7 +3236,7 @@
     if ((removeMRU == null) || (! removeMRU.equals(matchingRuleUse)))
     {
       LocalizableMessage message = ERR_SCHEMA_MODIFY_REMOVE_NO_SUCH_MR_USE.get(
-          matchingRuleUse.getName());
+          matchingRuleUse.getNameOrOID());
       throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
     }
 
diff --git a/opendj3-server-dev/src/server/org/opends/server/core/MatchingRuleConfigManager.java b/opendj3-server-dev/src/server/org/opends/server/core/MatchingRuleConfigManager.java
index b846240..29b4ca0 100644
--- a/opendj3-server-dev/src/server/org/opends/server/core/MatchingRuleConfigManager.java
+++ b/opendj3-server-dev/src/server/org/opends/server/core/MatchingRuleConfigManager.java
@@ -321,7 +321,7 @@
           {
             LocalizableMessage message =
                     WARN_CONFIG_SCHEMA_CANNOT_DELETE_MR_IN_USE_BY_MRU.get(
-                            matchingRule.getNameOrOID(), mru.getName());
+                            matchingRule.getNameOrOID(), mru.getNameOrOID());
             unacceptableReasons.add(message);
 
             configAcceptable = false;
@@ -458,7 +458,7 @@
             {
               LocalizableMessage message =
                       WARN_CONFIG_SCHEMA_CANNOT_DISABLE_MR_IN_USE_BY_MRU.get(
-                              matchingRule.getNameOrOID(), mru.getName());
+                              matchingRule.getNameOrOID(), mru.getNameOrOID());
               unacceptableReasons.add(message);
 
               configAcceptable = false;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/ConfigureWindowsService.java b/opendj3-server-dev/src/server/org/opends/server/tools/ConfigureWindowsService.java
index 4108796..94456e7 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/ConfigureWindowsService.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/ConfigureWindowsService.java
@@ -26,16 +26,10 @@
  */
 
 package org.opends.server.tools;
-import org.opends.guitools.controlpanel.util.Utilities;
+import java.io.*;
+
 import org.forgerock.i18n.LocalizableMessage;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.InputStreamReader;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintStream;
-
+import org.opends.guitools.controlpanel.util.Utilities;
 import org.opends.quicksetup.util.Utils;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.loggers.JDKLogging;
@@ -43,16 +37,11 @@
 import org.opends.server.util.DynamicConstants;
 import org.opends.server.util.SetupUtils;
 
-import com.forgerock.opendj.cli.ArgumentException;
-import com.forgerock.opendj.cli.ArgumentParser;
-import com.forgerock.opendj.cli.BooleanArgument;
-import com.forgerock.opendj.cli.CommonArguments;
-import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.*;
 
 import static org.opends.messages.ToolMessages.*;
-import static org.opends.server.util.ServerConstants.MAX_LINE_WIDTH;
+import static org.opends.server.util.ServerConstants.*;
 import static org.opends.server.util.StaticUtils.*;
-import static com.forgerock.opendj.cli.ArgumentConstants.*;
 
 /**
   * This class is used to configure the Windows service for this instance on
diff --git a/opendj3-server-dev/src/server/org/opends/server/types/CommonSchemaElements.java b/opendj3-server-dev/src/server/org/opends/server/types/CommonSchemaElements.java
index daa8c59..08d5628 100644
--- a/opendj3-server-dev/src/server/org/opends/server/types/CommonSchemaElements.java
+++ b/opendj3-server-dev/src/server/org/opends/server/types/CommonSchemaElements.java
@@ -581,9 +581,8 @@
    *          specifies the path to the schema file from which this
    *          schema definition was loaded.
    */
-  public final void toString(StringBuilder buffer,
-      boolean includeFileElement) {
-
+  private final void toString(StringBuilder buffer, boolean includeFileElement)
+  {
     buffer.append("( ");
     buffer.append(oid);
 
diff --git a/opendj3-server-dev/src/server/org/opends/server/types/DITStructureRule.java b/opendj3-server-dev/src/server/org/opends/server/types/DITStructureRule.java
index 5467c16..745f3bb 100644
--- a/opendj3-server-dev/src/server/org/opends/server/types/DITStructureRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/types/DITStructureRule.java
@@ -26,7 +26,6 @@
  */
 package org.opends.server.types;
 
-import org.forgerock.opendj.ldap.ByteString;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
@@ -35,13 +34,12 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.ByteString;
 import org.opends.server.schema.DITStructureRuleSyntax;
 
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-import static org.opends.server.util.ServerConstants.*;
 import static org.forgerock.util.Reject.*;
-
-
+import static org.opends.server.util.ServerConstants.*;
 
 /**
  * This class defines a DIT structure rule, which is used to indicate
@@ -367,9 +365,9 @@
    * @return  {@code true} if this DIT structure rule has one or more
    *          superior rules, or {@code false} if not.
    */
-  public boolean hasSuperiorRules()
+  boolean hasSuperiorRules()
   {
-    return ((superiorRules != null) && (! superiorRules.isEmpty()));
+    return superiorRules != null && !superiorRules.isEmpty();
   }
 
 
@@ -404,24 +402,6 @@
 
 
   /**
-   * Retrieves the value of the specified "extra" property for this
-   * DIT structure rule.
-   *
-   * @param  propertyName  The name of the "extra" property for which
-   *                       to retrieve the value.
-   *
-   * @return  The value of the specified "extra" property for this DIT
-   *          structure rule, or {@code null} if no such property is
-   *          defined.
-   */
-  public List<String> getExtraProperty(String propertyName)
-  {
-    return extraProperties.get(propertyName);
-  }
-
-
-
-  /**
    * Specifies the provided "extra" property for this DIT structure
    * rule.
    *
@@ -430,7 +410,7 @@
    * @param  value  The value for the "extra" property, or
    *                {@code null} if the property is to be removed.
    */
-  public void setExtraProperty(String name, String value)
+  private void setExtraProperty(String name, String value)
   {
     ifNull(name);
 
@@ -450,32 +430,6 @@
 
 
   /**
-   * Specifies the provided "extra" property for this DIT structure
-   * rule.
-   *
-   * @param  name    The name for the "extra" property.  It must not
-   *                 be {@code null}.
-   * @param  values  The set of value for the "extra" property, or
-   *                 {@code null} if the property is to be removed.
-   */
-  public void setExtraProperty(String name, List<String> values)
-  {
-    ifNull(name);
-
-    if ((values == null) || values.isEmpty())
-    {
-      extraProperties.remove(name);
-    }
-    else
-    {
-      LinkedList<String> valuesCopy = new LinkedList<String>(values);
-      extraProperties.put(name, valuesCopy);
-    }
-  }
-
-
-
-  /**
    * Indicates whether the provided object is equal to this DIT
    * structure rule.  The object will be considered equal if it is a
    * DIT structure rule with the same OID as the current type.
@@ -542,8 +496,7 @@
    *                             path to the schema file from which
    *                             this DIT structure rule was loaded.
    */
-  public void toString(StringBuilder buffer,
-                       boolean includeFileElement)
+  private void toString(StringBuilder buffer, boolean includeFileElement)
   {
     buffer.append("( ");
     buffer.append(ruleID);
diff --git a/opendj3-server-dev/src/server/org/opends/server/types/MatchingRuleUse.java b/opendj3-server-dev/src/server/org/opends/server/types/MatchingRuleUse.java
index a6dc5bf..d965501 100644
--- a/opendj3-server-dev/src/server/org/opends/server/types/MatchingRuleUse.java
+++ b/opendj3-server-dev/src/server/org/opends/server/types/MatchingRuleUse.java
@@ -26,7 +26,6 @@
  */
 package org.opends.server.types;
 
-import org.forgerock.opendj.ldap.ByteString;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
@@ -35,14 +34,13 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.ByteString;
 import org.opends.server.api.MatchingRule;
 import org.opends.server.schema.MatchingRuleUseSyntax;
 
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-import static org.opends.server.util.ServerConstants.*;
 import static org.forgerock.util.Reject.*;
-
-
+import static org.opends.server.util.ServerConstants.*;
 
 /**
  * This class defines a data structure for storing and interacting
@@ -242,7 +240,7 @@
    * @return  The primary name to use when referencing this matching
    *          rule use, or {@code null} if there is none.
    */
-  public String getName()
+  public String getNameOrOID()
   {
     if (names.isEmpty())
     {
@@ -359,7 +357,7 @@
    *          referenced by this matching rule use, or {@code false}
    *          if it is not.
    */
-  public boolean appliesToAttribute(AttributeType attributeType)
+  boolean appliesToAttribute(AttributeType attributeType)
   {
     return attributes.contains(attributeType);
   }
@@ -383,24 +381,6 @@
 
 
   /**
-   * Retrieves the value of the specified "extra" property for this
-   * matching rule use.
-   *
-   * @param  propertyName  The name of the "extra" property for which
-   *                       to retrieve the value.
-   *
-   * @return  The value of the specified "extra" property for this
-   *          matching rule use, or {@code null} if no such property
-   *          is defined.
-   */
-  public List<String> getExtraProperty(String propertyName)
-  {
-    return extraProperties.get(propertyName);
-  }
-
-
-
-  /**
    * Specifies the provided "extra" property for this matching rule
    * use.
    *
@@ -409,7 +389,7 @@
    * @param  value  The value for the "extra" property, or
    *                {@code null} if the property is to be removed.
    */
-  public void setExtraProperty(String name, String value)
+  private void setExtraProperty(String name, String value)
   {
     ifNull(name);
 
@@ -429,32 +409,6 @@
 
 
   /**
-   * Specifies the provided "extra" property for this matching rule
-   * use.
-   *
-   * @param  name    The name for the "extra" property.  It must not
-   *                 be {@code null}.
-   * @param  values  The set of value for the "extra" property, or
-   *                 {@code null} if the property is to be removed.
-   */
-  public void setExtraProperty(String name, List<String> values)
-  {
-    ifNull(name);
-
-    if ((values == null) || values.isEmpty())
-    {
-      extraProperties.remove(name);
-    }
-    else
-    {
-      LinkedList<String> valuesCopy = new LinkedList<String>(values);
-      extraProperties.put(name, valuesCopy);
-    }
-  }
-
-
-
-  /**
    * Indicates whether the provided object is equal to this matching
    * rule use.  The object will be considered equal if it is a
    * matching rule use with the same matching rule.
@@ -521,8 +475,7 @@
    *                             path to the schema file from which
    *                             this matching rule use was loaded.
    */
-  public void toString(StringBuilder buffer,
-                       boolean includeFileElement)
+  private void toString(StringBuilder buffer, boolean includeFileElement)
   {
     buffer.append("( ");
     buffer.append(matchingRule.getOID());
diff --git a/opendj3-server-dev/src/server/org/opends/server/types/NameForm.java b/opendj3-server-dev/src/server/org/opends/server/types/NameForm.java
index 674bf32..ecd8b85 100644
--- a/opendj3-server-dev/src/server/org/opends/server/types/NameForm.java
+++ b/opendj3-server-dev/src/server/org/opends/server/types/NameForm.java
@@ -26,7 +26,6 @@
  */
 package org.opends.server.types;
 
-import org.forgerock.opendj.ldap.ByteString;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
@@ -35,13 +34,12 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.ByteString;
 import org.opends.server.schema.NameFormSyntax;
 
-import org.forgerock.i18n.slf4j.LocalizedLogger;
-import static org.opends.server.util.ServerConstants.*;
 import static org.forgerock.util.Reject.*;
-
-
+import static org.opends.server.util.ServerConstants.*;
 
 /**
  * This class defines a data structure for storing and interacting
@@ -484,24 +482,6 @@
 
 
   /**
-   * Retrieves the value of the specified "extra" property for this
-   * name form.
-   *
-   * @param  propertyName  The name of the "extra" property for which
-   *                       to retrieve the value.
-   *
-   * @return  The value of the specified "extra" property for this
-   *          name form, or {@code null} if no such property is
-   *          defined.
-   */
-  public List<String> getExtraProperty(String propertyName)
-  {
-    return extraProperties.get(propertyName);
-  }
-
-
-
-  /**
    * Specifies the provided "extra" property for this name form.
    *
    * @param  name   The name for the "extra" property.  It must not be
@@ -509,7 +489,7 @@
    * @param  value  The value for the "extra" property, or
    *                {@code null} if the property is to be removed.
    */
-  public void setExtraProperty(String name, String value)
+  private void setExtraProperty(String name, String value)
   {
     ifNull(name);
 
@@ -529,31 +509,6 @@
 
 
   /**
-   * Specifies the provided "extra" property for this name form.
-   *
-   * @param  name    The name for the "extra" property.  It must not
-   *                 be {@code null}.
-   * @param  values  The set of value for the "extra" property, or
-   *                 {@code null} if the property is to be removed.
-   */
-  public void setExtraProperty(String name, List<String> values)
-  {
-    ifNull(name);
-
-    if ((values == null) || values.isEmpty())
-    {
-      extraProperties.remove(name);
-    }
-    else
-    {
-      LinkedList<String> valuesCopy = new LinkedList<String>(values);
-      extraProperties.put(name, valuesCopy);
-    }
-  }
-
-
-
-  /**
    * Indicates whether the provided object is equal to this name form.
    * The object will be considered equal if it is a name form with the
    * same OID as the current name form.
@@ -627,8 +582,7 @@
    *                             path to the schema file from which
    *                             this name form was loaded.
    */
-  public void toString(StringBuilder buffer,
-                       boolean includeFileElement)
+  private void toString(StringBuilder buffer, boolean includeFileElement)
   {
     buffer.append("( ");
     buffer.append(oid);
diff --git a/opendj3-server-dev/src/server/org/opends/server/types/Schema.java b/opendj3-server-dev/src/server/org/opends/server/types/Schema.java
index 85918f4..db6ec9c 100644
--- a/opendj3-server-dev/src/server/org/opends/server/types/Schema.java
+++ b/opendj3-server-dev/src/server/org/opends/server/types/Schema.java
@@ -2348,9 +2348,9 @@
                                matchingRuleUses.get(matchingRule);
 
           LocalizableMessage message = ERR_SCHEMA_CONFLICTING_MATCHING_RULE_USE.
-              get(matchingRuleUse.getName(),
+              get(matchingRuleUse.getNameOrOID(),
                   matchingRule.getNameOrOID(),
-                  conflictingUse.getName());
+                  conflictingUse.getNameOrOID());
           throw new DirectoryException(
                          ResultCode.CONSTRAINT_VIOLATION, message);
         }
diff --git a/opendj3-server-dev/src/server/org/opends/server/types/SearchFilter.java b/opendj3-server-dev/src/server/org/opends/server/types/SearchFilter.java
index 09d4546..502c612 100644
--- a/opendj3-server-dev/src/server/org/opends/server/types/SearchFilter.java
+++ b/opendj3-server-dev/src/server/org/opends/server/types/SearchFilter.java
@@ -3315,7 +3315,7 @@
                 "Attribute type %s is not allowed for use with " +
                 "matching rule %s because of matching rule use " +
                 "definition %s", attributeType.getNameOrOID(),
-                matchingRule.getNameOrOID(), mru.getName());
+                matchingRule.getNameOrOID(), mru.getNameOrOID());
           }
           return ConditionResult.UNDEFINED;
         }

--
Gitblit v1.10.0