From a9f9fcc56c81c61857eea46e019e8426b089eca3 Mon Sep 17 00:00:00 2001
From: dugan <dugan@localhost>
Date: Fri, 21 Aug 2009 20:13:18 +0000
Subject: [PATCH] Fix for issue 4178: Only base entry visible after on-line import

---
 opends/resource/schema/02-config.ldif                                     |   12 ++++++++++++
 opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java |   22 +++++++++++-----------
 opends/src/server/org/opends/server/tasks/ImportTask.java                 |    2 +-
 3 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/opends/resource/schema/02-config.ldif b/opends/resource/schema/02-config.ldif
index c5b0085..7cf8c0c 100644
--- a/opends/resource/schema/02-config.ldif
+++ b/opends/resource/schema/02-config.ldif
@@ -885,6 +885,11 @@
   SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
   SINGLE-VALUE
   X-ORIGIN 'OpenDS Directory Server' )
+attributeTypes: ( 1.3.6.1.4.1.26027.1.1.598
+  NAME 'ds-task-import-tmp-directory'
+  SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
+  SINGLE-VALUE
+  X-ORIGIN 'OpenDS Directory Server' )
 attributeTypes: ( 1.3.6.1.4.1.26027.1.1.180
   NAME 'ds-task-import-overwrite-rejects'
   SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
@@ -895,6 +900,11 @@
   SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
   SINGLE-VALUE
   X-ORIGIN 'OpenDS Directory Server' )
+attributeTypes: ( 1.3.6.1.4.1.26027.1.1.597
+  NAME 'ds-task-import-skip-dn-validation'
+  SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
+  SINGLE-VALUE
+  X-ORIGIN 'OpenDS Directory Server' )
 attributeTypes: ( 1.3.6.1.4.1.26027.1.1.519
   NAME 'ds-task-import-skip-file'
   SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
@@ -3083,6 +3093,8 @@
         ds-task-import-overwrite-rejects $
         ds-task-import-skip-file $
         ds-task-import-skip-schema-validation $
+        ds-task-import-skip-dn-validation $
+        ds-task-import-tmp-directory $
         ds-task-import-is-compressed $
         ds-task-import-is-encrypted $
         ds-task-import-backend-id $
diff --git a/opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java b/opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java
index aac3a7a..2349132 100644
--- a/opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java
+++ b/opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java
@@ -1607,7 +1607,6 @@
         dbValue1.setData(v);
         DN dn = DN.decode(ByteString.wrap(dbKey1.getData()));
 
-
         entryID = new EntryID(v1);
         if(parentIDMap.isEmpty())
         {
@@ -1633,16 +1632,17 @@
         }
         else
         {
-          DN pDN = entryContainer.getParentWithinBase(dn);
-          if(parentIDMap.containsKey(pDN)) {
-            DN lastKey = parentIDMap.lastKey();
-            Map<DN, EntryID> subMap = parentIDMap.subMap(pDN, lastKey);
-            for(Map.Entry<DN, EntryID> e : subMap.entrySet())
-            {
-              subMap.remove(e.getKey());
+          DN newParentDN = entryContainer.getParentWithinBase(dn);
+          if(parentIDMap.containsKey(newParentDN))
+          {
+            EntryID newParentID = parentIDMap.get(newParentDN);
+            DN lastDN = parentIDMap.lastKey();
+            while(!newParentDN.equals(lastDN)) {
+              parentIDMap.remove(lastDN);
+              lastDN = parentIDMap.lastKey();
             }
-            parentDN = pDN;
-            parentID = parentIDMap.get(pDN);
+            parentDN = newParentDN;
+            parentID = newParentID;
             lastDN = dn;
             lastID = entryID;
           }
@@ -1659,7 +1659,7 @@
       }
 
 
-    private void id2child(EntryID childID)
+      private void id2child(EntryID childID)
     {
       ImportIDSet idSet;
       if(!id2childTree.containsKey(parentID.getDatabaseEntry().getData()))
diff --git a/opends/src/server/org/opends/server/tasks/ImportTask.java b/opends/src/server/org/opends/server/tasks/ImportTask.java
index d185d19..51e589f 100644
--- a/opends/src/server/org/opends/server/tasks/ImportTask.java
+++ b/opends/src/server/org/opends/server/tasks/ImportTask.java
@@ -336,7 +336,7 @@
     append = TaskUtils.getBoolean(attrList, false);
 
     attrList = taskEntry.getAttribute(typeDNCheckPhase2);
-    skipDNValidation = TaskUtils.getBoolean(attrList, true);
+    skipDNValidation = TaskUtils.getBoolean(attrList, false);
 
     attrList = taskEntry.getAttribute(typeTmpDirectory);
     tmpDirectory = TaskUtils.getSingleValueString(attrList);

--
Gitblit v1.10.0