From 3d0432b70360e04c423d82bf5dcd78cfb98417bb Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 03 Jun 2016 06:45:18 +0000
Subject: [PATCH] OPENDJ-3037 Inlined DirectoryServer.getMatchingRuleUse()

---
 opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java |   24 ------------------------
 opendj-server-legacy/src/main/java/org/opends/server/types/SearchFilter.java   |   19 ++++++++++---------
 2 files changed, 10 insertions(+), 33 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java b/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
index b70e9a2..9db8ff4 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
@@ -72,12 +72,9 @@
 import org.forgerock.opendj.ldap.ResultCode;
 import org.forgerock.opendj.ldap.schema.AttributeType;
 import org.forgerock.opendj.ldap.schema.DITContentRule;
-import org.forgerock.opendj.ldap.schema.MatchingRule;
-import org.forgerock.opendj.ldap.schema.MatchingRuleUse;
 import org.forgerock.opendj.ldap.schema.NameForm;
 import org.forgerock.opendj.ldap.schema.ObjectClass;
 import org.forgerock.opendj.ldap.schema.Syntax;
-import org.forgerock.opendj.ldap.schema.UnknownSchemaElementException;
 import org.forgerock.opendj.server.config.server.AlertHandlerCfg;
 import org.forgerock.opendj.server.config.server.ConnectionHandlerCfg;
 import org.forgerock.opendj.server.config.server.CryptoManagerCfg;
@@ -2362,27 +2359,6 @@
   }
 
   /**
-   * Retrieves the matching rule use associated with the provided matching rule.
-   *
-   * @param  matchingRule  The matching rule for which to retrieve the matching
-   *                       rule use.
-   *
-   * @return  The matching rule use for the provided matching rule, or
-   *          {@code null} if none is defined.
-   */
-  public static MatchingRuleUse getMatchingRuleUse(MatchingRule matchingRule)
-  {
-    try
-    {
-      return directoryServer.schema.getMatchingRuleUse(matchingRule);
-    }
-    catch (UnknownSchemaElementException e)
-    {
-      return null;
-    }
-  }
-
-  /**
    * Retrieves the DIT content rule associated with the specified objectclass.
    *
    * @param  objectClass  The objectclass for which to retrieve the associated
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/SearchFilter.java b/opendj-server-legacy/src/main/java/org/opends/server/types/SearchFilter.java
index d801f15..764d835 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/SearchFilter.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/types/SearchFilter.java
@@ -3226,18 +3226,19 @@
     // determine if it allows that attribute type.
     if (attributeType != null)
     {
-      MatchingRuleUse mru = DirectoryServer.getMatchingRuleUse(matchingRule);
-      if (mru != null && !mru.hasAttribute(attributeType))
+      try
       {
-        if (logger.isTraceEnabled())
+        MatchingRuleUse mru = DirectoryServer.getSchema().getMatchingRuleUse(matchingRule);
+        if (!mru.hasAttribute(attributeType))
         {
-          logger.trace(
-              "Attribute type %s is not allowed for use with " +
-              "matching rule %s because of matching rule use " +
-              "definition %s", attributeType.getNameOrOID(),
-              matchingRule.getNameOrOID(), mru.getNameOrOID());
+          logger.trace("Attribute type %s is not allowed for use with "
+              + "matching rule %s because of matching rule use definition %s",
+              attributeType.getNameOrOID(), matchingRule.getNameOrOID(), mru.getNameOrOID());
+          return ConditionResult.UNDEFINED;
         }
-        return ConditionResult.UNDEFINED;
+      }
+      catch (UnknownSchemaElementException ignored)
+      {
       }
     }
 

--
Gitblit v1.10.0