From c5f739d0a79784332c08824bab6fb55586a8a37a Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Sun, 23 Sep 2007 06:14:00 +0000
Subject: [PATCH] Fix a problem in the LDIF backend in which references to subordinate entries were not properly updated for modify DN operations.

---
 opendj-sdk/opends/src/server/org/opends/server/backends/LDIFBackend.java |   28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/backends/LDIFBackend.java b/opendj-sdk/opends/src/server/org/opends/server/backends/LDIFBackend.java
index 6b29124..98d81d7 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/backends/LDIFBackend.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/backends/LDIFBackend.java
@@ -863,14 +863,36 @@
         throw new DirectoryException(ResultCode.ENTRY_ALREADY_EXISTS, m);
       }
 
-      DN parentDN = newDN.getParentDNInSuffix();
-      if (! entryMap.containsKey(parentDN))
+      DN newParentDN = newDN.getParentDNInSuffix();
+      if (! entryMap.containsKey(newParentDN))
       {
         Message m = ERR_LDIF_BACKEND_MODDN_NEW_PARENT_DOESNT_EXIST.get(
-                         String.valueOf(parentDN));
+                         String.valueOf(newParentDN));
         throw new DirectoryException(ResultCode.NO_SUCH_OBJECT, m);
       }
 
+      // Remove the entry from the list of children for the old parent and
+      // add the new entry DN to the set of children for the new parent.
+      DN oldParentDN = currentDN.getParentDNInSuffix();
+      HashSet<DN> parentChildDNs = childDNs.get(oldParentDN);
+      if (parentChildDNs != null)
+      {
+        parentChildDNs.remove(currentDN);
+        if (parentChildDNs.isEmpty() &&
+            (modifyDNOperation.getNewSuperior() != null))
+        {
+          childDNs.remove(oldParentDN);
+        }
+      }
+
+      parentChildDNs = childDNs.get(newParentDN);
+      if (parentChildDNs == null)
+      {
+        parentChildDNs = new HashSet<DN>();
+        childDNs.put(newParentDN, parentChildDNs);
+      }
+      parentChildDNs.add(newDN);
+
 
       // If the entry has children, then we'll need to work on the whole
       // subtree.  Otherwise, just work on the target entry.

--
Gitblit v1.10.0