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

Jean-Noel Rouvignac
20.44.2015 43f0c2c3c6570234721fb5635e043999fb894e28
Code cleanup

ServerConstants.java:
Removed constant MAX_LINE_WIDTH moved to com.forgerock.opendj.cli.Utils + switched all references to use the new location.

*.java:
Extracted methods.
Fixed javadocs.
23 files modified
1208 ■■■■■ changed files
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ControlPanelLauncher.java 17 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/BackUpDB.java 26 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/ConfigureDS.java 38 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/ConfigureWindowsService.java 22 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/EncodePassword.java 23 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/ExportLDIF.java 279 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/ImportLDIF.java 341 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/LDAPCompare.java 31 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/LDAPDelete.java 29 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/LDAPModify.java 22 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/LDAPPasswordModify.java 28 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/LDAPSearch.java 33 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/LDIFModify.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/LDIFSearch.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/ListBackends.java 25 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/ManageAccount.java 3 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/RestoreDB.java 130 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/StopDS.java 23 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/makeldif/MakeLDIF.java 13 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskTool.java 52 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/upgrade/UpgradeCli.java 11 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/util/ServerConstants.java 25 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/util/StaticUtils.java 11 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ControlPanelLauncher.java
@@ -22,24 +22,22 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2014 ForgeRock AS
 *      Portions Copyright 2011-2015 ForgeRock AS
 */
package org.opends.guitools.controlpanel;
import static com.forgerock.opendj.cli.Utils.*;
import static org.opends.messages.AdminToolMessages.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.util.ServerConstants.MAX_LINE_WIDTH;
import static com.forgerock.opendj.cli.Utils.wrapText;
import java.io.File;
import java.io.PrintStream;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import javax.swing.SwingUtilities;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.guitools.controlpanel.util.ControlPanelLog;
import org.opends.messages.AdminToolMessages;
import org.opends.quicksetup.ui.UIFactory;
@@ -47,6 +45,7 @@
import org.opends.server.types.InitializationException;
import org.opends.server.util.BuildVersion;
import org.opends.server.util.DynamicConstants;
import com.forgerock.opendj.cli.ArgumentException;
/**
@@ -170,6 +169,7 @@
    final int[] returnValue = { -1 };
    Thread t = new Thread(new Runnable()
    {
      @Override
      public void run()
      {
        try
@@ -322,6 +322,7 @@
   * This method assumes that is being called outside the event thread.
   * @param args arguments to be passed to the method ControlPanel.initialize.
   */
  @Override
  protected void constructApplication(String[] args)
  {
    try
@@ -346,10 +347,12 @@
   * @see org.opends.guitools.controlpanel.ControlPanel#createAndDisplayGUI()
   * This method assumes that is being called outside the event thread.
   */
  @Override
  protected void displayApplication()
  {
    Runnable runnable = new Runnable()
    {
      @Override
      public void run()
      {
        try
opendj3-server-dev/src/server/org/opends/server/tools/BackUpDB.java
@@ -22,14 +22,19 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2014 ForgeRock AS.
 *      Portions Copyright 2013-2015 ForgeRock AS.
 */
package org.opends.server.tools;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import java.io.File;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import java.io.OutputStream;
import java.io.PrintStream;
import java.text.SimpleDateFormat;
@@ -41,9 +46,11 @@
import java.util.TimeZone;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.api.Backend;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
@@ -59,7 +66,6 @@
import org.opends.server.tools.tasks.TaskTool;
import org.opends.server.types.BackupConfig;
import org.opends.server.types.BackupDirectory;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.InitializationException;
@@ -74,14 +80,6 @@
import com.forgerock.opendj.cli.CommonArguments;
import com.forgerock.opendj.cli.StringArgument;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import static com.forgerock.opendj.cli.Utils.wrapText;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
/**
 * This program provides a utility that may be used to back up a Directory
 * Server backend in a binary form that may be quickly archived and restored.
opendj3-server-dev/src/server/org/opends/server/tools/ConfigureDS.java
@@ -22,20 +22,31 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2014 ForgeRock AS.
 *      Portions Copyright 2012-2015 ForgeRock AS.
 */
package org.opends.server.tools;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.messages.ExtensionMessages.*;
import static org.opends.messages.ProtocolMessages.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import java.io.File;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.StringReader;
import java.net.InetAddress;
import java.security.GeneralSecurityException;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
import java.io.File;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.StringReader;
import javax.crypto.Cipher;
@@ -56,9 +67,9 @@
import org.opends.server.extensions.SaltedSHA512PasswordStorageScheme;
import org.opends.server.loggers.JDKLogging;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryEnvironmentConfig;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
import org.opends.server.types.InitializationException;
import org.opends.server.types.LDIFImportConfig;
@@ -74,17 +85,6 @@
import com.forgerock.opendj.cli.IntegerArgument;
import com.forgerock.opendj.cli.StringArgument;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.messages.ExtensionMessages.*;
import static org.opends.messages.ProtocolMessages.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.wrapText;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
/**
 * This class provides a very basic tool that can be used to configure some of
 * the most important settings in the Directory Server.  This configuration is
@@ -102,9 +102,7 @@
 */
public class ConfigureDS
{
  /**
   * The fully-qualified name of this class.
   */
  /** The fully-qualified name of this class. */
  private static final String CLASS_NAME =
       "org.opends.server.tools.ConfigureDS";
opendj3-server-dev/src/server/org/opends/server/tools/ConfigureWindowsService.java
@@ -22,11 +22,21 @@
 *
 *
 *      Copyright 2008-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2014 ForgeRock AS
 *      Portions Copyright 2011-2015 ForgeRock AS
 */
package org.opends.server.tools;
import java.io.*;
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.util.OperatingSystem.*;
import static org.opends.messages.ToolMessages.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import org.forgerock.i18n.LocalizableMessage;
import org.opends.guitools.controlpanel.util.Utilities;
@@ -39,12 +49,6 @@
import com.forgerock.opendj.cli.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.util.ServerConstants.*;
import static com.forgerock.opendj.util.OperatingSystem.hasUAC;
import static com.forgerock.opendj.cli.Utils.wrapText;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
/**
  * This class is used to configure the Windows service for this instance on
  * this machine.
opendj3-server-dev/src/server/org/opends/server/tools/EncodePassword.java
@@ -26,6 +26,14 @@
 */
package org.opends.server.tools;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
import static org.opends.server.util.StaticUtils.*;
import java.io.Console;
import java.io.IOException;
import java.io.OutputStream;
@@ -35,6 +43,8 @@
import java.util.concurrent.ConcurrentHashMap;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.admin.server.ServerManagementContext;
import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.admin.std.server.LDIFBackendCfg;
@@ -44,18 +54,16 @@
import org.opends.server.api.PasswordStorageScheme;
import org.opends.server.config.ConfigConstants;
import org.opends.server.config.ConfigEntry;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.PasswordStorageSchemeConfigManager;
import org.opends.server.core.DirectoryServer.DirectoryServerVersionHandler;
import org.opends.server.core.PasswordStorageSchemeConfigManager;
import org.opends.server.crypto.CryptoManagerSync;
import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.JDKLogging;
import org.opends.server.schema.AuthPasswordSyntax;
import org.opends.server.schema.UserPasswordSyntax;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.util.BuildVersion;
import com.forgerock.opendj.cli.ArgumentException;
@@ -65,15 +73,6 @@
import com.forgerock.opendj.cli.FileBasedArgument;
import com.forgerock.opendj.cli.StringArgument;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import static com.forgerock.opendj.cli.Utils.wrapText;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
/**
 * This program provides a utility that may be used to interact with the
 * password storage schemes defined in the Directory Server.  In particular,
opendj3-server-dev/src/server/org/opends/server/tools/ExportLDIF.java
@@ -22,61 +22,62 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2014 ForgeRock AS.
 *      Portions Copyright 2012-2015 ForgeRock AS.
 */
package org.opends.server.tools;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.util.StaticUtils.*;
import java.io.OutputStream;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.api.Backend;
import org.opends.server.api.plugin.PluginType;
import org.forgerock.opendj.config.server.ConfigException;
import static org.opends.server.config.ConfigConstants.*;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.DebugLogger;
import org.opends.server.loggers.ErrorLogPublisher;
import org.opends.server.loggers.JDKLogging;
import org.opends.server.loggers.TextWriter;
import org.opends.server.loggers.TextErrorLogPublisher;
import org.opends.server.loggers.ErrorLogger;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.loggers.JDKLogging;
import org.opends.server.loggers.TextErrorLogPublisher;
import org.opends.server.loggers.TextWriter;
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.tasks.ExportTask;
import org.opends.server.tools.tasks.TaskTool;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.ExistingFileBehavior;
import org.opends.server.types.InitializationException;
import org.opends.server.types.LDIFExportConfig;
import org.opends.server.types.NullOutputStream;
import org.opends.server.types.RawAttribute;
import org.opends.server.types.SearchFilter;
import org.opends.server.util.BuildVersion;
import org.opends.server.util.args.LDAPConnectionArgumentParser;
import com.forgerock.opendj.cli.Argument;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.ClientException;
import com.forgerock.opendj.cli.CommonArguments;
import com.forgerock.opendj.cli.IntegerArgument;
import com.forgerock.opendj.cli.StringArgument;
import com.forgerock.opendj.cli.ClientException;
import org.forgerock.i18n.LocalizableMessage;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.wrapText;
import org.opends.server.tools.tasks.TaskTool;
import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.tasks.ExportTask;
/**
 * This program provides a utility that may be used to export the contents of a
@@ -137,24 +138,24 @@
    return tool.process(args, initializeServer, outStream, errStream);
  }
  // Define the command-line arguments that may be used with this program.
  private BooleanArgument appendToLDIF            = null;
  private BooleanArgument compressLDIF            = null;
  private BooleanArgument displayUsage            = null;
  private BooleanArgument encryptLDIF             = null;
  private BooleanArgument excludeOperationalAttrs = null;
  private BooleanArgument signHash                = null;
  private IntegerArgument wrapColumn              = null;
  private StringArgument  backendID               = null;
  private StringArgument  configClass             = null;
  private StringArgument  configFile              = null;
  private StringArgument  excludeAttributeStrings = null;
  private StringArgument  excludeBranchStrings    = null;
  private StringArgument  excludeFilterStrings    = null;
  private StringArgument  includeAttributeStrings = null;
  private StringArgument  includeBranchStrings    = null;
  private StringArgument  includeFilterStrings    = null;
  private StringArgument  ldifFile                = null;
  /** Define the command-line arguments that may be used with this program. */
  private BooleanArgument appendToLDIF;
  private BooleanArgument compressLDIF;
  private BooleanArgument displayUsage;
  private BooleanArgument encryptLDIF;
  private BooleanArgument excludeOperationalAttrs;
  private BooleanArgument signHash;
  private IntegerArgument wrapColumn;
  private StringArgument  backendID;
  private StringArgument  configClass;
  private StringArgument  configFile;
  private StringArgument  excludeAttributeStrings;
  private StringArgument  excludeBranchStrings;
  private StringArgument  excludeFilterStrings;
  private StringArgument  includeAttributeStrings;
  private StringArgument  includeBranchStrings;
  private StringArgument  includeFilterStrings;
  private StringArgument  ldifFile;
  private int process(String[] args, boolean initializeServer,
                      OutputStream outStream, OutputStream errStream) {
@@ -363,150 +364,82 @@
    return process(argParser, initializeServer, out, err);
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public void addTaskAttributes(List<RawAttribute> attributes)
  {
    //
    // Required attributes
    //
    ArrayList<ByteString> values = new ArrayList<ByteString>(1);
    values.add(ByteString.valueOf(ldifFile.getValue()));
    attributes.add(new LDAPAttribute(ATTR_TASK_EXPORT_LDIF_FILE, values));
    attributes.add(new LDAPAttribute(ATTR_TASK_EXPORT_LDIF_FILE, toByteStrings(ldifFile.getValue())));
    attributes.add(new LDAPAttribute(ATTR_TASK_EXPORT_BACKEND_ID, toByteStrings(backendID.getValue())));
    values = new ArrayList<ByteString>(1);
    values.add(ByteString.valueOf(backendID.getValue()));
    attributes.add(new LDAPAttribute(ATTR_TASK_EXPORT_BACKEND_ID, values));
    //
    // Optional attributes
    //
    if (appendToLDIF.getValue() != null &&
            !appendToLDIF.getValue().equals(appendToLDIF.getDefaultValue())) {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf(appendToLDIF.getValue()));
      attributes.add(
              new LDAPAttribute(ATTR_TASK_EXPORT_APPEND_TO_LDIF, values));
    }
    if (compressLDIF.getValue() != null &&
            !compressLDIF.getValue().equals(compressLDIF.getDefaultValue())) {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf(compressLDIF.getValue()));
      attributes.add(new LDAPAttribute(ATTR_TASK_EXPORT_COMPRESS_LDIF, values));
    }
    if (encryptLDIF.getValue() != null &&
            !encryptLDIF.getValue().equals(encryptLDIF.getDefaultValue())) {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf(encryptLDIF.getValue()));
      attributes.add(new LDAPAttribute(ATTR_TASK_EXPORT_ENCRYPT_LDIF, values));
    }
    if (signHash.getValue() != null &&
            !signHash.getValue().equals(signHash.getDefaultValue())) {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf(signHash.getValue()));
      attributes.add(
              new LDAPAttribute(ATTR_TASK_EXPORT_SIGN_HASH, values));
    }
    List<String> includeAttributes = includeAttributeStrings.getValues();
    if (includeAttributes != null && includeAttributes.size() > 0) {
      values = new ArrayList<ByteString>(includeAttributes.size());
      for (String includeAttribute : includeAttributes) {
        values.add(ByteString.valueOf(includeAttribute));
      }
      attributes.add(
              new LDAPAttribute(ATTR_TASK_EXPORT_INCLUDE_ATTRIBUTE, values));
    }
    List<String> excludeAttributes = excludeAttributeStrings.getValues();
    if (excludeAttributes != null && excludeAttributes.size() > 0) {
      values = new ArrayList<ByteString>(excludeAttributes.size());
      for (String excludeAttribute : excludeAttributes) {
        values.add(ByteString.valueOf(excludeAttribute));
      }
      attributes.add(
              new LDAPAttribute(ATTR_TASK_EXPORT_EXCLUDE_ATTRIBUTE, values));
    }
    List<String> includeFilters = includeFilterStrings.getValues();
    if (includeFilters != null && includeFilters.size() > 0) {
      values = new ArrayList<ByteString>(includeFilters.size());
      for (String includeFilter : includeFilters) {
        values.add(ByteString.valueOf(includeFilter));
      }
      attributes.add(
              new LDAPAttribute(ATTR_TASK_EXPORT_INCLUDE_FILTER, values));
    }
    List<String> excludeFilters = excludeFilterStrings.getValues();
    if (excludeFilters != null && excludeFilters.size() > 0) {
      values = new ArrayList<ByteString>(excludeFilters.size());
      for (String excludeFilter : excludeFilters) {
        values.add(ByteString.valueOf(excludeFilter));
      }
      attributes.add(
              new LDAPAttribute(ATTR_TASK_EXPORT_EXCLUDE_FILTER, values));
    }
    List<String> includeBranches = includeBranchStrings.getValues();
    if (includeBranches != null && includeBranches.size() > 0) {
      values = new ArrayList<ByteString>(includeBranches.size());
      for (String includeBranche : includeBranches) {
        values.add(ByteString.valueOf(includeBranche));
      }
      attributes.add(
              new LDAPAttribute(ATTR_TASK_EXPORT_INCLUDE_BRANCH, values));
    }
    List<String> excludeBranches = excludeBranchStrings.getValues();
    if (excludeBranches != null && excludeBranches.size() > 0) {
      values = new ArrayList<ByteString>(excludeBranches.size());
      for (String excludeBranche : excludeBranches) {
        values.add(ByteString.valueOf(excludeBranche));
      }
      attributes.add(
              new LDAPAttribute(ATTR_TASK_EXPORT_EXCLUDE_BRANCH, values));
    }
    if (wrapColumn.getValue() != null &&
            !wrapColumn.getValue().equals(wrapColumn.getDefaultValue())) {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf(wrapColumn.getValue()));
      attributes.add(
              new LDAPAttribute(ATTR_TASK_EXPORT_WRAP_COLUMN, values));
    }
    addAttribute(attributes, ATTR_TASK_EXPORT_APPEND_TO_LDIF, appendToLDIF);
    addAttribute(attributes, ATTR_TASK_EXPORT_COMPRESS_LDIF, compressLDIF);
    addAttribute(attributes, ATTR_TASK_EXPORT_ENCRYPT_LDIF, encryptLDIF);
    addAttribute(attributes, ATTR_TASK_EXPORT_SIGN_HASH, signHash);
    addAttribute(attributes, ATTR_TASK_EXPORT_INCLUDE_ATTRIBUTE, includeAttributeStrings.getValues());
    addAttribute(attributes, ATTR_TASK_EXPORT_EXCLUDE_ATTRIBUTE, excludeAttributeStrings.getValues());
    addAttribute(attributes, ATTR_TASK_EXPORT_INCLUDE_FILTER, includeFilterStrings.getValues());
    addAttribute(attributes, ATTR_TASK_EXPORT_EXCLUDE_FILTER, excludeFilterStrings.getValues());
    addAttribute(attributes, ATTR_TASK_EXPORT_INCLUDE_BRANCH, includeBranchStrings.getValues());
    addAttribute(attributes, ATTR_TASK_EXPORT_EXCLUDE_BRANCH, excludeBranchStrings.getValues());
    addAttribute(attributes, ATTR_TASK_EXPORT_WRAP_COLUMN, wrapColumn);
    if (excludeOperationalAttrs.isPresent())
    {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf("false"));
      attributes.add(
          new LDAPAttribute(ATTR_TASK_EXPORT_INCLUDE_OPERATIONAL_ATTRIBUTES,
              values));
              toByteStrings("false")));
    }
  }
  /**
   * {@inheritDoc}
   */
  private void addAttribute(List<RawAttribute> attributes, String attrName, Argument arg)
  {
    if (arg.getValue() != null && !arg.getValue().equals(arg.getDefaultValue()))
    {
      attributes.add(new LDAPAttribute(attrName, toByteStrings(arg.getValue())));
    }
  }
  private void addAttribute(List<RawAttribute> attributes, String attrName, List<String> attrValues)
  {
    if (attrValues != null && !attrValues.isEmpty())
    {
      attributes.add(new LDAPAttribute(attrName, toByteStrings(attrValues)));
    }
  }
  private ArrayList<ByteString> toByteStrings(String value)
  {
    final ArrayList<ByteString> values = new ArrayList<ByteString>(1);
    values.add(ByteString.valueOf(value));
    return values;
  }
  private ArrayList<ByteString> toByteStrings(List<String> includeAttributes)
  {
    final ArrayList<ByteString> values = new ArrayList<ByteString>(includeAttributes.size());
    for (String includeAttribute : includeAttributes)
    {
      values.add(ByteString.valueOf(includeAttribute));
    }
    return values;
  }
  /** {@inheritDoc} */
  @Override
  public String getTaskObjectclass() {
    return "ds-task-export";
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public Class<?> getTaskClass() {
    return ExportTask.class;
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  protected int processLocal(boolean initializeServer,
                           PrintStream out,
                           PrintStream err) {
@@ -1002,12 +935,10 @@
    }
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public String getTaskId() {
    // NYI.
    return null;
  }
}
opendj3-server-dev/src/server/org/opends/server/tools/ImportLDIF.java
@@ -26,18 +26,12 @@
 */
package org.opends.server.tools;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static org.opends.messages.ToolMessages.*;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import static org.opends.server.config.ConfigConstants.*;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import static com.forgerock.opendj.cli.Utils.wrapText;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
import java.io.File;
import java.io.OutputStream;
@@ -48,10 +42,13 @@
import java.util.Random;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.api.Backend;
import org.opends.server.api.plugin.PluginType;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
@@ -67,7 +64,6 @@
import org.opends.server.tools.makeldif.TemplateFile;
import org.opends.server.tools.tasks.TaskTool;
import org.opends.server.types.AttributeType;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.ExistingFileBehavior;
@@ -76,19 +72,17 @@
import org.opends.server.types.LDIFImportResult;
import org.opends.server.types.NullOutputStream;
import org.opends.server.types.RawAttribute;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.types.SearchFilter;
import org.opends.server.util.BuildVersion;
import org.opends.server.util.args.LDAPConnectionArgumentParser;
import com.forgerock.opendj.cli.Argument;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.ClientException;
import com.forgerock.opendj.cli.CommonArguments;
import com.forgerock.opendj.cli.IntegerArgument;
import com.forgerock.opendj.cli.StringArgument;
import com.forgerock.opendj.cli.ClientException;
/**
 * This program provides a utility that may be used to import the contents of an
@@ -154,34 +148,34 @@
    return tool.process(args, initializeServer, outStream, errStream);
  }
  // Define the command-line arguments that may be used with this program.
  private BooleanArgument append                  = null;
  private BooleanArgument countRejects            = null;
  private BooleanArgument displayUsage            = null;
  private BooleanArgument isCompressed            = null;
  private BooleanArgument isEncrypted             = null;
  private BooleanArgument overwrite               = null;
  private BooleanArgument quietMode               = null;
  private BooleanArgument replaceExisting         = null;
  private BooleanArgument skipSchemaValidation    = null;
  private BooleanArgument clearBackend            = null;
  private IntegerArgument randomSeed              = null;
  private StringArgument  backendID               = null;
  private StringArgument  configClass             = null;
  private StringArgument  configFile              = null;
  private StringArgument  excludeAttributeStrings = null;
  private StringArgument  excludeBranchStrings    = null;
  private StringArgument  excludeFilterStrings    = null;
  private StringArgument  includeAttributeStrings = null;
  private StringArgument  includeBranchStrings    = null;
  private StringArgument  includeFilterStrings    = null;
  private StringArgument  ldifFiles               = null;
  private StringArgument  rejectFile              = null;
  private StringArgument  skipFile                = null;
  private StringArgument  templateFile            = null;
  private BooleanArgument skipDNValidation        = null;
  private IntegerArgument threadCount             = null;
  private StringArgument  tmpDirectory            = null;
  /** Define the command-line arguments that may be used with this program. */
  private BooleanArgument append;
  private BooleanArgument countRejects;
  private BooleanArgument displayUsage;
  private BooleanArgument isCompressed;
  private BooleanArgument isEncrypted;
  private BooleanArgument overwrite;
  private BooleanArgument quietMode;
  private BooleanArgument replaceExisting;
  private BooleanArgument skipSchemaValidation;
  private BooleanArgument clearBackend;
  private IntegerArgument randomSeed;
  private StringArgument  backendID;
  private StringArgument  configClass;
  private StringArgument  configFile;
  private StringArgument  excludeAttributeStrings;
  private StringArgument  excludeBranchStrings;
  private StringArgument  excludeFilterStrings;
  private StringArgument  includeAttributeStrings;
  private StringArgument  includeBranchStrings;
  private StringArgument  includeFilterStrings;
  private StringArgument  ldifFiles;
  private StringArgument  rejectFile;
  private StringArgument  skipFile;
  private StringArgument  templateFile;
  private BooleanArgument skipDNValidation;
  private IntegerArgument threadCount;
  private StringArgument  tmpDirectory;
  private int process(String[] args, boolean initializeServer,
                      OutputStream outStream, OutputStream errStream) {
@@ -514,230 +508,91 @@
    return process(argParser, initializeServer, out, err);
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public void addTaskAttributes(List<RawAttribute> attributes)
  {
    //
    // Required attributes
    //
    ArrayList<ByteString> values;
    addAttribute(attributes, ATTR_IMPORT_LDIF_FILE, ldifFiles.getValues());
    addAttribute(attributes, ATTR_IMPORT_TEMPLATE_FILE, templateFile.getValue());
    addAttribute(attributes, ATTR_IMPORT_RANDOM_SEED, randomSeed.getValue());
    addAttribute(attributes, ATTR_IMPORT_THREAD_COUNT, threadCount.getValue());
    List<String> fileList = ldifFiles.getValues();
    if ((fileList != null) && (fileList.size() > 0))
    {
      if (fileList != null && fileList.size() > 0) {
        values = new ArrayList<ByteString>(fileList.size());
        for (String file : fileList) {
          values.add(ByteString.valueOf(file));
        }
        attributes.add(new LDAPAttribute(ATTR_IMPORT_LDIF_FILE, values));
      }
    }
    String templateFileValue = templateFile.getValue();
    if (templateFileValue != null)
    {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf(templateFileValue));
      attributes.add(new LDAPAttribute(ATTR_IMPORT_TEMPLATE_FILE, values));
    }
    String randomSeedValue = randomSeed.getValue();
    if (randomSeedValue != null)
    {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf(randomSeedValue));
      attributes.add(new LDAPAttribute(ATTR_IMPORT_RANDOM_SEED, values));
    }
    if (threadCount.getValue() != null) {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf(threadCount.getValue()));
      attributes.add(new LDAPAttribute(ATTR_IMPORT_THREAD_COUNT, values));
    }
    //
    // Optional attributes
    //
    if (append.getValue() != null &&
            !append.getValue().equals(append.getDefaultValue())) {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf(append.getValue()));
      attributes.add(new LDAPAttribute(ATTR_IMPORT_APPEND, values));
    addAttribute2(attributes, ATTR_IMPORT_APPEND, append);
    addAttribute2(attributes, ATTR_IMPORT_REPLACE_EXISTING, replaceExisting);
    addAttribute2(attributes, ATTR_IMPORT_BACKEND_ID, backendID);
    addAttribute(attributes, ATTR_IMPORT_INCLUDE_ATTRIBUTE, includeAttributeStrings.getValues());
    addAttribute(attributes, ATTR_IMPORT_EXCLUDE_ATTRIBUTE, excludeAttributeStrings.getValues());
    addAttribute(attributes, ATTR_IMPORT_INCLUDE_FILTER, includeFilterStrings.getValues());
    addAttribute(attributes, ATTR_IMPORT_EXCLUDE_FILTER, excludeFilterStrings.getValues());
    addAttribute(attributes, ATTR_IMPORT_INCLUDE_BRANCH, includeBranchStrings.getValues());
    addAttribute(attributes, ATTR_IMPORT_EXCLUDE_BRANCH, excludeBranchStrings.getValues());
    addAttribute2(attributes, ATTR_IMPORT_REJECT_FILE, rejectFile);
    addAttribute2(attributes, ATTR_IMPORT_SKIP_FILE, skipFile);
    addAttribute2(attributes, ATTR_IMPORT_OVERWRITE, overwrite);
    addAttribute2(attributes, ATTR_IMPORT_SKIP_SCHEMA_VALIDATION, skipSchemaValidation);
    addAttribute2(attributes, ATTR_IMPORT_TMP_DIRECTORY, tmpDirectory);
    addAttribute2(attributes, ATTR_IMPORT_SKIP_DN_VALIDATION, skipDNValidation);
    addAttribute2(attributes, ATTR_IMPORT_IS_COMPRESSED, isCompressed);
    addAttribute2(attributes, ATTR_IMPORT_IS_ENCRYPTED, isEncrypted);
    addAttribute2(attributes, ATTR_IMPORT_CLEAR_BACKEND, clearBackend);
    }
    if (replaceExisting.getValue() != null &&
            !replaceExisting.getValue().equals(
                    replaceExisting.getDefaultValue())) {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf(replaceExisting.getValue()));
      attributes.add(new LDAPAttribute(ATTR_IMPORT_REPLACE_EXISTING, values));
  private void addAttribute(List<RawAttribute> attributes, String attrName, String value)
  {
    if (value != null)
    {
      attributes.add(new LDAPAttribute(attrName, toByteStrings(value)));
    }
    }
    if (backendID.getValue() != null &&
            !backendID.getValue().equals(
                    backendID.getDefaultValue())) {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf(backendID.getValue()));
      attributes.add(new LDAPAttribute(ATTR_IMPORT_BACKEND_ID, values));
  private void addAttribute2(List<RawAttribute> attributes, String attrName, Argument arg)
  {
    if (arg.getValue() != null && !arg.getValue().equals(arg.getDefaultValue()))
    {
      attributes.add(new LDAPAttribute(attrName, toByteStrings(arg.getValue())));
    }
    }
    List<String> includeAttributes = includeAttributeStrings.getValues();
    if (includeAttributes != null && includeAttributes.size() > 0) {
      values = new ArrayList<ByteString>(includeAttributes.size());
      for (String includeAttribute : includeAttributes) {
        values.add(ByteString.valueOf(includeAttribute));
  private void addAttribute(List<RawAttribute> attributes, String attrName, List<String> attrValues)
  {
    if (attrValues != null && !attrValues.isEmpty())
    {
      attributes.add(new LDAPAttribute(attrName, toByteStrings(attrValues)));
      }
      attributes.add(new LDAPAttribute(ATTR_IMPORT_INCLUDE_ATTRIBUTE, values));
    }
    List<String> excludeAttributes = excludeAttributeStrings.getValues();
    if (excludeAttributes != null && excludeAttributes.size() > 0) {
      values = new ArrayList<ByteString>(excludeAttributes.size());
      for (String excludeAttribute : excludeAttributes) {
        values.add(ByteString.valueOf(excludeAttribute));
      }
      attributes.add(new LDAPAttribute(ATTR_IMPORT_EXCLUDE_ATTRIBUTE, values));
  private ArrayList<ByteString> toByteStrings(String value)
  {
    final ArrayList<ByteString> values = new ArrayList<ByteString>(1);
    values.add(ByteString.valueOf(value));
    return values;
    }
    List<String> includeFilters = includeFilterStrings.getValues();
    if (includeFilters != null && includeFilters.size() > 0) {
      values = new ArrayList<ByteString>(includeFilters.size());
      for (String includeFilter : includeFilters) {
        values.add(ByteString.valueOf(includeFilter));
      }
      attributes.add(new LDAPAttribute(ATTR_IMPORT_INCLUDE_FILTER, values));
    }
    List<String> excludeFilters = excludeFilterStrings.getValues();
    if (excludeFilters != null && excludeFilters.size() > 0) {
      values = new ArrayList<ByteString>(excludeFilters.size());
      for (String excludeFilter : excludeFilters) {
        values.add(ByteString.valueOf(excludeFilter));
      }
      attributes.add(new LDAPAttribute(ATTR_IMPORT_EXCLUDE_FILTER, values));
    }
    List<String> includeBranches = includeBranchStrings.getValues();
    if (includeBranches != null && includeBranches.size() > 0) {
      values = new ArrayList<ByteString>(includeBranches.size());
      for (String includeBranche : includeBranches) {
  private ArrayList<ByteString> toByteStrings(List<String> attrValues)
  {
    final ArrayList<ByteString> values = new ArrayList<ByteString>(attrValues.size());
    for (String includeBranche : attrValues)
    {
        values.add(ByteString.valueOf(includeBranche));
      }
      attributes.add(new LDAPAttribute(ATTR_IMPORT_INCLUDE_BRANCH, values));
    return values;
    }
    List<String> excludeBranches = excludeBranchStrings.getValues();
    if (excludeBranches != null && excludeBranches.size() > 0) {
      values = new ArrayList<ByteString>(excludeBranches.size());
      for (String excludeBranch : excludeBranches) {
        values.add(ByteString.valueOf(excludeBranch));
      }
      attributes.add(new LDAPAttribute(ATTR_IMPORT_EXCLUDE_BRANCH, values));
    }
    if (rejectFile.getValue() != null &&
            !rejectFile.getValue().equals(
                    rejectFile.getDefaultValue())) {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf(rejectFile.getValue()));
      attributes.add(new LDAPAttribute(ATTR_IMPORT_REJECT_FILE, values));
    }
    if (skipFile.getValue() != null &&
            !skipFile.getValue().equals(
                    skipFile.getDefaultValue())) {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf(skipFile.getValue()));
      attributes.add(new LDAPAttribute(ATTR_IMPORT_SKIP_FILE, values));
    }
    if (overwrite.getValue() != null &&
            !overwrite.getValue().equals(
                    overwrite.getDefaultValue())) {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf(overwrite.getValue()));
      attributes.add(new LDAPAttribute(ATTR_IMPORT_OVERWRITE, values));
    }
    if (skipSchemaValidation.getValue() != null &&
            !skipSchemaValidation.getValue().equals(
                    skipSchemaValidation.getDefaultValue())) {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf(skipSchemaValidation.getValue()));
      attributes.add(
              new LDAPAttribute(ATTR_IMPORT_SKIP_SCHEMA_VALIDATION, values));
    }
    if (tmpDirectory.getValue() != null &&
            !tmpDirectory.getValue().equals(
                    tmpDirectory.getDefaultValue())) {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf(tmpDirectory.getValue()));
      attributes.add(new LDAPAttribute(ATTR_IMPORT_TMP_DIRECTORY, values));
    }
    if (skipDNValidation.getValue() != null &&
            !skipDNValidation.getValue().equals(
                    skipDNValidation.getDefaultValue())) {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf(skipDNValidation.getValue()));
      attributes.add(
              new LDAPAttribute(ATTR_IMPORT_SKIP_DN_VALIDATION, values));
    }
    if (isCompressed.getValue() != null &&
            !isCompressed.getValue().equals(
                    isCompressed.getDefaultValue())) {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf(isCompressed.getValue()));
      attributes.add(
              new LDAPAttribute(ATTR_IMPORT_IS_COMPRESSED, values));
    }
    if (isEncrypted.getValue() != null &&
            !isEncrypted.getValue().equals(
                    isEncrypted.getDefaultValue())) {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf(isEncrypted.getValue()));
      attributes.add(
              new LDAPAttribute(ATTR_IMPORT_IS_ENCRYPTED, values));
    }
    if (clearBackend.getValue() != null &&
            !clearBackend.getValue().equals(
                    clearBackend.getDefaultValue())) {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf(clearBackend.getValue()));
      attributes.add(
              new LDAPAttribute(ATTR_IMPORT_CLEAR_BACKEND, values));
    }
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public String getTaskObjectclass() {
    return "ds-task-import";
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public Class<?> getTaskClass() {
    return ImportTask.class;
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  protected int processLocal(boolean initializeServer,
                           PrintStream out,
@@ -1129,7 +984,7 @@
    // through them, finding the one backend into which the LDIF should be
    // imported and finding backends with subordinate base DNs that should be
    // excluded from the import.
    Backend       backend           = null;
    Backend<?> backend = null;
    List<DN> defaultIncludeBranches = null;
    List<DN> excludeBranches        = new ArrayList<DN>();
    List<DN> includeBranches        = new ArrayList<DN>();
@@ -1171,7 +1026,7 @@
    int numBackends = backendList.size();
    for (int i=0; i < numBackends; i++)
    {
      Backend b = backendList.get(i);
      Backend<?> b = backendList.get(i);
      if(backendID.isPresent())
      {
@@ -1542,12 +1397,10 @@
    return retCode;
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public String getTaskId() {
    // NYI.
    return null;
  }
}
opendj3-server-dev/src/server/org/opends/server/tools/LDAPCompare.java
@@ -26,6 +26,13 @@
 */
package org.opends.server.tools;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
import static org.opends.server.util.args.LDAPConnectionArgumentParser.*;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
@@ -64,38 +71,30 @@
import com.forgerock.opendj.cli.IntegerArgument;
import com.forgerock.opendj.cli.StringArgument;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.args.LDAPConnectionArgumentParser.*;
import static com.forgerock.opendj.cli.Utils.wrapText;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
/**
 * This class provides a tool that can be used to issue compare requests to the
 * Directory Server.
 */
public class LDAPCompare
{
  /**
   * The fully-qualified name of this class.
   */
  /** The fully-qualified name of this class. */
  private static final String CLASS_NAME =
      "org.opends.server.tools.LDAPCompare";
  // The message ID counter to use for requests.
  /** The message ID counter to use for requests. */
  private final AtomicInteger nextMessageID;
  // The print stream to use for standard error.
  /** The print stream to use for standard error. */
  private final PrintStream err;
  // The print stream to use for standard output.
  /** The print stream to use for standard output. */
  private final PrintStream out;
  // Tells whether the command-line is being executed in script friendly mode
  // or not.
  /**
   * Tells whether the command-line is being executed in script friendly mode
   * or not.
   */
  private boolean isScriptFriendly;
opendj3-server-dev/src/server/org/opends/server/tools/LDAPDelete.java
@@ -26,10 +26,17 @@
 */
package org.opends.server.tools;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
import static org.opends.server.util.args.LDAPConnectionArgumentParser.*;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.Reader;
@@ -61,14 +68,6 @@
import com.forgerock.opendj.cli.IntegerArgument;
import com.forgerock.opendj.cli.StringArgument;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
import static org.opends.server.util.ServerConstants.*;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static org.opends.server.util.args.LDAPConnectionArgumentParser.*;
import static com.forgerock.opendj.cli.Utils.wrapText;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
/**
 * This class provides a tool that can be used to issue delete requests to the
 * Directory Server.
@@ -77,20 +76,16 @@
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  /**
   * The fully-qualified name of this class.
   */
  /** The fully-qualified name of this class. */
  private static final String CLASS_NAME = "org.opends.server.tools.LDAPDelete";
  // The message ID counter to use for requests.
  /** The message ID counter to use for requests. */
  private final AtomicInteger nextMessageID;
  // The print stream to use for standard error.
  /** The print stream to use for standard error. */
  private final PrintStream err;
  // The print stream to use for standard output.
  /** The print stream to use for standard output. */
  private final PrintStream out;
opendj3-server-dev/src/server/org/opends/server/tools/LDAPModify.java
@@ -27,10 +27,18 @@
 */
package org.opends.server.tools;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.args.LDAPConnectionArgumentParser.*;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.*;
@@ -54,10 +62,10 @@
import org.opends.server.protocols.ldap.LDAPControl;
import org.opends.server.protocols.ldap.LDAPFilter;
import org.opends.server.protocols.ldap.LDAPMessage;
import org.opends.server.protocols.ldap.ModifyRequestProtocolOp;
import org.opends.server.protocols.ldap.ModifyResponseProtocolOp;
import org.opends.server.protocols.ldap.ModifyDNRequestProtocolOp;
import org.opends.server.protocols.ldap.ModifyDNResponseProtocolOp;
import org.opends.server.protocols.ldap.ModifyRequestProtocolOp;
import org.opends.server.protocols.ldap.ModifyResponseProtocolOp;
import org.opends.server.protocols.ldap.ProtocolOp;
import org.opends.server.types.*;
import org.opends.server.util.AddChangeRecordEntry;
@@ -77,14 +85,6 @@
import com.forgerock.opendj.cli.IntegerArgument;
import com.forgerock.opendj.cli.StringArgument;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.args.LDAPConnectionArgumentParser.*;
import static com.forgerock.opendj.cli.Utils.wrapText;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
/**
 * This class provides a tool that can be used to issue modify requests to the
 * Directory Server.
opendj3-server-dev/src/server/org/opends/server/tools/LDAPPasswordModify.java
@@ -26,6 +26,15 @@
 */
package org.opends.server.tools;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.extensions.ExtensionsConstants.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
@@ -33,20 +42,22 @@
import java.util.concurrent.atomic.AtomicInteger;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.io.*;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.opends.server.controls.PasswordPolicyErrorType;
import org.opends.server.controls.PasswordPolicyResponseControl;
import org.opends.server.controls.PasswordPolicyWarningType;
import org.opends.server.core.DirectoryServer.DirectoryServerVersionHandler;
import org.forgerock.opendj.io.*;
import org.opends.server.protocols.ldap.ExtendedRequestProtocolOp;
import org.opends.server.protocols.ldap.ExtendedResponseProtocolOp;
import org.opends.server.protocols.ldap.LDAPControl;
import org.opends.server.protocols.ldap.LDAPMessage;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.protocols.ldap.UnbindRequestProtocolOp;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.opends.server.types.Control;
import org.opends.server.types.DN;
import org.opends.server.types.NullOutputStream;
import org.opends.server.util.EmbeddedUtils;
import com.forgerock.opendj.cli.ArgumentException;
@@ -59,15 +70,6 @@
import com.forgerock.opendj.cli.IntegerArgument;
import com.forgerock.opendj.cli.StringArgument;
import static org.opends.server.extensions.ExtensionsConstants.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
import static com.forgerock.opendj.cli.Utils.wrapText;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
/**
 * This program provides a utility that uses the LDAP password modify extended
 * operation to change the password for a user.  It exposes the three primary
opendj3-server-dev/src/server/org/opends/server/tools/LDAPSearch.java
@@ -26,6 +26,16 @@
 */
package org.opends.server.tools;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.protocols.ldap.LDAPConstants.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import static org.opends.server.util.args.LDAPConnectionArgumentParser.*;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
@@ -55,16 +65,6 @@
import com.forgerock.opendj.cli.MultiChoiceArgument;
import com.forgerock.opendj.cli.StringArgument;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.protocols.ldap.LDAPConstants.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import static org.opends.server.util.args.LDAPConnectionArgumentParser.*;
import static com.forgerock.opendj.cli.Utils.wrapText;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
/**
 * This class provides a tool that can be used to issue search requests to the
 * Directory Server.
@@ -73,23 +73,20 @@
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  /**
   * The fully-qualified name of this class.
   */
  /** The fully-qualified name of this class. */
  private static final String CLASS_NAME = "org.opends.server.tools.LDAPSearch";
  // The set of response controls for the search.
  /** The set of response controls for the search. */
  private List<Control> responseControls;
  // The message ID counter to use for requests.
  /** The message ID counter to use for requests. */
  private final AtomicInteger nextMessageID;
  // The print stream to use for standard error.
  /** The print stream to use for standard error. */
  private final PrintStream err;
  // The print stream to use for standard output.
  /** The print stream to use for standard output. */
  private final PrintStream out;
opendj3-server-dev/src/server/org/opends/server/tools/LDIFModify.java
@@ -26,6 +26,12 @@
 */
package org.opends.server.tools;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.util.StaticUtils.*;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
@@ -73,13 +79,6 @@
import com.forgerock.opendj.cli.CommonArguments;
import com.forgerock.opendj.cli.StringArgument;
import static org.opends.messages.ToolMessages.*;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import static com.forgerock.opendj.cli.Utils.wrapText;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
/**
 * This class provides a program that may be used to apply a set of changes (in
 * LDIF change format) to an LDIF file.  It will first read all of the changes
opendj3-server-dev/src/server/org/opends/server/tools/LDIFSearch.java
@@ -26,6 +26,12 @@
 */
package org.opends.server.tools;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.util.StaticUtils.*;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.OutputStream;
@@ -50,13 +56,6 @@
import com.forgerock.opendj.cli.*;
import static org.opends.messages.ToolMessages.*;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import static com.forgerock.opendj.cli.Utils.wrapText;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
/**
 * This class provides a program that may be used to search LDIF files.  It is
 * modeled after the LDAPSearch tool, with the primary differencing being that
opendj3-server-dev/src/server/org/opends/server/tools/ListBackends.java
@@ -26,6 +26,14 @@
 */
package org.opends.server.tools;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.util.StaticUtils.*;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Iterator;
@@ -33,17 +41,17 @@
import java.util.TreeMap;
import java.util.TreeSet;
import org.opends.server.config.ConfigEntry;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.config.ConfigEntry;
import org.opends.server.config.DNConfigAttribute;
import org.opends.server.config.StringConfigAttribute;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.DirectoryServer.DirectoryServerVersionHandler;
import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.JDKLogging;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.InitializationException;
import org.opends.server.types.NullOutputStream;
import org.opends.server.util.BuildVersion;
@@ -56,15 +64,6 @@
import com.forgerock.opendj.cli.TableBuilder;
import com.forgerock.opendj.cli.TextTablePrinter;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.wrapText;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
/**
 * This program provides a utility that may be used to list the backends in the
 * server, as well as to determine which backend holds a given entry.
@@ -452,9 +451,9 @@
      TableBuilder table = new TableBuilder();
      LocalizableMessage[] headers = {backendIDLabel, baseDNLabel};
      for (int i=0; i< headers.length; i++)
      for (LocalizableMessage header : headers)
      {
        table.appendHeading(headers[i]);
        table.appendHeading(header);
      }
      for (String id : backendIDs)
      {
opendj3-server-dev/src/server/org/opends/server/tools/ManageAccount.java
@@ -28,8 +28,7 @@
package org.opends.server.tools;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.wrapText;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
import static com.forgerock.opendj.cli.Utils.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.extensions.PasswordPolicyStateExtendedOperation.*;
opendj3-server-dev/src/server/org/opends/server/tools/RestoreDB.java
@@ -22,12 +22,16 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2014 ForgeRock AS.
 *      Portions Copyright 2012-2015 ForgeRock AS.
 */
package org.opends.server.tools;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.util.StaticUtils.*;
import java.io.OutputStream;
import java.io.PrintStream;
@@ -38,45 +42,36 @@
import java.util.Iterator;
import java.util.List;
import org.opends.server.api.Backend;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.api.Backend;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.DebugLogger;
import org.opends.server.loggers.ErrorLogPublisher;
import org.opends.server.loggers.JDKLogging;
import org.opends.server.loggers.TextWriter;
import org.opends.server.loggers.ErrorLogger;
import org.opends.server.loggers.JDKLogging;
import org.opends.server.loggers.TextErrorLogPublisher;
import org.opends.server.loggers.TextWriter;
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.tasks.RestoreTask;
import org.opends.server.tools.tasks.TaskTool;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.util.BuildVersion;
import org.opends.server.util.args.LDAPConnectionArgumentParser;
import com.forgerock.opendj.cli.Argument;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.ClientException;
import com.forgerock.opendj.cli.CommonArguments;
import com.forgerock.opendj.cli.StringArgument;
import org.opends.server.util.args.LDAPConnectionArgumentParser;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static org.opends.server.config.ConfigConstants.*;
import static com.forgerock.opendj.cli.Utils.wrapText;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
import org.opends.server.tools.tasks.TaskTool;
import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.tasks.RestoreTask;
/**
 * This program provides a utility that may be used to restore a binary backup
 * of a Directory Server backend generated using the BackUpDB tool.  This will
@@ -137,14 +132,14 @@
  }
  // Define the command-line arguments that may be used with this program.
  private BooleanArgument displayUsage      = null;
  private BooleanArgument listBackups       = null;
  private BooleanArgument verifyOnly        = null;
  private StringArgument  backupIDString    = null;
  private StringArgument  configClass       = null;
  private StringArgument  configFile        = null;
  private StringArgument  backupDirectory   = null;
  /** Define the command-line arguments that may be used with this program. */
  private BooleanArgument displayUsage;
  private BooleanArgument listBackups;
  private BooleanArgument verifyOnly;
  private StringArgument  backupIDString;
  private StringArgument  configClass;
  private StringArgument  configFile;
  private StringArgument  backupDirectory;
  private int process(String[] args, boolean initializeServer,
@@ -285,59 +280,44 @@
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public void addTaskAttributes(List<RawAttribute> attributes)
  {
    ArrayList<ByteString> values;
    if (backupDirectory.getValue() != null &&
            !backupDirectory.getValue().equals(
                    backupDirectory.getDefaultValue())) {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf(backupDirectory.getValue()));
      attributes.add(
              new LDAPAttribute(ATTR_BACKUP_DIRECTORY_PATH, values));
    addAttribute(attributes, ATTR_BACKUP_DIRECTORY_PATH, backupDirectory);
    addAttribute(attributes, ATTR_BACKUP_ID, backupIDString);
    addAttribute(attributes, ATTR_TASK_RESTORE_VERIFY_ONLY, verifyOnly);
    }
    if (backupIDString.getValue() != null &&
            !backupIDString.getValue().equals(
                    backupIDString.getDefaultValue())) {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf(backupIDString.getValue()));
      attributes.add(
              new LDAPAttribute(ATTR_BACKUP_ID, values));
  private void addAttribute(List<RawAttribute> attributes, String attrName, Argument arg)
  {
    if (arg.getValue() != null && !arg.getValue().equals(arg.getDefaultValue()))
    {
      attributes.add(new LDAPAttribute(attrName, toByteStrings(arg.getValue())));
    }
    }
    if (verifyOnly.getValue() != null &&
            !verifyOnly.getValue().equals(
                    verifyOnly.getDefaultValue())) {
      values = new ArrayList<ByteString>(1);
      values.add(ByteString.valueOf(verifyOnly.getValue()));
      attributes.add(
              new LDAPAttribute(ATTR_TASK_RESTORE_VERIFY_ONLY, values));
  private ArrayList<ByteString> toByteStrings(String value)
  {
    final ArrayList<ByteString> values = new ArrayList<ByteString>(1);
    values.add(ByteString.valueOf(value));
    return values;
    }
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public String getTaskObjectclass() {
    return "ds-task-restore";
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public Class<?> getTaskClass() {
    return RestoreTask.class;
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  protected int processLocal(boolean initializeServer,
                           PrintStream out,
                           PrintStream err) {
@@ -676,15 +656,9 @@
    return 0;
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  public String getTaskId() {
    if (backupIDString != null) {
      return backupIDString.getValue();
    } else {
      return null;
    return backupIDString != null? backupIDString.getValue() : null;
    }
  }
}
opendj3-server-dev/src/server/org/opends/server/tools/StopDS.java
@@ -26,6 +26,14 @@
 */
package org.opends.server.tools;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
@@ -45,8 +53,8 @@
import org.opends.server.admin.AdministrationConnector;
import org.opends.server.controls.ProxiedAuthV2Control;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
import org.opends.server.core.DirectoryServer.DirectoryServerVersionHandler;
import org.opends.server.core.LockFileManager;
import org.opends.server.loggers.JDKLogging;
import org.opends.server.protocols.ldap.AddRequestProtocolOp;
import org.opends.server.protocols.ldap.AddResponseProtocolOp;
@@ -57,7 +65,10 @@
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.tasks.ShutdownTask;
import org.opends.server.tools.tasks.TaskTool;
import org.opends.server.types.*;
import org.opends.server.types.Control;
import org.opends.server.types.LDAPException;
import org.opends.server.types.NullOutputStream;
import org.opends.server.types.RawAttribute;
import org.opends.server.util.args.LDAPConnectionArgumentParser;
import com.forgerock.opendj.cli.Argument;
@@ -70,14 +81,6 @@
import com.forgerock.opendj.cli.IntegerArgument;
import com.forgerock.opendj.cli.StringArgument;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.wrapText;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
/**
 * This class provides a tool that can send a request to the Directory Server
 * that will cause it to shut down.
opendj3-server-dev/src/server/org/opends/server/tools/makeldif/MakeLDIF.java
@@ -26,6 +26,12 @@
 */
package org.opends.server.tools.makeldif;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.util.StaticUtils.*;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
@@ -51,13 +57,6 @@
import com.forgerock.opendj.cli.IntegerArgument;
import com.forgerock.opendj.cli.StringArgument;
import static org.opends.messages.ToolMessages.*;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import static com.forgerock.opendj.cli.Utils.wrapText;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
/**
 * This class defines a program that can be used to generate LDIF content based
 * on a template.
opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskTool.java
@@ -22,46 +22,44 @@
 *
 *
 *      Copyright 2007-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2014 ForgeRock AS
 *      Portions Copyright 2012-2015 ForgeRock AS
 */
package org.opends.server.tools.tasks;
import com.forgerock.opendj.cli.Argument;
import com.forgerock.opendj.cli.ArgumentGroup;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.CommonArguments;
import com.forgerock.opendj.cli.StringArgument;
import com.forgerock.opendj.cli.ClientException;
import static com.forgerock.opendj.cli.Utils.*;
import static org.opends.server.util.StaticUtils.getExceptionMessage;
import static org.opends.server.util.ServerConstants.MAX_LINE_WIDTH;
import static com.forgerock.opendj.cli.Utils.wrapText;
import static org.opends.messages.TaskMessages.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.util.StaticUtils.*;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.admin.client.cli.TaskScheduleArgs;
import org.opends.server.backends.task.FailedDependencyAction;
import org.opends.server.backends.task.TaskState;
import org.opends.server.core.DirectoryServer;
import org.opends.server.loggers.JDKLogging;
import org.opends.server.tools.LDAPConnection;
import org.opends.server.tools.LDAPConnectionException;
import org.opends.server.types.LDAPException;
import org.opends.server.types.OpenDsException;
import org.opends.server.util.args.LDAPConnectionArgumentParser;
import org.opends.server.core.DirectoryServer;
import org.opends.server.admin.client.cli.TaskScheduleArgs;
import org.opends.server.backends.task.TaskState;
import org.opends.server.backends.task.FailedDependencyAction;
import org.forgerock.i18n.LocalizableMessage;
import static org.opends.messages.ToolMessages.*;
import static org.opends.messages.TaskMessages.*;
import java.io.PrintStream;
import java.util.Date;
import java.util.Set;
import java.util.HashSet;
import java.util.List;
import java.util.logging.Level;
import java.io.IOException;
import com.forgerock.opendj.cli.Argument;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.ArgumentGroup;
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.ClientException;
import com.forgerock.opendj.cli.CommonArguments;
import com.forgerock.opendj.cli.StringArgument;
/**
 * Base class for tools that are capable of operating either by running
opendj3-server-dev/src/server/org/opends/server/tools/upgrade/UpgradeCli.java
@@ -50,7 +50,6 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.core.DirectoryServer.DirectoryServerVersionHandler;
import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.util.ServerConstants;
import org.opends.server.util.StaticUtils;
import com.forgerock.opendj.cli.ArgumentException;
@@ -421,16 +420,15 @@
        final String defaultOption = getDefaultOption(cc.getDefaultOption());
        StringBuilder prompt =
            new StringBuilder(wrapText(cc.getPrompt(),
                ServerConstants.MAX_LINE_WIDTH, 2));
            new StringBuilder(wrapText(cc.getPrompt(), MAX_LINE_WIDTH, 2));
        // Default answers.
        final List<String> yesNoDefaultResponses =
            StaticUtils.arrayToList(new String[] {
            StaticUtils.arrayToList(
              INFO_PROMPT_YES_COMPLETE_ANSWER.get().toString(),
              INFO_PROMPT_YES_FIRST_LETTER_ANSWER.get().toString(),
              INFO_PROMPT_NO_COMPLETE_ANSWER.get().toString(),
              INFO_PROMPT_NO_FIRST_LETTER_ANSWER.get().toString() });
              INFO_PROMPT_NO_FIRST_LETTER_ANSWER.get().toString());
        // Generating prompt and possible answers list.
        prompt.append(" ").append("(");
@@ -446,8 +444,7 @@
        {
          choices.addAll(yesNoDefaultResponses);
          choices.addAll(StaticUtils.arrayToList(
              new String[] { INFO_TASKINFO_CMD_CANCEL_CHAR.get().toString() }
          ));
              INFO_TASKINFO_CMD_CANCEL_CHAR.get().toString()));
          prompt.append(" ")
                .append("(").append(INFO_PROMPT_YES_COMPLETE_ANSWER.get())
opendj3-server-dev/src/server/org/opends/server/util/ServerConstants.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2010-2014 ForgeRock AS
 *      Portions Copyright 2010-2015 ForgeRock AS
 */
package org.opends.server.util;
@@ -39,9 +39,7 @@
     mayInvoke=true)
public final class ServerConstants
{
  /**
   * The end-of-line character for this platform.
   */
  /** The end-of-line character for this platform. */
  public static final String EOL = System.getProperty("line.separator");
@@ -3005,25 +3003,6 @@
  /**
   * The column at which to wrap long lines of output in the command-line tools.
   */
  public static final int MAX_LINE_WIDTH;
  static {
    int columns = 80;
    try {
      String s = System.getenv("COLUMNS");
      if (s != null) {
        columns = Integer.parseInt(s);
      }
    } catch (Exception e) {
      // Do nothing.
    }
    MAX_LINE_WIDTH = columns - 1;
  }
  /**
   * The name that should be used for the file to which the latest complete
   * schema data should be concatenated.
   */
opendj3-server-dev/src/server/org/opends/server/util/StaticUtils.java
@@ -22,10 +22,13 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2011-2014 ForgeRock AS
 *      Portions Copyright 2011-2015 ForgeRock AS
 */
package org.opends.server.util;
import static org.opends.messages.UtilityMessages.*;
import static org.opends.server.util.ServerConstants.*;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.net.InetAddress;
@@ -59,9 +62,6 @@
import com.forgerock.opendj.cli.Argument;
import com.forgerock.opendj.cli.ArgumentException;
import static org.opends.messages.UtilityMessages.*;
import static org.opends.server.util.ServerConstants.*;
/**
 * This class defines a number of static utility methods that may be used
 * throughout the server.  Note that because of the frequency with which these
@@ -3343,7 +3343,7 @@
   *
   * @return  An array list containing the contents of the provided array.
   */
  public static ArrayList<String> arrayToList(String[] stringArray)
  public static ArrayList<String> arrayToList(String... stringArray)
  {
    if (stringArray == null)
    {
@@ -3355,7 +3355,6 @@
    {
      stringList.add(s);
    }
    return stringList;
  }