From 1e53194379b3b80e4d2a026865c0dde59bbf6ed1 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 28 Jun 2016 13:17:43 +0000
Subject: [PATCH] OPENDJ-2715 Incorrect "exclude" message when importing entries with an exclude filter

---
 opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java |   28 +++++++++++-----------------
 1 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java b/opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java
index b074724..81a2bfa 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/util/LDIFReader.java
@@ -46,6 +46,8 @@
 import org.forgerock.opendj.ldap.RDN;
 import org.forgerock.opendj.ldap.schema.AttributeType;
 import org.forgerock.opendj.ldap.schema.CoreSchema;
+import org.forgerock.opendj.ldap.schema.ObjectClass;
+import org.forgerock.util.Pair;
 import org.opends.server.api.plugin.PluginResult;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.core.PluginConfigManager;
@@ -57,7 +59,6 @@
 import org.opends.server.types.Attributes;
 import org.opends.server.types.Entry;
 import org.opends.server.types.LDIFImportConfig;
-import org.forgerock.opendj.ldap.schema.ObjectClass;
 import org.opends.server.types.RawModification;
 
 /**
@@ -200,29 +201,24 @@
         // read and return the next entry.
         continue;
       }
-      else if (!importConfig.includeEntry(entryDN))
+
+      entriesRead.incrementAndGet();
+      Pair<Boolean, LocalizableMessage> includeResult = importConfig.includeEntry(entryDN);
+      if (!includeResult.getFirst())
       {
-        logger.trace("Skipping entry %s because the DN is not one that "
-            + "should be included based on the include and exclude branches.", entryDN);
-        entriesRead.incrementAndGet();
-        logToSkipWriter(lines, ERR_LDIF_SKIP.get(entryDN));
+        logToSkipWriter(lines, includeResult.getSecond());
         continue;
       }
-      else
-      {
-        entriesRead.incrementAndGet();
-      }
 
-      // Create the entry and see if it is one that should be included in the import.
       final Entry entry = createEntry(entryDN, lines, checkSchema);
       if (!isIncludedInImport(entry,lines)
           || !invokeImportPlugins(entry, lines))
       {
         continue;
       }
-      validateAgainstSchemaIfNeeded(checkSchema, entry, lines);
 
       // The entry should be included in the import, so return it.
+      validateAgainstSchemaIfNeeded(checkSchema, entry, lines);
       return entry;
     }
   }
@@ -247,12 +243,10 @@
   {
     try
     {
-      if (!importConfig.includeEntry(entry))
+      Pair<Boolean, LocalizableMessage> includeResult = importConfig.includeEntry(entry);
+      if (!includeResult.getFirst())
       {
-        final DN entryDN = entry.getName();
-        logger.trace("Skipping entry %s because the DN is not one that "
-            + "should be included based on the include and exclude filters.", entryDN);
-        logToSkipWriter(lines, ERR_LDIF_SKIP.get(entryDN));
+        logToSkipWriter(lines, includeResult.getSecond());
         return false;
       }
       return true;

--
Gitblit v1.10.0