From 5008a279581d6b54c99a623a9b297d889221870b Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Fri, 13 Apr 2007 04:04:37 +0000
Subject: [PATCH] Fix a problem in the memory backend in that it stores entries with virtual attributes, which doesn't properly handle changes to virtual attribute rules. Update the backend so that it stores the entries without the virtual attributes and then computes them in a copy whenever the entries are accessed.

---
 opends/src/server/org/opends/server/backends/MemoryBackend.java |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/opends/src/server/org/opends/server/backends/MemoryBackend.java b/opends/src/server/org/opends/server/backends/MemoryBackend.java
index 3dda52d..dc97a0d 100644
--- a/opends/src/server/org/opends/server/backends/MemoryBackend.java
+++ b/opends/src/server/org/opends/server/backends/MemoryBackend.java
@@ -271,7 +271,13 @@
    */
   public synchronized Entry getEntry(DN entryDN)
   {
-    return entryMap.get(entryDN);
+    Entry entry = entryMap.get(entryDN);
+    if (entry != null)
+    {
+      entry = entry.duplicate(true);
+    }
+
+    return entry;
   }
 
 
@@ -292,7 +298,7 @@
   public synchronized void addEntry(Entry entry, AddOperation addOperation)
          throws DirectoryException
   {
-    Entry e = entry.duplicate(true);
+    Entry e = entry.duplicate(false);
 
     // See if the target entry already exists.  If so, then fail.
     DN entryDN = e.getDN();
@@ -438,7 +444,7 @@
                                         ModifyOperation modifyOperation)
          throws DirectoryException
   {
-    Entry e = entry.duplicate(true);
+    Entry e = entry.duplicate(false);
 
     // Make sure the entry exists.  If not, then throw an exception.
     DN entryDN = e.getDN();
@@ -463,7 +469,7 @@
                                        ModifyDNOperation modifyDNOperation)
          throws DirectoryException
   {
-    Entry e = entry.duplicate(true);
+    Entry e = entry.duplicate(false);
 
     // Make sure that the target entry exists.
     if (! entryMap.containsKey(currentDN))
@@ -573,6 +579,11 @@
                                    matchedDN, null);
     }
 
+    if (baseEntry != null)
+    {
+      baseEntry = baseEntry.duplicate(true);
+    }
+
 
     // If it's a base-level search, then just get that entry and return it if it
     // matches the filter.
@@ -588,6 +599,7 @@
       // Walk through all entries and send the ones that match.
       for (Entry e : entryMap.values())
       {
+        e = e.duplicate(true);
         if (e.matchesBaseAndScope(baseDN, scope) && filter.matchesEntry(e))
         {
           searchOperation.returnEntry(e, new LinkedList<Control>());

--
Gitblit v1.10.0