From a90890af51b755a0a6862a32306b1a979d5a9612 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 11 Mar 2014 13:42:19 +0000
Subject: [PATCH] OPENDJ-1368 (CR-3157) Remove AttributeValue

---
 opendj3-server-dev/src/server/org/opends/server/backends/jeb/VerifyJob.java |   34 +++++++++++-----------------------
 1 files changed, 11 insertions(+), 23 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/VerifyJob.java b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/VerifyJob.java
index 6677630..cace05a 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/jeb/VerifyJob.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/jeb/VerifyJob.java
@@ -34,9 +34,8 @@
 import org.forgerock.opendj.ldap.ConditionResult;
 import org.forgerock.opendj.ldap.DecodeException;
 import org.forgerock.opendj.ldap.ResultCode;
-import org.opends.server.api.ApproximateMatchingRule;
+import org.opends.server.api.EqualityMatchingRule;
 import org.opends.server.api.MatchingRule;
-import org.opends.server.api.OrderingMatchingRule;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.types.*;
 import org.opends.server.util.ServerConstants;
@@ -1629,18 +1628,20 @@
 
     for (Attribute attr : attrList)
     {
+      final AttributeType attrType = attr.getAttributeType();
+      EqualityMatchingRule equalityRule = attrType.getEqualityMatchingRule();
       for (AttributeValue value : attr)
       {
-        byte[] normalizedBytes = value.getNormalizedValue().toByteArray();
+        final ByteString bsValue = value.getValue();
+        byte[] normalizedBytes = normalize(equalityRule, bsValue);
 
-        // Equality index.
         if (equalityIndex != null)
         {
+          // TODO JNR reuse DatabaseEntry object for all indexes?
           DatabaseEntry key = new DatabaseEntry(normalizedBytes);
           verifyAttributeInIndex(equalityIndex, txn, key, entryID);
         }
 
-        // Substring index.
         if (substringIndex != null)
         {
           Set<ByteString> keyBytesSet =
@@ -1653,28 +1654,16 @@
           }
         }
 
-        // Ordering index.
         if (orderingIndex != null)
         {
-          // Use the ordering matching rule to normalize the value.
-          OrderingMatchingRule orderingRule =
-              attr.getAttributeType().getOrderingMatchingRule();
-
-          normalizedBytes = normalizeAttributeValue(orderingRule, value);
-
+          normalizedBytes = normalize(attrType.getOrderingMatchingRule(), bsValue);
           DatabaseEntry key = new DatabaseEntry(normalizedBytes);
           verifyAttributeInIndex(orderingIndex, txn, key, entryID);
         }
 
-        // Approximate index.
         if (approximateIndex != null)
         {
-          // Use the approximate matching rule to normalize the value.
-          ApproximateMatchingRule approximateRule =
-              attr.getAttributeType().getApproximateMatchingRule();
-
-          normalizedBytes = normalizeAttributeValue(approximateRule, value);
-
+          normalizedBytes = normalize(attrType.getApproximateMatchingRule(), bsValue);
           DatabaseEntry key = new DatabaseEntry(normalizedBytes);
           verifyAttributeInIndex(approximateIndex, txn, key, entryID);
         }
@@ -1717,13 +1706,12 @@
     }
   }
 
-  private byte[] normalizeAttributeValue(MatchingRule matchingRule,
-      AttributeValue value) throws DirectoryException
+  private byte[] normalize(MatchingRule matchingRule,
+      ByteString value) throws DirectoryException
   {
     try
     {
-      return matchingRule.normalizeAttributeValue(value.getValue())
-          .toByteArray();
+      return matchingRule.normalizeAttributeValue(value).toByteArray();
     }
     catch (DecodeException e)
     {

--
Gitblit v1.10.0