From 2d7aad2c25507ea427980b54848c26594c607ae2 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 20 Feb 2014 11:20:22 +0000
Subject: [PATCH] OPENDJ-1308 Migrate schema support

---
 opendj3-server-dev/src/server/org/opends/server/api/AbstractMatchingRule.java |   42 +++++++++++++++++++++++++++++++++++++-----
 1 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/api/AbstractMatchingRule.java b/opendj3-server-dev/src/server/org/opends/server/api/AbstractMatchingRule.java
index 1f31185..b03077a 100644
--- a/opendj3-server-dev/src/server/org/opends/server/api/AbstractMatchingRule.java
+++ b/opendj3-server-dev/src/server/org/opends/server/api/AbstractMatchingRule.java
@@ -28,12 +28,13 @@
 
 import java.util.Collection;
 
+import org.forgerock.opendj.ldap.Assertion;
 import org.forgerock.opendj.ldap.ByteSequence;
 import org.forgerock.opendj.ldap.ByteString;
 import org.forgerock.opendj.ldap.ConditionResult;
+import org.forgerock.opendj.ldap.DecodeException;
 import org.forgerock.opendj.ldap.schema.Schema;
 import org.forgerock.opendj.ldap.schema.Syntax;
-import org.opends.server.types.DirectoryException;
 
 /**
  * This class provides default implementation of MatchingRule. A
@@ -53,7 +54,7 @@
    */
   @Override
   public ByteString normalizeAssertionValue(ByteSequence value)
-      throws DirectoryException
+      throws DecodeException
   {
     // Default implementation is to use attribute value normalization.
     return normalizeAttributeValue(value);
@@ -93,16 +94,47 @@
 
   /** {@inheritDoc} */
   @Override
+  public Assertion getAssertion(final ByteSequence value)
+      throws DecodeException
+  {
+    final ByteString assertionValue = normalizeAssertionValue(value);
+    return new Assertion()
+    {
+
+      @Override
+      public ConditionResult matches(ByteSequence attributeValue)
+      {
+        return valuesMatch(attributeValue, assertionValue);
+      }
+    };
+  }
+
+  /** {@inheritDoc} */
+  @Override
   public boolean isObsolete()
   {
     return false;
   }
 
   /**
-   * {@inheritDoc}
+   * Indicates whether the provided attribute value should be
+   * considered a match for the given assertion value. This will only
+   * be used for the purpose of extensible matching. Subclasses
+   * should define more specific methods that are appropriate to the
+   * matching rule type.
+   *
+   * @param attributeValue
+   *          The attribute value in a form that has been normalized
+   *          according to this matching rule.
+   * @param assertionValue
+   *          The assertion value in a form that has been normalized
+   *          according to this matching rule.
+   * @return {@code TRUE} if the attribute value should be considered
+   *         a match for the provided assertion value, {@code FALSE}
+   *         if it does not match, or {@code UNDEFINED} if the result
+   *         is undefined.
    */
-  @Override
-  public ConditionResult valuesMatch(
+  protected ConditionResult valuesMatch(
       ByteSequence attributeValue, ByteSequence assertionValue)
   {
     //Default implementation of most rule types.

--
Gitblit v1.10.0