From 6b47d8afcb80c74e8c29d2702a38e8948056b462 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 27 Jan 2015 15:20:15 +0000
Subject: [PATCH] Code cleanup: Used Sets instead of Lists where it makes sense.
---
opendj3-server-dev/src/server/org/opends/server/api/Backend.java | 5
opendj3-server-dev/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java | 11
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestImportJob.java | 11
opendj3-server-dev/src/server/org/opends/server/tools/ImportLDIF.java | 292 ++++++------------
opendj3-server-dev/src/server/org/opends/server/types/LDIFImportConfig.java | 485 +++++++++-----------------------
opendj3-server-dev/src/server/org/opends/server/tasks/ImportTask.java | 78 +---
6 files changed, 270 insertions(+), 612 deletions(-)
diff --git a/opendj3-server-dev/src/server/org/opends/server/api/Backend.java b/opendj3-server-dev/src/server/org/opends/server/api/Backend.java
index 77beb1e..849e907 100644
--- a/opendj3-server-dev/src/server/org/opends/server/api/Backend.java
+++ b/opendj3-server-dev/src/server/org/opends/server/api/Backend.java
@@ -29,6 +29,7 @@
import static org.opends.messages.BackendMessages.*;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Queue;
@@ -1066,7 +1067,7 @@
* @return {@code true} if the backend should handle operations for
* the provided entry, or {@code false} if it does not.
*/
- public static final boolean handlesEntry(DN entryDN, List<DN> baseDNs, List<DN> excludeDNs)
+ public static final boolean handlesEntry(DN entryDN, Collection<DN> baseDNs, Collection<DN> excludeDNs)
{
for (DN baseDN : baseDNs)
{
@@ -1078,7 +1079,7 @@
return false;
}
- private static boolean isExcluded(List<DN> excludeDNs, DN entryDN)
+ private static boolean isExcluded(Collection<DN> excludeDNs, DN entryDN)
{
if (excludeDNs == null || excludeDNs.isEmpty())
{
diff --git a/opendj3-server-dev/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java b/opendj3-server-dev/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
index 7e692fa..6083abe 100644
--- a/opendj3-server-dev/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
+++ b/opendj3-server-dev/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
@@ -1272,13 +1272,10 @@
return list;
}
- private static <T> Set<T> newSet(T... elems)
+ private static <T> Set<T> newSet(T elem)
{
- final Set<T> list = new LinkedHashSet<T>(elems.length);
- for (T elem : elems)
- {
- list.add(elem);
- }
+ final Set<T> list = new LinkedHashSet<T>(1);
+ list.add(elem);
return list;
}
@@ -3578,7 +3575,7 @@
}
importConfig = new LDIFImportConfig(input);
- importConfig.setIncludeBranches(newList(getBaseDN()));
+ importConfig.setIncludeBranches(newSet(getBaseDN()));
importConfig.setAppendToExistingData(false);
importConfig.setSkipDNValidation(true);
// We should not validate schema for replication
diff --git a/opendj3-server-dev/src/server/org/opends/server/tasks/ImportTask.java b/opendj3-server-dev/src/server/org/opends/server/tasks/ImportTask.java
index 85fc865..71bfbec 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tasks/ImportTask.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tasks/ImportTask.java
@@ -239,10 +239,8 @@
Backend<?> backend = null;
ArrayList<DN> defaultIncludeBranches;
- ArrayList<DN> excludeBranches =
- new ArrayList<DN>(excludeBranchStrings.size());
- ArrayList<DN> includeBranches =
- new ArrayList<DN>(includeBranchStrings.size());
+ HashSet<DN> excludeBranches = new HashSet<DN>(excludeBranchStrings.size());
+ HashSet<DN> includeBranches = new HashSet<DN>(includeBranchStrings.size());
for (String s : includeBranchStrings)
{
@@ -264,10 +262,7 @@
throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
}
- if(! includeBranches.contains(includeBranch))
- {
- includeBranches.add(includeBranch);
- }
+ includeBranches.add(includeBranch);
}
for (String s : excludeBranchStrings)
{
@@ -289,10 +284,7 @@
throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
}
- if (! excludeBranches.contains(excludeBranch))
- {
- excludeBranches.add(excludeBranch);
- }
+ excludeBranches.add(excludeBranch);
}
for (String filterString : excludeFilterStrings)
@@ -487,11 +479,9 @@
// Get the backend into which the LDIF should be imported.
Backend<?> backend = null;
- ArrayList<DN> defaultIncludeBranches;
- ArrayList<DN> excludeBranches =
- new ArrayList<DN>(excludeBranchStrings.size());
- ArrayList<DN> includeBranches =
- new ArrayList<DN>(includeBranchStrings.size());
+ HashSet<DN> defaultIncludeBranches;
+ HashSet<DN> excludeBranches = new HashSet<DN>(excludeBranchStrings.size());
+ HashSet<DN> includeBranches = new HashSet<DN>(includeBranchStrings.size());
for (String s : includeBranchStrings)
{
@@ -511,10 +501,7 @@
return TaskState.STOPPED_BY_ERROR;
}
- if(! includeBranches.contains(includeBranch))
- {
- includeBranches.add(includeBranch);
- }
+ includeBranches.add(includeBranch);
}
if(backendID != null)
@@ -574,7 +561,7 @@
// Find backends with subordinate base DNs that should be excluded from the
// import.
- defaultIncludeBranches = new ArrayList<DN>(backend.getBaseDNs().length);
+ defaultIncludeBranches = new HashSet<DN>(backend.getBaseDNs().length);
for (DN dn : backend.getBaseDNs())
{
defaultIncludeBranches.add(dn);
@@ -588,14 +575,9 @@
{
for (DN importBase : defaultIncludeBranches)
{
- if (baseDN.isDescendantOf(importBase)
- && !baseDN.equals(importBase))
+ if (!baseDN.equals(importBase) && baseDN.isDescendantOf(importBase))
{
- if (! excludeBranches.contains(baseDN))
- {
- excludeBranches.add(baseDN);
- }
-
+ excludeBranches.add(baseDN);
break;
}
}
@@ -621,10 +603,7 @@
return TaskState.STOPPED_BY_ERROR;
}
- if (! excludeBranches.contains(excludeBranch))
- {
- excludeBranches.add(excludeBranch);
- }
+ excludeBranches.add(excludeBranch);
}
if (includeBranchStrings.isEmpty())
@@ -707,15 +686,8 @@
{
try
{
- ExistingFileBehavior existingBehavior;
- if (overwrite)
- {
- existingBehavior = ExistingFileBehavior.OVERWRITE;
- }
- else
- {
- existingBehavior = ExistingFileBehavior.APPEND;
- }
+ ExistingFileBehavior existingBehavior =
+ overwrite ? ExistingFileBehavior.OVERWRITE : ExistingFileBehavior.APPEND;
importConfig.writeRejectedEntries(rejectFile, existingBehavior);
}
@@ -730,15 +702,8 @@
{
try
{
- ExistingFileBehavior existingBehavior;
- if (overwrite)
- {
- existingBehavior = ExistingFileBehavior.OVERWRITE;
- }
- else
- {
- existingBehavior = ExistingFileBehavior.APPEND;
- }
+ ExistingFileBehavior existingBehavior =
+ overwrite ? ExistingFileBehavior.OVERWRITE : ExistingFileBehavior.APPEND;
importConfig.writeSkippedEntries(skipFile, existingBehavior);
}
catch (Exception e)
@@ -804,19 +769,16 @@
logger.traceException(de);
DirectoryServer.notifyImportEnded(backend, importConfig, false);
- LocalizableMessage message = null;
+ LocalizableMessage msg;
if (de.getResultCode() == ResultCode.CONSTRAINT_VIOLATION)
{
- message =
- ERR_LDIFIMPORT_ERROR_DURING_IMPORT
- .get(ERR_LDIFIMPORT_ERROR_CONSTRAINT_VIOLATION.get());
+ msg = ERR_LDIFIMPORT_ERROR_CONSTRAINT_VIOLATION.get();
}
else
{
- message = ERR_LDIFIMPORT_ERROR_DURING_IMPORT.get(
- de.getMessageObject());
+ msg = de.getMessageObject();
}
- logger.error(message);
+ logger.error(ERR_LDIFIMPORT_ERROR_DURING_IMPORT.get(msg));
return TaskState.STOPPED_BY_ERROR;
}
catch (Exception e)
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/ImportLDIF.java b/opendj3-server-dev/src/server/org/opends/server/tools/ImportLDIF.java
index f09ea69..eade487 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/ImportLDIF.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/ImportLDIF.java
@@ -40,6 +40,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Random;
+import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
@@ -118,8 +119,7 @@
/**
* Processes the command-line arguments and invokes the import process.
*
- * @param args The command-line arguments provided to thisprogram.
- *
+ * @param args The command-line arguments provided to this program.
* @return The error code.
*/
public static int mainImportLDIF(String[] args)
@@ -549,9 +549,10 @@
private void addAttribute2(List<RawAttribute> attributes, String attrName, Argument arg)
{
- if (arg.getValue() != null && !arg.getValue().equals(arg.getDefaultValue()))
+ final String value = arg.getValue();
+ if (value != null && !value.equals(arg.getDefaultValue()))
{
- attributes.add(new LDAPAttribute(attrName, toByteStrings(arg.getValue())));
+ attributes.add(new LDAPAttribute(attrName, toByteStrings(value)));
}
}
@@ -642,21 +643,9 @@
{
directoryServer.initializeSchema();
}
- catch (ConfigException ce)
- {
- LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(ce.getMessage());
- err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
- }
- catch (InitializationException ie)
- {
- LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(ie.getMessage());
- err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
- }
catch (Exception e)
{
- LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e));
+ LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(getMessage(e));
err.println(wrapText(message, MAX_LINE_WIDTH));
return 1;
}
@@ -668,24 +657,9 @@
CoreConfigManager coreConfigManager = new CoreConfigManager(directoryServer.getServerContext());
coreConfigManager.initializeCoreConfig();
}
- catch (ConfigException ce)
- {
- LocalizableMessage message = ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(
- ce.getMessage());
- err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
- }
- catch (InitializationException ie)
- {
- LocalizableMessage message = ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(
- ie.getMessage());
- err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
- }
catch (Exception e)
{
- LocalizableMessage message = ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(
- getExceptionMessage(e));
+ LocalizableMessage message = ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getMessage(e));
err.println(wrapText(message, MAX_LINE_WIDTH));
return 1;
}
@@ -696,24 +670,9 @@
{
directoryServer.initializeCryptoManager();
}
- catch (ConfigException ce)
- {
- LocalizableMessage message = ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(
- ce.getMessage());
- err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
- }
- catch (InitializationException ie)
- {
- LocalizableMessage message = ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(
- ie.getMessage());
- err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
- }
catch (Exception e)
{
- LocalizableMessage message = ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(
- getExceptionMessage(e));
+ LocalizableMessage message = ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getMessage(e));
err.println(wrapText(message, MAX_LINE_WIDTH));
return 1;
}
@@ -740,17 +699,9 @@
{
directoryServer.initializeRootDNConfigManager();
}
- catch (ConfigException ce)
+ catch (Exception e)
{
- LocalizableMessage message = ERR_CANNOT_INITIALIZE_ROOTDN_MANAGER.get(
- ce.getMessage());
- err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
- }
- catch (InitializationException ie)
- {
- LocalizableMessage message = ERR_CANNOT_INITIALIZE_ROOTDN_MANAGER.get(
- ie.getMessage());
+ LocalizableMessage message = ERR_CANNOT_INITIALIZE_ROOTDN_MANAGER.get(getMessage(e));
err.println(wrapText(message, MAX_LINE_WIDTH));
return 1;
}
@@ -761,24 +712,9 @@
HashSet<PluginType> pluginTypes = new HashSet<PluginType>(1);
directoryServer.initializePlugins(pluginTypes);
}
- catch (ConfigException ce)
- {
- LocalizableMessage message = ERR_LDIFIMPORT_CANNOT_INITIALIZE_PLUGINS.get(
- ce.getMessage());
- err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
- }
- catch (InitializationException ie)
- {
- LocalizableMessage message = ERR_LDIFIMPORT_CANNOT_INITIALIZE_PLUGINS.get(
- ie.getMessage());
- err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
- }
catch (Exception e)
{
- LocalizableMessage message = ERR_LDIFIMPORT_CANNOT_INITIALIZE_PLUGINS.get(
- getExceptionMessage(e));
+ LocalizableMessage message = ERR_LDIFIMPORT_CANNOT_INITIALIZE_PLUGINS.get(getMessage(e));
err.println(wrapText(message, MAX_LINE_WIDTH));
return 1;
}
@@ -801,24 +737,9 @@
{
directoryServer.initializeAuthenticationPolicyComponents();
}
- catch (ConfigException ce)
- {
- LocalizableMessage message = ERR_LDIFIMPORT_CANNOT_INITIALIZE_PWPOLICY.get(
- ce.getMessage());
- err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
- }
- catch (InitializationException ie)
- {
- LocalizableMessage message = ERR_LDIFIMPORT_CANNOT_INITIALIZE_PWPOLICY.get(
- ie.getMessage());
- err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
- }
catch (Exception e)
{
- LocalizableMessage message = ERR_LDIFIMPORT_CANNOT_INITIALIZE_PWPOLICY.get(
- getExceptionMessage(e));
+ LocalizableMessage message = ERR_LDIFIMPORT_CANNOT_INITIALIZE_PWPOLICY.get(getMessage(e));
err.println(wrapText(message, MAX_LINE_WIDTH));
return 1;
}
@@ -833,24 +754,9 @@
DirectoryServer.getPluginConfigManager();
pluginConfigManager.initializeUserPlugins(pluginTypes);
}
- catch (ConfigException ce)
- {
- LocalizableMessage message = ERR_LDIFIMPORT_CANNOT_INITIALIZE_PLUGINS.get(
- ce.getMessage());
- err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
- }
- catch (InitializationException ie)
- {
- LocalizableMessage message = ERR_LDIFIMPORT_CANNOT_INITIALIZE_PLUGINS.get(
- ie.getMessage());
- err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
- }
catch (Exception e)
{
- LocalizableMessage message = ERR_LDIFIMPORT_CANNOT_INITIALIZE_PLUGINS.get(
- getExceptionMessage(e));
+ LocalizableMessage message = ERR_LDIFIMPORT_CANNOT_INITIALIZE_PLUGINS.get(getMessage(e));
err.println(wrapText(message, MAX_LINE_WIDTH));
return 1;
}
@@ -985,13 +891,12 @@
// imported and finding backends with subordinate base DNs that should be
// excluded from the import.
Backend<?> backend = null;
- List<DN> defaultIncludeBranches = null;
- List<DN> excludeBranches = new ArrayList<DN>();
- List<DN> includeBranches = new ArrayList<DN>();
+ Set<DN> defaultIncludeBranches = null;
+ Set<DN> excludeBranches = new HashSet<DN>();
+ Set<DN> includeBranches = new HashSet<DN>();
if (includeBranchStrings.isPresent())
{
- includeBranches = new ArrayList<DN>();
for (String s : includeBranchStrings.getValues())
{
DN includeBranch;
@@ -1037,23 +942,7 @@
}
else
{
- boolean useBackend = false;
- for(DN baseDN : dnList.get(i))
- {
- for(DN includeDN : includeBranches)
- {
- if(baseDN.isAncestorOf(includeDN))
- {
- useBackend = true;
- break;
- }
- }
- if(useBackend)
- {
- break;
- }
- }
- if(!useBackend)
+ if (!useBackend(includeBranches, dnList.get(i)))
{
continue;
}
@@ -1062,7 +951,7 @@
if (backend == null)
{
backend = b;
- defaultIncludeBranches = dnList.get(i);
+ defaultIncludeBranches = new HashSet<DN>(dnList.get(i));
}
else
{
@@ -1088,14 +977,9 @@
{
for (DN importBase : defaultIncludeBranches)
{
- if (baseDN.isDescendantOf(importBase) &&
- (! baseDN.equals(importBase)))
+ if (!baseDN.equals(importBase) && baseDN.isDescendantOf(importBase))
{
- if (! excludeBranches.contains(baseDN))
- {
- excludeBranches.add(baseDN);
- }
-
+ excludeBranches.add(baseDN);
break;
}
}
@@ -1112,13 +996,7 @@
defaultIncludeBranches.size() > 1 &&
!clearBackend.isPresent())
{
- StringBuilder builder = new StringBuilder();
- builder.append(backend.getBaseDNs()[0].toString());
- for(int i = 1; i < backend.getBaseDNs().length; i++)
- {
- builder.append(" / ");
- builder.append(backend.getBaseDNs()[i].toString());
- }
+ StringBuilder builder = join(backend.getBaseDNs(), " / ");
LocalizableMessage message = ERR_LDIFIMPORT_MISSING_CLEAR_BACKEND.get(
builder, clearBackend.getLongIdentifier());
err.println(wrapText(message, MAX_LINE_WIDTH));
@@ -1143,10 +1021,7 @@
return 1;
}
- if (! excludeBranches.contains(excludeBranch))
- {
- excludeBranches.add(excludeBranch);
- }
+ excludeBranches.add(excludeBranch);
}
if (! includeBranchStrings.isPresent())
@@ -1188,22 +1063,7 @@
}
else
{
- Random random;
- if (randomSeed.isPresent())
- {
- try
- {
- random = new Random(randomSeed.getIntValue());
- }
- catch (Exception e)
- {
- random = new Random();
- }
- }
- else
- {
- random = new Random();
- }
+ Random random = newRandom();
String resourcePath = DirectoryServer.getInstanceRoot() + File.separator +
PATH_MAKELDIF_RESOURCE_DIR;
@@ -1252,12 +1112,9 @@
}
importConfig.setBufferSize(LDIF_BUFFER_SIZE);
- importConfig.setExcludeAllUserAttributes(
- excludeAllUserAttributes);
- importConfig.setExcludeAllOperationalAttributes(
- excludeAllOperationalAttributes);
- importConfig.setIncludeAllOpAttributes(
- includeAllOperationalAttributes);
+ importConfig.setExcludeAllUserAttributes(excludeAllUserAttributes);
+ importConfig.setExcludeAllOperationalAttributes(excludeAllOperationalAttributes);
+ importConfig.setIncludeAllOpAttributes(includeAllOperationalAttributes);
importConfig.setIncludeAllUserAttributes(includeAllUserAttributes);
// FIXME -- Should this be conditional?
@@ -1267,15 +1124,9 @@
{
try
{
- ExistingFileBehavior existingBehavior;
- if (overwrite.isPresent())
- {
- existingBehavior = ExistingFileBehavior.OVERWRITE;
- }
- else
- {
- existingBehavior = ExistingFileBehavior.APPEND;
- }
+ ExistingFileBehavior existingBehavior = overwrite.isPresent()
+ ? ExistingFileBehavior.OVERWRITE
+ : ExistingFileBehavior.APPEND;
importConfig.writeRejectedEntries(rejectFile.getValue(),
existingBehavior);
@@ -1291,15 +1142,9 @@
{
try
{
- ExistingFileBehavior existingBehavior;
- if (overwrite.isPresent())
- {
- existingBehavior = ExistingFileBehavior.OVERWRITE;
- }
- else
- {
- existingBehavior = ExistingFileBehavior.APPEND;
- }
+ ExistingFileBehavior existingBehavior = overwrite.isPresent()
+ ? ExistingFileBehavior.OVERWRITE
+ : ExistingFileBehavior.APPEND;
importConfig.writeSkippedEntries(skipFile.getValue(),
existingBehavior);
@@ -1353,18 +1198,16 @@
}
catch (DirectoryException de)
{
- LocalizableMessage message = null;
+ LocalizableMessage msg;
if (de.getResultCode() == ResultCode.CONSTRAINT_VIOLATION)
{
- message =
- ERR_LDIFIMPORT_ERROR_DURING_IMPORT
- .get(ERR_LDIFIMPORT_ERROR_CONSTRAINT_VIOLATION.get());
+ msg = ERR_LDIFIMPORT_ERROR_CONSTRAINT_VIOLATION.get();
}
else
{
- message = ERR_LDIFIMPORT_ERROR_DURING_IMPORT.get(de.getMessageObject());
+ msg = de.getMessageObject();
}
- logger.error(message);
+ logger.error(ERR_LDIFIMPORT_ERROR_DURING_IMPORT.get(msg));
retCode = 1;
}
catch (Exception e)
@@ -1397,6 +1240,69 @@
return retCode;
}
+ private Object getMessage(Exception e)
+ {
+ try
+ {
+ throw e;
+ }
+ catch (ConfigException e2)
+ {
+ return e2.getMessage();
+ }
+ catch (InitializationException e2)
+ {
+ return e2.getMessage();
+ }
+ catch (Exception e2)
+ {
+ return getExceptionMessage(e2);
+ }
+ }
+
+ private boolean useBackend(Set<DN> includeBranches, List<DN> dnlist)
+ {
+ for (DN baseDN : dnlist)
+ {
+ for (DN includeDN : includeBranches)
+ {
+ if (baseDN.isAncestorOf(includeDN))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private StringBuilder join(final DN[] baseDNs, final String separator)
+ {
+ final StringBuilder builder = new StringBuilder();
+ builder.append(baseDNs[0].toString());
+ for (int i = 1; i < baseDNs.length; i++)
+ {
+ builder.append(separator);
+ builder.append(baseDNs[i].toString());
+ }
+ return builder;
+ }
+
+ private Random newRandom()
+ {
+ if (randomSeed.isPresent())
+ {
+ try
+ {
+ return new Random(randomSeed.getIntValue());
+ }
+ catch (Exception ignored)
+ {
+ // ignore
+ }
+ }
+ return new Random();
+ }
+
/** {@inheritDoc} */
@Override
public String getTaskId() {
diff --git a/opendj3-server-dev/src/server/org/opends/server/types/LDIFImportConfig.java b/opendj3-server-dev/src/server/org/opends/server/types/LDIFImportConfig.java
index a0d694e..515c4b0 100644
--- a/opendj3-server-dev/src/server/org/opends/server/types/LDIFImportConfig.java
+++ b/opendj3-server-dev/src/server/org/opends/server/types/LDIFImportConfig.java
@@ -22,20 +22,21 @@
*
*
* Copyright 2006-2009 Sun Microsystems, Inc.
- * Portions Copyright 2012-2014 ForgeRock AS
+ * Portions Copyright 2012-2015 ForgeRock AS
*/
package org.opends.server.types;
+import static org.opends.messages.UtilityMessages.*;
+
import java.io.*;
import java.util.*;
import java.util.zip.GZIPInputStream;
+import org.forgerock.i18n.LocalizableMessageDescriptor.Arg1;
import org.opends.server.tools.makeldif.MakeLDIFInputStream;
import org.opends.server.tools.makeldif.TemplateFile;
import org.opends.server.util.StaticUtils;
-import static org.opends.messages.UtilityMessages.*;
-
/**
* This class defines a data structure for holding configuration
* information to use when performing an LDIF import.
@@ -49,99 +50,79 @@
implements Closeable
{
- /**
- * The default buffer size that will be used when reading LDIF data.
- */
+ /** The default buffer size that will be used when reading LDIF data. */
private static final int DEFAULT_BUFFER_SIZE = 8192;
-
-
- // Indicates whether to append to the existing data set rather than
- // replacing it.
+ /**
+ * Indicates whether to append to the existing data set rather than
+ * replacing it.
+ */
private boolean appendToExistingData;
- // Indicates whether to include the objectclasses in the entries
- // read from the import.
- private boolean includeObjectClasses;
+ /**
+ * Indicates whether to include the objectclasses in the entries
+ * read from the import.
+ */
+ private boolean includeObjectClasses = true;
- // Indicates whether to invoke LDIF import plugins whenever an entry
- // is read.
+ /** Indicates whether to invoke LDIF import plugins whenever an entry is read. */
private boolean invokeImportPlugins;
-
- // Indicates whether the import is compressed.
+ /** Indicates whether the import is compressed. */
private boolean isCompressed;
-
- // Indicates whether the import is encrypted.
+ /** Indicates whether the import is encrypted. */
private boolean isEncrypted;
-
- // Indicates whether to clear all base DNs in a backend.
+ /** Indicates whether to clear all base DNs in a backend. */
private boolean clearBackend;
-
- // Indicates whether to replace existing entries when appending
- // data.
+ /** Indicates whether to replace existing entries when appending data. */
private boolean replaceExistingEntries;
+ /** Indicates whether to perform schema validation on the entries read. */
+ private boolean validateSchema = true;
- // Indicates whether to perform schema validation on the entries
- // read.
- private boolean validateSchema;
-
- // The buffered reader from which the LDIF data should be read.
+ /** The buffered reader from which the LDIF data should be read. */
private BufferedReader reader;
-
- // The buffered writer to which rejected entries should be written.
+ /** The buffered writer to which rejected entries should be written. */
private BufferedWriter rejectWriter;
-
- // The buffered writer to which rejected entries should be written.
+ /** The buffered writer to which rejected entries should be written. */
private BufferedWriter skipWriter;
-
- // The input stream to use to read the data to import.
+ /** The input stream to use to read the data to import. */
private InputStream ldifInputStream;
- // The buffer size to use when reading data from the LDIF file.
- private int bufferSize;
+ /** The buffer size to use when reading data from the LDIF file. */
+ private int bufferSize = DEFAULT_BUFFER_SIZE;
- // The iterator used to read through the set of LDIF files.
+ /** The iterator used to read through the set of LDIF files. */
private Iterator<String> ldifFileIterator;
- // The set of base DNs to exclude from the import.
- private List<DN> excludeBranches;
+ /** The set of base DNs to exclude from the import. */
+ private Set<DN> excludeBranches = new HashSet<DN>(0);
+ /** The set of base DNs to include from the import. */
+ private Set<DN> includeBranches = new HashSet<DN>(0);
- // The set of base DNs to include from the import.
- private List<DN> includeBranches;
+ /** The set of search filters for entries to exclude from the import. */
+ private List<SearchFilter> excludeFilters = new ArrayList<SearchFilter>(0);
+ /** The set of search filters for entries to include in the import. */
+ private List<SearchFilter> includeFilters = new ArrayList<SearchFilter>(0);
- // The set of search filters for entries to exclude from the import.
- private List<SearchFilter> excludeFilters;
-
- // The set of search filters for entries to include in the import.
- private List<SearchFilter> includeFilters;
-
- // The set of LDIF files to be imported.
+ /** The set of LDIF files to be imported. */
private List<String> ldifFiles;
- // The set of attribute types that should be excluded from the
- // import.
- private Set<AttributeType> excludeAttributes;
+ /** The set of attribute types that should be excluded from the import. */
+ private Set<AttributeType> excludeAttributes = new HashSet<AttributeType>(0);
+ /** The set of attribute types that should be included in the import. */
+ private Set<AttributeType> includeAttributes = new HashSet<AttributeType>(0);
- // The set of attribute types that should be included in the import.
- private Set<AttributeType> includeAttributes;
-
- // Indicates whether all the user attributes should be included.
+ /** Indicates whether all the user attributes should be included. */
private boolean includeAllUserAttrs;
-
- //Indicates whether all the operational attributes should be
- // included.
+ /** Indicates whether all the operational attributes should be included. */
private boolean includeAllOpAttrs;
-
- //Indicates whether all the user attributes should be excluded.
+ /** Indicates whether all the user attributes should be excluded. */
private boolean excludeAllUserAttrs;
-
- //Indicates whether all the operational attributes should be
- // excluded.
+ /** Indicates whether all the operational attributes should be excluded. */
private boolean excludeAllOpAttrs;
private String tmpDirectory;
- private boolean skipDNValidation = false;
- private int threadCount = 0;
+ private boolean skipDNValidation;
+ private int threadCount;
/**
@@ -156,35 +137,8 @@
ldifFiles = new ArrayList<String>(1);
ldifFiles.add(ldifFile);
ldifFileIterator = ldifFiles.iterator();
-
- ldifInputStream = null;
- bufferSize = DEFAULT_BUFFER_SIZE;
- excludeBranches = new ArrayList<DN>();
- includeBranches = new ArrayList<DN>();
- excludeFilters = new ArrayList<SearchFilter>();
- includeFilters = new ArrayList<SearchFilter>();
- appendToExistingData = false;
- replaceExistingEntries = false;
- includeObjectClasses = true;
- invokeImportPlugins = false;
- isCompressed = false;
- isEncrypted = false;
- clearBackend = false;
- validateSchema = true;
- reader = null;
- rejectWriter = null;
- skipWriter = null;
- excludeAttributes = new HashSet<AttributeType>();
- includeAttributes = new HashSet<AttributeType>();
- includeAllUserAttrs = false;
- includeAllOpAttrs = false;
- excludeAllUserAttrs = false;
- excludeAllOpAttrs = false;
-
}
-
-
/**
* Creates a new LDIF import configuration that will read from the
* specified LDIF files. The files will be imported in the order
@@ -197,34 +151,8 @@
{
this.ldifFiles = ldifFiles;
ldifFileIterator = ldifFiles.iterator();
-
- ldifInputStream = null;
- bufferSize = DEFAULT_BUFFER_SIZE;
- excludeBranches = new ArrayList<DN>();
- includeBranches = new ArrayList<DN>();
- excludeFilters = new ArrayList<SearchFilter>();
- includeFilters = new ArrayList<SearchFilter>();
- appendToExistingData = false;
- replaceExistingEntries = false;
- includeObjectClasses = true;
- invokeImportPlugins = false;
- isCompressed = false;
- isEncrypted = false;
- validateSchema = true;
- reader = null;
- rejectWriter = null;
- skipWriter = null;
- excludeAttributes = new HashSet<AttributeType>();
- includeAttributes = new HashSet<AttributeType>();
- includeAllUserAttrs = false;
- includeAllOpAttrs = false;
- excludeAllUserAttrs = false;
- excludeAllOpAttrs = false;
-
}
-
-
/**
* Creates a new LDIF import configuration that will read from the
* provided input stream.
@@ -235,31 +163,6 @@
public LDIFImportConfig(InputStream ldifInputStream)
{
this.ldifInputStream = ldifInputStream;
- bufferSize = DEFAULT_BUFFER_SIZE;
- ldifFiles = null;
- ldifFileIterator = null;
-
- excludeBranches = new ArrayList<DN>();
- includeBranches = new ArrayList<DN>();
- excludeFilters = new ArrayList<SearchFilter>();
- includeFilters = new ArrayList<SearchFilter>();
- appendToExistingData = false;
- replaceExistingEntries = false;
- includeObjectClasses = true;
- invokeImportPlugins = false;
- isCompressed = false;
- isEncrypted = false;
- validateSchema = true;
- reader = null;
- rejectWriter = null;
- skipWriter = null;
- excludeAttributes = new HashSet<AttributeType>();
- includeAttributes = new HashSet<AttributeType>();
- includeAllUserAttrs = false;
- includeAllOpAttrs = false;
- excludeAllUserAttrs = false;
- excludeAllOpAttrs = false;
-
}
/**
@@ -271,32 +174,7 @@
*/
public LDIFImportConfig(Reader ldifInputReader)
{
- ldifInputStream = null;
- bufferSize = DEFAULT_BUFFER_SIZE;
- ldifFiles = null;
- ldifFileIterator = null;
-
- excludeBranches = new ArrayList<DN>();
- includeBranches = new ArrayList<DN>();
- excludeFilters = new ArrayList<SearchFilter>();
- includeFilters = new ArrayList<SearchFilter>();
- appendToExistingData = false;
- replaceExistingEntries = false;
- includeObjectClasses = true;
- invokeImportPlugins = false;
- isCompressed = false;
- isEncrypted = false;
- validateSchema = true;
reader = getBufferedReader(ldifInputReader);
- rejectWriter = null;
- skipWriter = null;
- excludeAttributes = new HashSet<AttributeType>();
- includeAttributes = new HashSet<AttributeType>();
- includeAllUserAttrs = false;
- includeAllOpAttrs = false;
- excludeAllUserAttrs = false;
- excludeAllOpAttrs = false;
-
}
/**
@@ -324,8 +202,6 @@
public LDIFImportConfig(TemplateFile templateFile)
{
this(new MakeLDIFInputStream(templateFile));
-
-
}
@@ -347,14 +223,14 @@
if (reader == null)
{
InputStream inputStream;
- if (ldifInputStream == null)
+ if (ldifInputStream != null)
{
- inputStream = ldifInputStream =
- new FileInputStream(ldifFileIterator.next());
+ inputStream = ldifInputStream;
}
else
{
- inputStream = ldifInputStream;
+ inputStream = ldifInputStream =
+ new FileInputStream(ldifFileIterator.next());
}
if (isEncrypted)
@@ -384,13 +260,12 @@
* @return The reader that should be used to read the LDIF data, or
* <CODE>null</CODE> if there are no more files to read.
*
- * @throws IOException If a problem occurs while obtaining the
- * reader.
+ * @throws IOException If a problem occurs while obtaining the reader.
*/
public BufferedReader nextReader()
throws IOException
{
- if ((ldifFileIterator == null) || (! ldifFileIterator.hasNext()))
+ if (ldifFileIterator == null || !ldifFileIterator.hasNext())
{
return null;
}
@@ -420,8 +295,7 @@
* Retrieves the writer that should be used to write entries that
* are rejected rather than imported for some reason.
*
- * @return The reject writer, or <CODE>null</CODE> if none is to be
- * used.
+ * @return The reject writer, or <CODE>null</CODE> if none is to be used.
*/
public BufferedWriter getRejectWriter()
{
@@ -430,10 +304,9 @@
/**
* Retrieves the writer that should be used to write entries that
- * are skipped because they don't match the criteri.
+ * are skipped because they don't match the criteria.
*
- * @return The skip writer, or <CODE>null</CODE> if none is to be
- * used.
+ * @return The skip writer, or <CODE>null</CODE> if none is to be used.
*/
public BufferedWriter getSkipWriter()
{
@@ -448,10 +321,8 @@
* rejected because they matched exclude criteria.
*
* @param rejectFile The path to the file to which
- * reject information should be
- * written.
- * @param existingFileBehavior Indicates how to treat an existing
- * file.
+ * reject information should be written.
+ * @param existingFileBehavior Indicates how to treat an existing file.
*
* @throws IOException If a problem occurs while opening the
* reject file for writing.
@@ -462,42 +333,37 @@
{
if (rejectFile == null)
{
- if (rejectWriter != null)
- {
- StaticUtils.close(rejectWriter);
- rejectWriter = null;
- }
-
+ closeRejectWriter();
return;
}
- switch (existingFileBehavior)
+ final BufferedWriter writer = newBufferedWriter(rejectFile, existingFileBehavior, ERR_REJECT_FILE_EXISTS);
+ if (writer != null)
{
- case APPEND:
- rejectWriter =
- new BufferedWriter(new FileWriter(rejectFile, true));
- break;
- case OVERWRITE:
- rejectWriter =
- new BufferedWriter(new FileWriter(rejectFile, false));
- break;
- case FAIL:
- File f = new File(rejectFile);
- if (f.exists())
- {
- throw new IOException(
- ERR_REJECT_FILE_EXISTS.get(rejectFile).toString());
- }
- else
- {
- rejectWriter =
- new BufferedWriter(new FileWriter(rejectFile));
- }
- break;
+ rejectWriter = writer;
}
}
-
+ private BufferedWriter newBufferedWriter(String file, ExistingFileBehavior existingFileBehavior,
+ Arg1<Object> fileExistsErrorMsg) throws IOException
+ {
+ switch (existingFileBehavior)
+ {
+ case APPEND:
+ return new BufferedWriter(new FileWriter(file, true));
+ case OVERWRITE:
+ return new BufferedWriter(new FileWriter(file, false));
+ case FAIL:
+ File f = new File(file);
+ if (f.exists())
+ {
+ throw new IOException(fileExistsErrorMsg.get(file).toString());
+ }
+ return new BufferedWriter(new FileWriter(file));
+ default:
+ return null;
+ }
+ }
/**
* Indicates that rejected entries should be written to the provided
@@ -513,12 +379,7 @@
{
if (outputStream == null)
{
- if (rejectWriter != null)
- {
- StaticUtils.close(rejectWriter);
- rejectWriter = null;
- }
-
+ closeRejectWriter();
return;
}
@@ -526,16 +387,23 @@
new BufferedWriter(new OutputStreamWriter(outputStream));
}
+ private void closeRejectWriter()
+ {
+ if (rejectWriter != null)
+ {
+ StaticUtils.close(rejectWriter);
+ rejectWriter = null;
+ }
+ }
+
/**
* Indicates that skipped entries should be written to the
* specified file. Note that this applies only to entries that are
* skipped because they matched exclude criteria.
*
* @param skipFile The path to the file to which
- * skipped information should be
- * written.
- * @param existingFileBehavior Indicates how to treat an existing
- * file.
+ * skipped information should be written.
+ * @param existingFileBehavior Indicates how to treat an existing file.
*
* @throws IOException If a problem occurs while opening the
* skip file for writing.
@@ -546,42 +414,25 @@
{
if (skipFile == null)
{
- if (skipWriter != null)
- {
- StaticUtils.close(skipWriter);
- skipWriter = null;
- }
-
+ closeSkipWriter();
return;
}
- switch (existingFileBehavior)
+ final BufferedWriter writer = newBufferedWriter(skipFile, existingFileBehavior, ERR_SKIP_FILE_EXISTS);
+ if (writer != null)
{
- case APPEND:
- skipWriter =
- new BufferedWriter(new FileWriter(skipFile, true));
- break;
- case OVERWRITE:
- skipWriter =
- new BufferedWriter(new FileWriter(skipFile, false));
- break;
- case FAIL:
- File f = new File(skipFile);
- if (f.exists())
- {
- throw new IOException(
- ERR_SKIP_FILE_EXISTS.get(skipFile).toString());
- }
- else
- {
- skipWriter =
- new BufferedWriter(new FileWriter(skipFile));
- }
- break;
+ skipWriter = writer;
}
}
-
+ private void closeSkipWriter()
+ {
+ if (skipWriter != null)
+ {
+ StaticUtils.close(skipWriter);
+ skipWriter = null;
+ }
+ }
/**
* Indicates that skipped entries should be written to the provided
@@ -597,12 +448,7 @@
{
if (outputStream == null)
{
- if (skipWriter != null)
- {
- StaticUtils.close(skipWriter);
- skipWriter = null;
- }
-
+ closeSkipWriter();
return;
}
skipWriter =
@@ -664,8 +510,7 @@
* existing entry if a duplicate is
* found or to reject the new entry.
*/
- public void setReplaceExistingEntries(
- boolean replaceExistingEntries)
+ public void setReplaceExistingEntries(boolean replaceExistingEntries)
{
this.replaceExistingEntries = replaceExistingEntries;
}
@@ -826,7 +671,7 @@
* @return The set of base DNs that specify the set of entries to
* exclude from the import.
*/
- public List<DN> getExcludeBranches()
+ public Set<DN> getExcludeBranches()
{
return excludeBranches;
}
@@ -840,18 +685,15 @@
* @param excludeBranches The set of base DNs that specify the set
* of entries to exclude from the import.
*/
- public void setExcludeBranches(List<DN> excludeBranches)
+ public void setExcludeBranches(Set<DN> excludeBranches)
{
- if (excludeBranches == null)
- {
- this.excludeBranches = new ArrayList<DN>(0);
- }
- else
- {
- this.excludeBranches = excludeBranches;
- }
+ this.excludeBranches = getSet(excludeBranches);
}
+ private <T> Set<T> getSet(Set<T> set)
+ {
+ return set != null ? set : new HashSet<T>(0);
+ }
/**
@@ -862,7 +704,7 @@
* @return The set of base DNs that specify the set of entries to
* include in the import.
*/
- public List<DN> getIncludeBranches()
+ public Set<DN> getIncludeBranches()
{
return includeBranches;
}
@@ -876,20 +718,11 @@
* @param includeBranches The set of base DNs that specify the set
* of entries to include in the import.
*/
- public void setIncludeBranches(List<DN> includeBranches)
+ public void setIncludeBranches(Set<DN> includeBranches)
{
- if (includeBranches == null)
- {
- this.includeBranches = new ArrayList<DN>(0);
- }
- else
- {
- this.includeBranches = includeBranches;
- }
+ this.includeBranches = getSet(includeBranches);
}
-
-
/**
* Indicates whether to include the entry with the specified DN in
* the import.
@@ -985,21 +818,11 @@
* excluded from the entries read from
* the LDIF.
*/
- public void setExcludeAttributes(
- Set<AttributeType> excludeAttributes)
+ public void setExcludeAttributes(Set<AttributeType> excludeAttributes)
{
- if (excludeAttributes == null)
- {
- this.excludeAttributes = new HashSet<AttributeType>(0);
- }
- else
- {
- this.excludeAttributes = excludeAttributes;
- }
+ this.excludeAttributes = getSet(excludeAttributes);
}
-
-
/**
* Retrieves the set of attributes that should be included in the
* entries read from the LDIF. The contents of the returned set may
@@ -1023,21 +846,11 @@
* included in the entries read from the
* LDIF.
*/
- public void setIncludeAttributes(
- Set<AttributeType> includeAttributes)
+ public void setIncludeAttributes(Set<AttributeType> includeAttributes)
{
- if (includeAttributes == null)
- {
- this.includeAttributes = new HashSet<AttributeType>(0);
- }
- else
- {
- this.includeAttributes = includeAttributes;
- }
+ this.includeAttributes = getSet(includeAttributes);
}
-
-
/**
* Indicates whether the specified attribute should be included in
* the entries read from the LDIF.
@@ -1051,20 +864,20 @@
*/
public boolean includeAttribute(AttributeType attributeType)
{
- if ((! excludeAttributes.isEmpty()) &&
- excludeAttributes.contains(attributeType))
+ if (!excludeAttributes.isEmpty()
+ && excludeAttributes.contains(attributeType))
{
return false;
}
- if(excludeAllOpAttrs && attributeType.isOperational() ||
- excludeAllUserAttrs && !attributeType.isOperational())
+ if((excludeAllOpAttrs && attributeType.isOperational())
+ || (excludeAllUserAttrs && !attributeType.isOperational()))
{
return false;
}
- if(includeAllUserAttrs && !attributeType.isOperational() ||
- includeAllOpAttrs && attributeType.isOperational())
+ if((includeAllUserAttrs && !attributeType.isOperational())
+ || (includeAllOpAttrs && attributeType.isOperational()))
{
return true;
}
@@ -1073,13 +886,10 @@
{
return includeAttributes.contains(attributeType);
}
- else
+ else if((includeAllUserAttrs && attributeType.isOperational())
+ || (includeAllOpAttrs && !attributeType.isOperational()))
{
- if(includeAllUserAttrs && attributeType.isOperational() ||
- includeAllOpAttrs && !attributeType.isOperational())
- {
- return false;
- }
+ return false;
}
return true;
}
@@ -1111,18 +921,9 @@
*/
public void setExcludeFilters(List<SearchFilter> excludeFilters)
{
- if (excludeFilters == null)
- {
- this.excludeFilters = new ArrayList<SearchFilter>(0);
- }
- else
- {
- this.excludeFilters = excludeFilters;
- }
+ this.excludeFilters = getList(excludeFilters);
}
-
-
/**
* Retrieves the set of search filters that should be used to
* determine which entries to include in the LDIF. The contents of
@@ -1148,17 +949,13 @@
*/
public void setIncludeFilters(List<SearchFilter> includeFilters)
{
- if (includeFilters == null)
- {
- this.includeFilters = new ArrayList<SearchFilter>(0);
- }
- else
- {
- this.includeFilters = includeFilters;
- }
+ this.includeFilters = getList(includeFilters);
}
-
+ private <T> List<T> getList(List<T> list)
+ {
+ return list != null ? list : new ArrayList<T>(0);
+ }
/**
* Indicates whether the specified entry should be included in the
@@ -1255,8 +1052,7 @@
* operational attributes
* should be excluded.
*/
- public void setExcludeAllOperationalAttributes(
- boolean excludeAllOpAttrs)
+ public void setExcludeAllOperationalAttributes(boolean excludeAllOpAttrs)
{
this.excludeAllOpAttrs = excludeAllOpAttrs;
}
@@ -1292,9 +1088,7 @@
- /**
- * Closes any resources that this import config might have open.
- */
+ /** Closes any resources that this import config might have open. */
@Override
public void close()
{
@@ -1362,4 +1156,3 @@
return this.threadCount;
}
}
-
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestImportJob.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestImportJob.java
index fc1c22d..9f45166 100644
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestImportJob.java
+++ b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/jeb/TestImportJob.java
@@ -33,6 +33,8 @@
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Set;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.TestCaseUtils;
@@ -375,10 +377,8 @@
fileList.add(homeDirName + File.separator + "top.ldif");
fileList.add(homeDirName + File.separator + "entries1.ldif");
- ArrayList<DN> includeBranches = new ArrayList<DN>();
- includeBranches.add(DN.valueOf("ou=People,dc=importtest,dc=com"));
- ArrayList<DN> excludeBranches = new ArrayList<DN>();
- excludeBranches.add(DN.valueOf("ou=Others,ou=People,dc=importtest,dc=com"));
+ Set<DN> includeBranches = Collections.singleton(DN.valueOf("ou=People,dc=importtest,dc=com"));
+ Set<DN> excludeBranches = Collections.singleton(DN.valueOf("ou=Others,ou=People,dc=importtest,dc=com"));
ByteArrayOutputStream rejectedEntries = new ByteArrayOutputStream();
ByteArrayOutputStream skippedEntries = new ByteArrayOutputStream();
@@ -601,8 +601,7 @@
@Test(dependsOnMethods = "testImportPartial")
public void testImportSkip() throws Exception
{
- ArrayList<DN> excludeBranches = new ArrayList<DN>();
- excludeBranches.add(DN.valueOf("dc=skipped,dc=importtest1,dc=com"));
+ Set<DN> excludeBranches = Collections.singleton(DN.valueOf("dc=skipped,dc=importtest1,dc=com"));
ByteArrayOutputStream skippedEntries = new ByteArrayOutputStream();
LDIFImportConfig importConfig = new LDIFImportConfig(homeDirName
+ File.separator + "skipped.ldif");
--
Gitblit v1.10.0