From e25d897908d93ab4f9cabadb1029ad3352602d5d Mon Sep 17 00:00:00 2001
From: boli <boli@localhost>
Date: Wed, 31 Oct 2007 22:19:14 +0000
Subject: [PATCH] This set of fixes mainly address the issues where the JE backend does not handle attributes with options and subtypes correctly when they are being indexed.  With this fix: - All values of an indexed attribute type will be indexed correctly on modifies, adds, and deletes.  - Updates to subordinate types will now update the superior type if its indexed.  - Adding and deleting superior attribute types that are not allowed by any object classes (ie. name) will be correctly handled - Deleting all values from an attribute with no options will no longer delete the values from the same attribute but with options.  

---
 opends/src/server/org/opends/server/backends/jeb/ApproximateIndexer.java |   32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/opends/src/server/org/opends/server/backends/jeb/ApproximateIndexer.java b/opends/src/server/org/opends/server/backends/jeb/ApproximateIndexer.java
index bf42103..84ffd2a 100644
--- a/opends/src/server/org/opends/server/backends/jeb/ApproximateIndexer.java
+++ b/opends/src/server/org/opends/server/backends/jeb/ApproximateIndexer.java
@@ -176,7 +176,37 @@
                           Set<ASN1OctetString> addKeys,
                           Set<ASN1OctetString> delKeys)
   {
-    replaceEntry(txn, oldEntry, newEntry, addKeys, delKeys);
+    List<Attribute> newAttributes = newEntry.getAttribute(attributeType, true);
+    List<Attribute> oldAttributes = oldEntry.getAttribute(attributeType, true);
+    HashSet<AttributeValue> newValues;
+    HashSet<AttributeValue> oldValues;
+
+    if(newAttributes == null)
+    {
+      indexAttribute(oldAttributes, delKeys);
+    }
+    else
+    {
+      if(oldAttributes == null)
+      {
+        indexAttribute(newAttributes, addKeys);
+      }
+      else
+      {
+        HashSet<ASN1OctetString> newKeys =
+            new HashSet<ASN1OctetString>();
+        HashSet<ASN1OctetString> oldKeys =
+            new HashSet<ASN1OctetString>();
+        indexAttribute(newAttributes, newKeys);
+        indexAttribute(oldAttributes, oldKeys);
+
+        addKeys.addAll(newKeys);
+        addKeys.removeAll(oldKeys);
+
+        delKeys.addAll(oldKeys);
+        delKeys.removeAll(newKeys);
+      }
+    }
   }
 
   /**

--
Gitblit v1.10.0