mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
24.57.2014 3dac39290588b8348919647bb76c00f83b6db911
ImportTask.java:
In runTask(), extracted method toAttributeTypes().
Fixed some formatting.
1 files modified
56 ■■■■■ changed files
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/tasks/ImportTask.java 56 ●●●●● patch | view | raw | blame | history
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;
  }
}