From 3dac39290588b8348919647bb76c00f83b6db911 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 24 Dec 2014 14:57:50 +0000
Subject: [PATCH] ImportTask.java: In runTask(), extracted method toAttributeTypes(). Fixed some formatting.
---
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/tasks/ImportTask.java | 56 ++++++++++++++++++++++----------------------------------
1 files changed, 22 insertions(+), 34 deletions(-)
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/tasks/ImportTask.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/tasks/ImportTask.java
index 7d414b2..856c2b0 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/tasks/ImportTask.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/tasks/ImportTask.java
@@ -371,18 +371,14 @@
// The include branches span across multiple backends.
LocalizableMessage message = ERR_LDIFIMPORT_INVALID_INCLUDE_BASE.get(
includeBranch.toNormalizedString(), backend.getBackendID());
- throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
- message);
+ throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
}
}
else
{
// The include branch is not associated with any backend.
- LocalizableMessage message =
- ERR_NO_BACKENDS_FOR_BASE.get(includeBranch
- .toNormalizedString());
- throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
- message);
+ LocalizableMessage message = ERR_NO_BACKENDS_FOR_BASE.get(includeBranch.toNormalizedString());
+ throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message);
}
}
}
@@ -455,33 +451,8 @@
{
// See if there were any user-defined sets of include/exclude attributes or
// filters. If so, then process them.
- HashSet<AttributeType> excludeAttributes =
- new HashSet<AttributeType>(excludeAttributeStrings.size());
- for (String attrName : excludeAttributeStrings)
- {
- String lowerName = attrName.toLowerCase();
- AttributeType attrType = DirectoryServer.getAttributeType(lowerName);
- if (attrType == null)
- {
- attrType = DirectoryServer.getDefaultAttributeType(attrName);
- }
-
- excludeAttributes.add(attrType);
- }
-
- HashSet<AttributeType> includeAttributes =
- new HashSet<AttributeType>(includeAttributeStrings.size());
- for (String attrName : includeAttributeStrings)
- {
- String lowerName = attrName.toLowerCase();
- AttributeType attrType = DirectoryServer.getAttributeType(lowerName);
- if (attrType == null)
- {
- attrType = DirectoryServer.getDefaultAttributeType(attrName);
- }
-
- includeAttributes.add(attrType);
- }
+ HashSet<AttributeType> excludeAttributes = toAttributeTypes(excludeAttributeStrings);
+ HashSet<AttributeType> includeAttributes = toAttributeTypes(includeAttributeStrings);
ArrayList<SearchFilter> excludeFilters =
new ArrayList<SearchFilter>(excludeFilterStrings.size());
@@ -906,4 +877,21 @@
importConfig.close();
return getFinalTaskState();
}
+
+ private HashSet<AttributeType> toAttributeTypes(ArrayList<String> attrNames)
+ {
+ final HashSet<AttributeType> attrTypes = new HashSet<AttributeType>(attrNames.size());
+ for (String attrName : attrNames)
+ {
+ String lowerName = attrName.toLowerCase();
+ AttributeType attrType = DirectoryServer.getAttributeType(lowerName);
+ if (attrType == null)
+ {
+ attrType = DirectoryServer.getDefaultAttributeType(attrName);
+ }
+
+ attrTypes.add(attrType);
+ }
+ return attrTypes;
+ }
}
--
Gitblit v1.10.0