From 2f91821eb66d1500b9bbb493caba9c261b6a766a Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 20 May 2015 09:20:16 +0000
Subject: [PATCH] Decouple ImportLDIFReader from Importer.

---
 opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportLDIFReader.java |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportLDIFReader.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportLDIFReader.java
index dd98d28..5961507 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportLDIFReader.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ImportLDIFReader.java
@@ -163,7 +163,7 @@
           logToSkipWriter(lines, ERR_LDIF_SKIP.get(entryDN));
           continue;
         }
-        suffix = Importer.getMatchSuffix(entryDN, suffixesMap);
+        suffix = getMatchSuffix(entryDN, suffixesMap);
         if (suffix == null)
         {
           logger.trace("Skipping entry %s because the DN is not one that "
@@ -293,4 +293,28 @@
     }
     return true;
   }
+
+  /**
+   * Return the suffix instance in the specified map that matches the specified DN.
+   *
+   * @param dn
+   *          The DN to search for.
+   * @param map
+   *          The map to search.
+   * @return The suffix instance that matches the DN, or null if no match is found.
+   */
+  private Suffix getMatchSuffix(DN dn, Map<DN, Suffix> map)
+  {
+    DN nodeDN = dn;
+    while (nodeDN != null)
+    {
+      final Suffix suffix = map.get(nodeDN);
+      if (suffix != null)
+      {
+        return suffix;
+      }
+      nodeDN = nodeDN.getParentDNInSuffix();
+    }
+    return null;
+  }
 }

--
Gitblit v1.10.0