From 6f5e10b0dc596c8e7625de7ddf523b6d5bc220c7 Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Thu, 27 Feb 2014 08:17:06 +0000
Subject: [PATCH] Checkpoint for OPENDJ-1303 "opendj-cli" / Checkpoint OPENDJ-1343 Migrate dsconfig - Added CONFLICTING_ARGS to ReturnCode. - Added canWrite() to Utils + unit tests.   - Replaced calls to org.opends.quicksetup.util.Utils.canWrite by com.forgerock.opendj.cli.Utils.canWrite. - Removed the TablePrinter classes from org.opends.server.util.table as they are now in the opendj-cli. - Minor code cleanup on DSConfig package. (reorganize imports).

---
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java           |   30 +
 opendj3-server-dev/src/server/org/opends/server/util/table/CSVTablePrinter.java                       |    4 
 opendj3-server-dev/src/server/org/opends/server/tools/InstallDS.java                                  |   15 
 opendj-cli/src/test/java/com/forgerock/opendj/cli/UtilsTestCase.java                                  |   22 +
 opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java |    7 
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java             |    7 
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandlerFactory.java          |    1 
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java               |    9 
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java           |    7 
 opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java                                          |   17 +
 opendj3-server-dev/src/server/org/opends/server/tools/ManageTasks.java                                |    5 
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ManagementContextFactory.java          |    7 
 opendj3-server-dev/src/server/org/opends/server/tools/DBTest.java                                     |    4 
 opendj-cli/src/main/java/com/forgerock/opendj/cli/FileBasedArgument.java                              |    7 
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java             |    2 
 opendj3-server-dev/src/server/org/opends/server/tools/JavaPropertiesToolArgumentParser.java           |    3 
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java                 |   11 
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java          |   21 
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DSConfig.java                          |   81 ++--
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ArgumentExceptionFactory.java          |    5 
 opendj-cli/src/main/java/com/forgerock/opendj/cli/ReturnCode.java                                     |    4 
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java      |   36 +-
 opendj3-server-dev/src/server/org/opends/server/tools/ListBackends.java                               |    5 
 opendj3-server-dev/src/quicksetup/org/opends/quicksetup/installer/Installer.java                      |    1 
 /dev/null                                                                                             |  565 -----------------------------------
 opendj3-server-dev/src/server/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java         |   20 
 opendj3-server-dev/src/quicksetup/org/opends/quicksetup/util/Utils.java                               |   22 -
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValuePrinter.java              |   10 
 28 files changed, 192 insertions(+), 736 deletions(-)

diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/FileBasedArgument.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/FileBasedArgument.java
index 98390d6..3bfcaf7 100644
--- a/opendj-cli/src/main/java/com/forgerock/opendj/cli/FileBasedArgument.java
+++ b/opendj-cli/src/main/java/com/forgerock/opendj/cli/FileBasedArgument.java
@@ -28,6 +28,7 @@
 
 import static com.forgerock.opendj.cli.CliMessages.*;
 import static com.forgerock.opendj.util.StaticUtils.getExceptionMessage;
+import static org.forgerock.util.Utils.closeSilently;
 
 import java.io.BufferedReader;
 import java.io.File;
@@ -218,11 +219,7 @@
                     getExceptionMessage(e)));
             return false;
         } finally {
-            try {
-                reader.close();
-            } catch (final Exception e) {
-                // Ignored.
-            }
+            closeSilently(reader);
         }
 
         // If the line read is null, then that means the file was empty.
diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/ReturnCode.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/ReturnCode.java
index 294341c..61555de 100644
--- a/opendj-cli/src/main/java/com/forgerock/opendj/cli/ReturnCode.java
+++ b/opendj-cli/src/main/java/com/forgerock/opendj/cli/ReturnCode.java
@@ -113,6 +113,10 @@
      */
     SASL_BIND_IN_PROGRESS(14),
     /**
+     * Conflicting command line arguments.
+     */
+    CONFLICTING_ARGS(18),
+    /**
      * The LDAP result code for operations that fail because a defined constraint
      * has been violated.
      */
diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java
index df5da38..e2e3d4c 100644
--- a/opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java
+++ b/opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java
@@ -489,6 +489,23 @@
         return msg;
     }
 
+    /**
+     * Returns <CODE>true</CODE> if we can write on the provided path and <CODE>false</CODE> otherwise.
+     *
+     * @param path
+     *            the path.
+     * @return <CODE>true</CODE> if we can write on the provided path and <CODE>false</CODE> otherwise.
+     */
+    public static boolean canWrite(String path) {
+        final File file = new File(path);
+        if (file.exists()) {
+            return file.canWrite();
+        }
+        final File parentFile = file.getParentFile();
+        return (parentFile != null && parentFile.canWrite());
+    }
+
+
     // Prevent instantiation.
     private Utils() {
         // Do nothing.
diff --git a/opendj-cli/src/test/java/com/forgerock/opendj/cli/UtilsTestCase.java b/opendj-cli/src/test/java/com/forgerock/opendj/cli/UtilsTestCase.java
index 8df648b..3d7065e 100644
--- a/opendj-cli/src/test/java/com/forgerock/opendj/cli/UtilsTestCase.java
+++ b/opendj-cli/src/test/java/com/forgerock/opendj/cli/UtilsTestCase.java
@@ -25,7 +25,12 @@
  */
 package com.forgerock.opendj.cli;
 
+import java.io.File;
+import java.io.IOException;
+
 import org.testng.annotations.Test;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
 
 public class UtilsTestCase extends CliTestCase {
 
@@ -44,4 +49,21 @@
     public void testValidJavaVersion() throws ClientException {
         Utils.checkJavaVersion();
     }
+
+    @Test()
+    public void testCanWriteOnNewFile() throws ClientException, IOException {
+        final File f = File.createTempFile("tempFile", ".txt");
+        f.deleteOnExit();
+        assertTrue(f.exists());
+        assertTrue(Utils.canWrite(f.getPath()));
+    }
+
+    @Test()
+    public void testCannotWriteOnNewFile() throws ClientException, IOException {
+        final File f = File.createTempFile("tempFile", ".txt");
+        f.setReadOnly();
+        f.deleteOnExit();
+        assertTrue(f.exists());
+        assertFalse(Utils.canWrite(f.getPath()));
+    }
 }
diff --git a/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/installer/Installer.java b/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/installer/Installer.java
index a0c56f8..a23f900 100644
--- a/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/installer/Installer.java
+++ b/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/installer/Installer.java
@@ -65,6 +65,7 @@
 import static org.opends.messages.QuickSetupMessages.*;
 import static org.opends.quicksetup.Step.*;
 import static org.opends.quicksetup.util.Utils.*;
+import static com.forgerock.opendj.cli.Utils.canWrite;
 
 /**
  * This is an abstract class that is in charge of actually performing the
diff --git a/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/util/Utils.java b/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/util/Utils.java
index 5e4029e..2f29478 100644
--- a/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/util/Utils.java
+++ b/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -481,28 +481,6 @@
   }
 
   /**
-   * Returns <CODE>true</CODE> if we can write on the provided path and
-   * <CODE>false</CODE> otherwise.
-   * @param path the path.
-   * @return <CODE>true</CODE> if we can write on the provided path and
-   * <CODE>false</CODE> otherwise.
-   */
-  public static boolean canWrite(String path)
-  {
-    boolean canWrite;
-    File file = new File(path);
-    if (file.exists())
-    {
-      canWrite = file.canWrite();
-    } else
-    {
-      File parentFile = file.getParentFile();
-      canWrite = parentFile != null && parentFile.canWrite();
-    }
-    return canWrite;
-  }
-
-  /**
    * Creates the a directory in the provided path.
    * @param path the path.
    * @return <CODE>true</CODE> if the path was created or already existed (and
diff --git a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java
index cfff15c..87654fe 100644
--- a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java
+++ b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java
@@ -27,9 +27,11 @@
 package org.opends.server.admin.client.cli;
 
 import static com.forgerock.opendj.cli.CliMessages.INFO_DESCRIPTION_ADMIN_PORT;
-import static org.opends.server.tools.JavaPropertiesTool.ErrorReturnCode.*;
+import static com.forgerock.opendj.cli.Utils.LINE_SEPARATOR;
 import static org.opends.messages.AdminToolMessages.*;
 import static org.opends.messages.ToolMessages.*;
+import static com.forgerock.opendj.cli.ReturnCode.SUCCESS;
+import static com.forgerock.opendj.cli.ReturnCode.CONFLICTING_ARGS;
 
 import org.forgerock.i18n.LocalizableMessage;
 import org.forgerock.i18n.LocalizableMessageBuilder;
@@ -188,12 +190,6 @@
   private boolean configurationInitialized = false;
   private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
 
-  /**
-   * End Of Line.
-   */
-  public static String EOL = System.getProperty("line.separator");
-
-
   // Defines if the CLI always use the SSL connection type.
   private boolean alwaysSSL = false;
 
@@ -316,7 +312,7 @@
           try
           {
             err.write(wrapText(ex.getMessage(), MAX_LINE_WIDTH).getBytes());
-            err.write(EOL.getBytes());
+            err.write(LINE_SEPARATOR.getBytes());
           }
           catch (IOException e)
           {
@@ -348,7 +344,7 @@
           try
           {
             err.write(wrapText(ex.getMessage(), MAX_LINE_WIDTH).getBytes());
-            err.write(EOL.getBytes());
+            err.write(LINE_SEPARATOR.getBytes());
           }
           catch (IOException e)
           {
@@ -635,14 +631,14 @@
       {
         if (buf.length() > 0)
         {
-          buf.append(EOL);
+          buf.append(LINE_SEPARATOR);
         }
         buf.append(error);
       }
-      return CONFLICTING_ARGS.getReturnCode();
+      return CONFLICTING_ARGS.get();
     }
 
-    return SUCCESSFUL_NOP.getReturnCode();
+    return SUCCESS.get();
   }
   /**
    * Indication if provided global options are validate.
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/DBTest.java b/opendj3-server-dev/src/server/org/opends/server/tools/DBTest.java
index 67c987f..e681f97 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/DBTest.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/DBTest.java
@@ -56,9 +56,9 @@
 import com.forgerock.opendj.cli.StringArgument;
 import com.forgerock.opendj.cli.SubCommand;
 import com.forgerock.opendj.cli.SubCommandArgumentParser;
+import com.forgerock.opendj.cli.TableBuilder;
+import com.forgerock.opendj.cli.TextTablePrinter;
 
-import org.opends.server.util.table.TableBuilder;
-import org.opends.server.util.table.TextTablePrinter;
 
 import java.io.OutputStream;
 import java.io.PrintStream;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/InstallDS.java b/opendj3-server-dev/src/server/org/opends/server/tools/InstallDS.java
index f5a1a4f..9b2c091 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/InstallDS.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/InstallDS.java
@@ -27,12 +27,13 @@
  */
 package org.opends.server.tools;
 
-import static org.forgerock.util.Utils.*;
 import static org.opends.messages.AdminToolMessages.*;
 import static org.opends.messages.QuickSetupMessages.*;
 import static org.opends.messages.ToolMessages.*;
 import static org.opends.messages.UtilityMessages.*;
 import static com.forgerock.opendj.cli.Utils.CONFIRMATION_MAX_TRIES;
+import static com.forgerock.opendj.cli.Utils.canWrite;
+import static org.forgerock.util.Utils.joinAsString;
 
 import java.io.BufferedReader;
 import java.io.File;
@@ -793,7 +794,7 @@
       String rejectedFile = argParser.rejectedImportFileArg.getValue();
       if (rejectedFile != null)
       {
-        if (!Utils.canWrite(rejectedFile))
+        if (!canWrite(rejectedFile))
         {
           errorMessages.add(
               ERR_INSTALLDS_CANNOT_WRITE_REJECTED.get(rejectedFile));
@@ -802,7 +803,7 @@
       String skippedFile = argParser.skippedImportFileArg.getValue();
       if (skippedFile != null)
       {
-        if (!Utils.canWrite(skippedFile))
+        if (!canWrite(skippedFile))
         {
           errorMessages.add(ERR_INSTALLDS_CANNOT_WRITE_SKIPPED.get(
               skippedFile));
@@ -1323,7 +1324,7 @@
       String rejectedFile = argParser.rejectedImportFileArg.getValue();
       if (rejectedFile != null)
       {
-        while (!Utils.canWrite(rejectedFile))
+        while (!canWrite(rejectedFile))
         {
           println();
           println(ERR_INSTALLDS_CANNOT_WRITE_REJECTED.get(rejectedFile));
@@ -1343,7 +1344,7 @@
       String skippedFile = argParser.skippedImportFileArg.getValue();
       if (skippedFile != null)
       {
-        while (!Utils.canWrite(skippedFile))
+        while (!canWrite(skippedFile))
         {
           println();
           println(ERR_INSTALLDS_CANNOT_WRITE_SKIPPED.get(skippedFile));
@@ -1491,7 +1492,7 @@
         String rejectedFile = argParser.rejectedImportFileArg.getValue();
         if (rejectedFile != null)
         {
-          while (!Utils.canWrite(rejectedFile))
+          while (!canWrite(rejectedFile))
           {
             println();
             println(
@@ -1511,7 +1512,7 @@
         String skippedFile = argParser.skippedImportFileArg.getValue();
         if (skippedFile != null)
         {
-          while (!Utils.canWrite(skippedFile))
+          while (!canWrite(skippedFile))
           {
             println();
             println(ERR_INSTALLDS_CANNOT_WRITE_SKIPPED.get(skippedFile));
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/JavaPropertiesToolArgumentParser.java b/opendj3-server-dev/src/server/org/opends/server/tools/JavaPropertiesToolArgumentParser.java
index 4145db5..910b575 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/JavaPropertiesToolArgumentParser.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/JavaPropertiesToolArgumentParser.java
@@ -27,6 +27,7 @@
 package org.opends.server.tools;
 
 import static org.opends.messages.ToolMessages.*;
+import static com.forgerock.opendj.cli.Utils.canWrite;
 
 import java.io.File;
 import java.util.LinkedHashSet;
@@ -132,7 +133,7 @@
       if (value != null)
       {
         File f = new File(value);
-        if (f.isDirectory() || !Utils.canWrite(value))
+        if (f.isDirectory() || !canWrite(value))
         {
           errorMessages.add(
               ERR_JAVAPROPERTIES_WITH_DESTINATION_FILE.get(value));
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/ListBackends.java b/opendj3-server-dev/src/server/org/opends/server/tools/ListBackends.java
index cf9353e..587338a 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/ListBackends.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/ListBackends.java
@@ -56,9 +56,8 @@
 import com.forgerock.opendj.cli.BooleanArgument;
 import com.forgerock.opendj.cli.CommonArguments;
 import com.forgerock.opendj.cli.StringArgument;
-
-import org.opends.server.util.table.TableBuilder;
-import org.opends.server.util.table.TextTablePrinter;
+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.*;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/ManageTasks.java b/opendj3-server-dev/src/server/org/opends/server/tools/ManageTasks.java
index e7fe764..852756a 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/ManageTasks.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/ManageTasks.java
@@ -62,9 +62,8 @@
 import com.forgerock.opendj.cli.MenuBuilder;
 import com.forgerock.opendj.cli.MenuCallback;
 import com.forgerock.opendj.cli.MenuResult;
-
-import org.opends.server.util.table.TableBuilder;
-import org.opends.server.util.table.TextTablePrinter;
+import com.forgerock.opendj.cli.TableBuilder;
+import com.forgerock.opendj.cli.TextTablePrinter;
 
 import java.io.IOException;
 import java.io.InputStream;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ArgumentExceptionFactory.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ArgumentExceptionFactory.java
index 4d9dc73..df9e8bb 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ArgumentExceptionFactory.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ArgumentExceptionFactory.java
@@ -32,10 +32,10 @@
 
 import org.forgerock.i18n.LocalizableMessage;
 import org.opends.server.admin.AbstractManagedObjectDefinition;
-import org.opends.server.admin.PropertyException;
 import org.opends.server.admin.ManagedObjectDefinition;
 import org.opends.server.admin.PropertyDefinition;
 import org.opends.server.admin.PropertyDefinitionUsageBuilder;
+import org.opends.server.admin.PropertyException;
 import org.opends.server.admin.RelationDefinition;
 import org.opends.server.admin.client.IllegalManagedObjectNameException;
 import org.opends.server.admin.client.ManagedObjectDecodingException;
@@ -45,9 +45,8 @@
 import com.forgerock.opendj.cli.Argument;
 import com.forgerock.opendj.cli.ArgumentException;
 import com.forgerock.opendj.cli.ClientException;
-import com.forgerock.opendj.cli.ReturnCode;
-
 import com.forgerock.opendj.cli.ConsoleApplication;
+import com.forgerock.opendj.cli.ReturnCode;
 import com.forgerock.opendj.cli.TableBuilder;
 import com.forgerock.opendj.cli.TextTablePrinter;
 
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java
index 09319e1..5553376 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java
@@ -28,11 +28,18 @@
 
 
 
-import static org.opends.messages.DSConfigMessages.*;
-import static org.opends.messages.ToolMessages.*;
-import static org.opends.server.admin.PropertyException.*;
-import static org.opends.server.tools.dsconfig.ArgumentExceptionFactory.*;
 import static com.forgerock.opendj.cli.ArgumentConstants.LIST_TABLE_SEPARATOR;
+import static org.opends.messages.DSConfigMessages.*;
+import static org.opends.messages.ToolMessages.INFO_NAME_PLACEHOLDER;
+import static org.opends.messages.ToolMessages.INFO_PROPERTY_PLACEHOLDER;
+import static org.opends.messages.ToolMessages.INFO_TYPE_PLACEHOLDER;
+import static org.opends.messages.ToolMessages.INFO_VALUE_SET_PLACEHOLDER;
+import static org.opends.server.admin.PropertyException.
+propertyIsSingleValuedException;
+import static org.opends.server.tools.dsconfig.ArgumentExceptionFactory.
+displayMissingMandatoryPropertyException;
+import static org.opends.server.tools.dsconfig.ArgumentExceptionFactory.
+displayOperationRejectedException;
 
 import java.util.Collection;
 import java.util.Collections;
@@ -52,7 +59,6 @@
 import org.opends.server.admin.AggregationPropertyDefinition;
 import org.opends.server.admin.Configuration;
 import org.opends.server.admin.ConfigurationClient;
-import org.opends.server.admin.PropertyException;
 import org.opends.server.admin.DefinitionDecodingException;
 import org.opends.server.admin.InstantiableRelationDefinition;
 import org.opends.server.admin.ManagedObjectAlreadyExistsException;
@@ -63,6 +69,7 @@
 import org.opends.server.admin.OptionalRelationDefinition;
 import org.opends.server.admin.PropertyDefinition;
 import org.opends.server.admin.PropertyDefinitionUsageBuilder;
+import org.opends.server.admin.PropertyException;
 import org.opends.server.admin.PropertyOption;
 import org.opends.server.admin.PropertyProvider;
 import org.opends.server.admin.RelationDefinition;
@@ -81,19 +88,18 @@
 
 import com.forgerock.opendj.cli.Argument;
 import com.forgerock.opendj.cli.ArgumentException;
-import com.forgerock.opendj.cli.ReturnCode;
-import com.forgerock.opendj.cli.StringArgument;
-import com.forgerock.opendj.cli.SubCommand;
-import com.forgerock.opendj.cli.SubCommandArgumentParser;
 import com.forgerock.opendj.cli.ClientException;
-
 import com.forgerock.opendj.cli.ConsoleApplication;
 import com.forgerock.opendj.cli.HelpCallback;
 import com.forgerock.opendj.cli.MenuBuilder;
 import com.forgerock.opendj.cli.MenuResult;
+import com.forgerock.opendj.cli.ReturnCode;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.SubCommand;
+import com.forgerock.opendj.cli.SubCommandArgumentParser;
+import com.forgerock.opendj.cli.TableBuilder;
+import com.forgerock.opendj.cli.TextTablePrinter;
 import com.forgerock.opendj.cli.ValidationCallback;
-import org.opends.server.util.table.TableBuilder;
-import org.opends.server.util.table.TextTablePrinter;
 
 
 
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DSConfig.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DSConfig.java
index f0f6ee6..c0d8889 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DSConfig.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DSConfig.java
@@ -28,18 +28,26 @@
 
 
 
-import java.io.BufferedReader;
-
-import static org.opends.messages.DSConfigMessages.*;
-import static org.opends.messages.ToolMessages.*;
 import static com.forgerock.opendj.cli.ArgumentConstants.*;
-import static org.opends.server.tools.dsconfig.ArgumentExceptionFactory.*;
-import static org.opends.server.util.ServerConstants.PROPERTY_SCRIPT_NAME;
-import static org.opends.server.util.StaticUtils.*;
-import static com.forgerock.opendj.cli.Utils.formatDateTimeStringForEquivalentCommand;
+import static com.forgerock.opendj.cli.CliMessages.*;
 import static com.forgerock.opendj.cli.Utils.SHELL_COMMENT_SEPARATOR;
+import static com.forgerock.opendj.cli.Utils.canWrite;
+import static com.forgerock.opendj.cli.Utils.filterExitCode;
+import static com.forgerock.opendj.cli.Utils.formatDateTimeStringForEquivalentCommand;
 import static com.forgerock.opendj.cli.Utils.getCurrentOperationDateMessage;
+import static com.forgerock.opendj.util.StaticUtils.stackTraceToSingleLineString;
+import static org.forgerock.util.Utils.closeSilently;
+import static org.opends.messages.DSConfigMessages.*;
+import static org.opends.messages.ToolMessages.ERR_DSCFG_ERROR_BATCH_FILE_AND_INTERACTIVE_INCOMPATIBLE;
+import static org.opends.messages.ToolMessages.ERR_DSCFG_ERROR_QUIET_AND_INTERACTIVE_INCOMPATIBLE;
+import static org.opends.messages.ToolMessages.INFO_CONFIGDS_TOOL_DESCRIPTION;
+import static org.opends.messages.ToolMessages.INFO_DESCRIPTION_CONFIG_OPTIONS_ARGS;
+import static org.opends.server.tools.dsconfig.ArgumentExceptionFactory.displayManagedObjectDecodingException;
+import static org.opends.server.tools.dsconfig.ArgumentExceptionFactory.displayMissingMandatoryPropertyException;
+import static org.opends.server.tools.dsconfig.ArgumentExceptionFactory.displayOperationRejectedException;
+import static org.opends.server.util.ServerConstants.PROPERTY_SCRIPT_NAME;
 
+import java.io.BufferedReader;
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileReader;
@@ -61,7 +69,6 @@
 import java.util.TreeSet;
 
 import org.forgerock.i18n.LocalizableMessage;
-import org.opends.quicksetup.util.Utils;
 import org.opends.server.admin.AttributeTypePropertyDefinition;
 import org.opends.server.admin.ClassLoaderProvider;
 import org.opends.server.admin.ClassPropertyDefinition;
@@ -78,19 +85,19 @@
 import org.opends.server.util.EmbeddedUtils;
 
 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.SubCommand;
-import com.forgerock.opendj.cli.SubCommandArgumentParser;
 import com.forgerock.opendj.cli.ArgumentGroup;
+import com.forgerock.opendj.cli.BooleanArgument;
 import com.forgerock.opendj.cli.ClientException;
 import com.forgerock.opendj.cli.CommandBuilder;
+import com.forgerock.opendj.cli.CommonArguments;
 import com.forgerock.opendj.cli.ConsoleApplication;
 import com.forgerock.opendj.cli.Menu;
 import com.forgerock.opendj.cli.MenuBuilder;
 import com.forgerock.opendj.cli.MenuCallback;
 import com.forgerock.opendj.cli.MenuResult;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.SubCommand;
+import com.forgerock.opendj.cli.SubCommandArgumentParser;
 
 
 
@@ -777,16 +784,15 @@
     // equivalent non-interactive commands.
     if (equivalentCommandFileArgument.isPresent())
     {
-      String file = equivalentCommandFileArgument.getValue();
-      if (!Utils.canWrite(file))
+      final String file = equivalentCommandFileArgument.getValue();
+      if (!canWrite(file))
       {
         println(ERR_DSCFG_CANNOT_WRITE_EQUIVALENT_COMMAND_LINE_FILE.get(file));
         return 1;
       }
       else
       {
-        File f = new File(file);
-        if (f.isDirectory())
+        if (new File(file).isDirectory())
         {
           println(ERR_DSCFG_EQUIVALENT_COMMAND_LINE_FILE_DIRECTORY.get(file));
           return 1;
@@ -859,27 +865,21 @@
 
         return s1.compareToIgnoreCase(s2);
       }
-
     };
 
-    Set<RelationDefinition<?, ?>> relations;
-    Map<RelationDefinition<?, ?>, CreateSubCommandHandler<?, ?>> createHandlers;
-    Map<RelationDefinition<?, ?>, DeleteSubCommandHandler> deleteHandlers;
-    Map<RelationDefinition<?, ?>, ListSubCommandHandler> listHandlers;
-    Map<RelationDefinition<?, ?>, GetPropSubCommandHandler> getPropHandlers;
-    Map<RelationDefinition<?, ?>, SetPropSubCommandHandler> setPropHandlers;
+    final Set<RelationDefinition<?, ?>> relations =
+        new TreeSet<RelationDefinition<?, ?>>(c);
+    final Map<RelationDefinition<?, ?>, CreateSubCommandHandler<?, ?>> createHandlers =
+        new HashMap<RelationDefinition<?, ?>, CreateSubCommandHandler<?, ?>>();
+    final Map<RelationDefinition<?, ?>, DeleteSubCommandHandler> deleteHandlers =
+        new HashMap<RelationDefinition<?, ?>, DeleteSubCommandHandler>();
+    final Map<RelationDefinition<?, ?>, ListSubCommandHandler> listHandlers =
+        new HashMap<RelationDefinition<?, ?>, ListSubCommandHandler>();
+    final Map<RelationDefinition<?, ?>, GetPropSubCommandHandler> getPropHandlers =
+        new HashMap<RelationDefinition<?, ?>, GetPropSubCommandHandler>();
+    final Map<RelationDefinition<?, ?>, SetPropSubCommandHandler> setPropHandlers =
+        new HashMap<RelationDefinition<?, ?>, SetPropSubCommandHandler>();
 
-    relations = new TreeSet<RelationDefinition<?, ?>>(c);
-    createHandlers =
-      new HashMap<RelationDefinition<?, ?>, CreateSubCommandHandler<?, ?>>();
-    deleteHandlers =
-      new HashMap<RelationDefinition<?, ?>, DeleteSubCommandHandler>();
-    listHandlers =
-      new HashMap<RelationDefinition<?, ?>, ListSubCommandHandler>();
-    getPropHandlers =
-      new HashMap<RelationDefinition<?, ?>, GetPropSubCommandHandler>();
-    setPropHandlers =
-      new HashMap<RelationDefinition<?, ?>, SetPropSubCommandHandler>();
 
     for (CreateSubCommandHandler<?, ?> ch : handlerFactory
         .getCreateSubCommandHandlers()) {
@@ -1004,7 +1004,7 @@
 
       return 1;
     } catch (Exception e) {
-      println(LocalizableMessage.raw(stackTraceToString(e)));
+      println(LocalizableMessage.raw(stackTraceToSingleLineString(e, true)));
       return 1;
     }
   }
@@ -1120,7 +1120,7 @@
       }
       finally
       {
-        close(writer);
+        closeSilently(writer);
       }
     }
   }
@@ -1211,17 +1211,14 @@
         int exitCode =
                 main(allArgsArray, false, getOutputStream(), getErrorStream());
         if (exitCode != 0) {
-          bReader.close();
           System.exit(filterExitCode(exitCode));
         }
         errPrintln();
       }
-      bReader.close();
-
     } catch (IOException ex) {
       println(ERR_DSCFG_ERROR_READING_BATCH_FILE.get(ex));
     } finally {
-      close(bReader);
+      closeSilently(bReader);
     }
   }
 
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java
index 39a74d5..0e4a7f7 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java
@@ -52,14 +52,13 @@
 
 import com.forgerock.opendj.cli.ArgumentException;
 import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.ClientException;
+import com.forgerock.opendj.cli.ConsoleApplication;
+import com.forgerock.opendj.cli.MenuResult;
 import com.forgerock.opendj.cli.ReturnCode;
 import com.forgerock.opendj.cli.StringArgument;
 import com.forgerock.opendj.cli.SubCommand;
 import com.forgerock.opendj.cli.SubCommandArgumentParser;
-import com.forgerock.opendj.cli.ClientException;
-
-import com.forgerock.opendj.cli.ConsoleApplication;
-import com.forgerock.opendj.cli.MenuResult;
 import com.forgerock.opendj.cli.TableBuilder;
 import com.forgerock.opendj.cli.TextTablePrinter;
 
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java
index f91a3c2..5f3de9e 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java
@@ -31,7 +31,7 @@
 import static org.opends.messages.DSConfigMessages.*;
 import static org.opends.messages.UtilityMessages.*;
 import static org.opends.messages.ToolMessages.*;
-import static org.opends.server.util.ServerConstants.*;
+import static com.forgerock.opendj.cli.Utils.MAX_LINE_WIDTH;
 
 import java.io.PrintStream;
 import java.util.Collection;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java
index ae71217..dc0aa6b 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java
@@ -26,6 +26,21 @@
  */
 package org.opends.server.tools.dsconfig;
 
+
+
+import static com.forgerock.opendj.cli.ArgumentConstants.OPTION_LONG_HELP;
+import static com.forgerock.opendj.cli.ArgumentConstants.OPTION_SHORT_HELP;
+import static org.opends.messages.DSConfigMessages.*;
+
+import java.util.LinkedHashSet;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.InitialLdapContext;
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.SSLException;
+import javax.net.ssl.SSLHandshakeException;
+import javax.net.ssl.TrustManager;
+
 import org.forgerock.i18n.LocalizableMessage;
 import org.forgerock.i18n.LocalizableMessageBuilder;
 import org.opends.admin.ads.util.ApplicationTrustManager;
@@ -40,32 +55,17 @@
 import org.opends.server.admin.client.ldap.LDAPConnection;
 import org.opends.server.admin.client.ldap.LDAPManagementContext;
 import org.opends.server.config.ConfigException;
-
-import com.forgerock.opendj.cli.ClientException;
-
 import org.opends.server.tools.JavaPropertiesTool.ErrorReturnCode;
-import static com.forgerock.opendj.cli.ArgumentConstants.OPTION_LONG_HELP;
-import static com.forgerock.opendj.cli.ArgumentConstants.OPTION_SHORT_HELP;
-import com.forgerock.opendj.cli.CommandBuilder;
-import com.forgerock.opendj.cli.ConsoleApplication;
 import org.opends.server.util.cli.LDAPConnectionConsoleInteraction;
 
 import com.forgerock.opendj.cli.Argument;
 import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ClientException;
+import com.forgerock.opendj.cli.CommandBuilder;
+import com.forgerock.opendj.cli.ConsoleApplication;
 import com.forgerock.opendj.cli.ReturnCode;
 import com.forgerock.opendj.cli.SubCommandArgumentParser;
 
-import java.util.LinkedHashSet;
-
-import javax.naming.NamingException;
-import javax.naming.ldap.InitialLdapContext;
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.SSLException;
-import javax.net.ssl.SSLHandshakeException;
-import javax.net.ssl.TrustManager;
-
-import static org.opends.messages.DSConfigMessages.*;
-
 
 /**
  * An LDAP management context factory.
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java
index 966b8c1..656f65c 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java
@@ -56,14 +56,13 @@
 import org.opends.server.admin.client.ManagementContext;
 
 import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ClientException;
+import com.forgerock.opendj.cli.ConsoleApplication;
+import com.forgerock.opendj.cli.MenuResult;
 import com.forgerock.opendj.cli.ReturnCode;
 import com.forgerock.opendj.cli.StringArgument;
 import com.forgerock.opendj.cli.SubCommand;
 import com.forgerock.opendj.cli.SubCommandArgumentParser;
-import com.forgerock.opendj.cli.ClientException;
-
-import com.forgerock.opendj.cli.ConsoleApplication;
-import com.forgerock.opendj.cli.MenuResult;
 import com.forgerock.opendj.cli.TableBuilder;
 import com.forgerock.opendj.cli.TablePrinter;
 import com.forgerock.opendj.cli.TextTablePrinter;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ManagementContextFactory.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ManagementContextFactory.java
index 414dffe..0fe4585 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ManagementContextFactory.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ManagementContextFactory.java
@@ -26,14 +26,13 @@
  */
 package org.opends.server.tools.dsconfig;
 
-
-
 import org.opends.server.admin.client.ManagementContext;
-import com.forgerock.opendj.cli.ClientException;
+
 import com.forgerock.opendj.cli.ArgumentException;
-import com.forgerock.opendj.cli.SubCommandArgumentParser;
+import com.forgerock.opendj.cli.ClientException;
 import com.forgerock.opendj.cli.CommandBuilder;
 import com.forgerock.opendj.cli.ConsoleApplication;
+import com.forgerock.opendj.cli.SubCommandArgumentParser;
 
 
 
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java
index 803e73e..d403b51 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java
@@ -42,6 +42,7 @@
 
 import org.forgerock.i18n.LocalizableMessage;
 import org.forgerock.i18n.LocalizableMessageBuilder;
+import org.forgerock.util.Reject;
 import org.opends.server.admin.AbsoluteInheritedDefaultBehaviorProvider;
 import org.opends.server.admin.AbstractManagedObjectDefinition;
 import org.opends.server.admin.AggregationPropertyDefinition;
@@ -53,7 +54,6 @@
 import org.opends.server.admin.DefinedDefaultBehaviorProvider;
 import org.opends.server.admin.DefinitionDecodingException;
 import org.opends.server.admin.EnumPropertyDefinition;
-import org.opends.server.admin.PropertyException;
 import org.opends.server.admin.InstantiableRelationDefinition;
 import org.opends.server.admin.ManagedObjectDefinition;
 import org.opends.server.admin.ManagedObjectNotFoundException;
@@ -61,6 +61,7 @@
 import org.opends.server.admin.PropertyDefinition;
 import org.opends.server.admin.PropertyDefinitionUsageBuilder;
 import org.opends.server.admin.PropertyDefinitionVisitor;
+import org.opends.server.admin.PropertyException;
 import org.opends.server.admin.PropertyOption;
 import org.opends.server.admin.RelativeInheritedDefaultBehaviorProvider;
 import org.opends.server.admin.UndefinedDefaultBehaviorProvider;
@@ -69,19 +70,17 @@
 import org.opends.server.admin.client.ManagedObject;
 import org.opends.server.admin.client.ManagedObjectDecodingException;
 import org.opends.server.admin.client.ManagementContext;
-import org.forgerock.util.Reject;
 
 import com.forgerock.opendj.cli.ClientException;
-import com.forgerock.opendj.cli.ReturnCode;
-
+import com.forgerock.opendj.cli.ConsoleApplication;
 import com.forgerock.opendj.cli.HelpCallback;
 import com.forgerock.opendj.cli.Menu;
 import com.forgerock.opendj.cli.MenuBuilder;
 import com.forgerock.opendj.cli.MenuCallback;
 import com.forgerock.opendj.cli.MenuResult;
+import com.forgerock.opendj.cli.ReturnCode;
 import com.forgerock.opendj.cli.TableBuilder;
 import com.forgerock.opendj.cli.TextTablePrinter;
-import com.forgerock.opendj.cli.ConsoleApplication;
 
 
 
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValuePrinter.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValuePrinter.java
index 4321a2a..714f575 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValuePrinter.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValuePrinter.java
@@ -26,14 +26,12 @@
  */
 package org.opends.server.tools.dsconfig;
 
-
-
-import java.text.NumberFormat;
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-
 import static org.opends.messages.DSConfigMessages.*;
 
+import java.text.NumberFormat;
+
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.LocalizableMessageBuilder;
 import org.opends.server.admin.BooleanPropertyDefinition;
 import org.opends.server.admin.DurationPropertyDefinition;
 import org.opends.server.admin.DurationUnit;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java
index ac049bc..4413c3c 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java
@@ -28,8 +28,13 @@
 package org.opends.server.tools.dsconfig;
 
 import static org.opends.messages.DSConfigMessages.*;
-import static org.opends.messages.ToolMessages.*;
-import static org.opends.server.tools.dsconfig.ArgumentExceptionFactory.*;
+import static org.opends.messages.ToolMessages.INFO_NAME_PLACEHOLDER;
+import static org.opends.messages.ToolMessages.INFO_PROPERTY_PLACEHOLDER;
+import static org.opends.messages.ToolMessages.INFO_VALUE_SET_PLACEHOLDER;
+import static org.opends.server.tools.dsconfig.ArgumentExceptionFactory.
+displayMissingMandatoryPropertyException;
+import static org.opends.server.tools.dsconfig.ArgumentExceptionFactory.
+displayOperationRejectedException;
 
 import java.util.HashMap;
 import java.util.List;
@@ -41,7 +46,6 @@
 import org.forgerock.i18n.LocalizableMessage;
 import org.opends.server.admin.AggregationPropertyDefinition;
 import org.opends.server.admin.DefinitionDecodingException;
-import org.opends.server.admin.PropertyException;
 import org.opends.server.admin.InstantiableRelationDefinition;
 import org.opends.server.admin.ManagedObjectAlreadyExistsException;
 import org.opends.server.admin.ManagedObjectDefinition;
@@ -49,6 +53,7 @@
 import org.opends.server.admin.ManagedObjectPath;
 import org.opends.server.admin.OptionalRelationDefinition;
 import org.opends.server.admin.PropertyDefinition;
+import org.opends.server.admin.PropertyException;
 import org.opends.server.admin.PropertyOption;
 import org.opends.server.admin.RelationDefinition;
 import org.opends.server.admin.SetRelationDefinition;
@@ -67,16 +72,14 @@
 
 import com.forgerock.opendj.cli.Argument;
 import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ClientException;
+import com.forgerock.opendj.cli.CommandBuilder;
+import com.forgerock.opendj.cli.ConsoleApplication;
+import com.forgerock.opendj.cli.MenuResult;
 import com.forgerock.opendj.cli.ReturnCode;
 import com.forgerock.opendj.cli.StringArgument;
 import com.forgerock.opendj.cli.SubCommand;
 import com.forgerock.opendj.cli.SubCommandArgumentParser;
-import com.forgerock.opendj.cli.ClientException;
-
-import com.forgerock.opendj.cli.CommandBuilder;
-import com.forgerock.opendj.cli.ConsoleApplication;
-import com.forgerock.opendj.cli.MenuResult;
-
 import com.forgerock.opendj.util.Pair;
 
 /**
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java
index d656306..e01d6e6 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java
@@ -29,7 +29,9 @@
 
 
 import static org.opends.messages.DSConfigMessages.*;
-import static org.opends.messages.ToolMessages.*;
+import static org.opends.messages.ToolMessages.INFO_NAME_PLACEHOLDER;
+import static org.opends.messages.ToolMessages.INFO_PROPERTY_PLACEHOLDER;
+import static org.opends.messages.ToolMessages.INFO_UNIT_PLACEHOLDER;
 
 import java.io.PrintStream;
 import java.util.ArrayList;
@@ -77,16 +79,15 @@
 import com.forgerock.opendj.cli.Argument;
 import com.forgerock.opendj.cli.ArgumentException;
 import com.forgerock.opendj.cli.BooleanArgument;
-import com.forgerock.opendj.cli.ReturnCode;
-import com.forgerock.opendj.cli.StringArgument;
-import com.forgerock.opendj.cli.SubCommand;
 import com.forgerock.opendj.cli.ClientException;
-
 import com.forgerock.opendj.cli.CommandBuilder;
 import com.forgerock.opendj.cli.ConsoleApplication;
 import com.forgerock.opendj.cli.Menu;
 import com.forgerock.opendj.cli.MenuBuilder;
 import com.forgerock.opendj.cli.MenuResult;
+import com.forgerock.opendj.cli.ReturnCode;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.SubCommand;
 import com.forgerock.opendj.cli.TabSeparatedTablePrinter;
 import com.forgerock.opendj.cli.TablePrinter;
 
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandlerFactory.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandlerFactory.java
index 9015d4e..a94b245 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandlerFactory.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandlerFactory.java
@@ -42,6 +42,7 @@
 import org.opends.server.admin.RelationOption;
 import org.opends.server.admin.SetRelationDefinition;
 import org.opends.server.admin.SingletonRelationDefinition;
+
 import com.forgerock.opendj.cli.ArgumentException;
 import com.forgerock.opendj.cli.SubCommandArgumentParser;
 
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java
index c2d4123..5e67774 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java
@@ -30,6 +30,8 @@
 import static org.opends.messages.AdminToolMessages.*;
 import static org.opends.messages.ToolMessages.*;
 import static com.forgerock.opendj.cli.ArgumentConstants.*;
+import static com.forgerock.opendj.cli.Utils.canWrite;
+import static org.opends.quicksetup.util.Utils.isDn;
 
 import java.io.File;
 import java.io.OutputStream;
@@ -40,7 +42,6 @@
 import org.forgerock.i18n.LocalizableMessage;
 import org.forgerock.i18n.LocalizableMessageBuilder;
 import org.opends.quicksetup.Constants;
-import org.opends.quicksetup.util.Utils;
 import org.opends.server.admin.AdministrationConnector;
 import org.opends.server.admin.client.cli.SecureConnectionCliArgs;
 import org.opends.server.admin.client.cli.SecureConnectionCliParser;
@@ -414,7 +415,7 @@
     if (equivalentCommandFileArgument.isPresent())
     {
       String file = equivalentCommandFileArgument.getValue();
-      if (!Utils.canWrite(file))
+      if (!canWrite(file))
       {
         errors.add(
             ERR_REPLICATION_CANNOT_WRITE_EQUIVALENT_COMMAND_LINE_FILE.get(
@@ -463,7 +464,7 @@
       LinkedList<String> baseDNs = baseDNsArg.getValues();
       for (String dn : baseDNs)
       {
-        if (!Utils.isDn(dn))
+        if (!isDn(dn))
         {
           errors.add(ERR_REPLICATION_NOT_A_VALID_BASEDN.get(dn));
         }
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/table/CSVTablePrinter.java b/opendj3-server-dev/src/server/org/opends/server/util/table/CSVTablePrinter.java
index e8fe180..d4f0382 100644
--- a/opendj3-server-dev/src/server/org/opends/server/util/table/CSVTablePrinter.java
+++ b/opendj3-server-dev/src/server/org/opends/server/util/table/CSVTablePrinter.java
@@ -22,6 +22,7 @@
  *
  *
  *      Copyright 2008 Sun Microsystems, Inc.
+ *      Portions Copyright 2014 ForgeRock AS
  */
 package org.opends.server.util.table;
 
@@ -33,6 +34,9 @@
 import java.io.PrintWriter;
 import java.io.Writer;
 
+import com.forgerock.opendj.cli.TablePrinter;
+import com.forgerock.opendj.cli.TableSerializer;
+
 
 
 /**
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/table/TabSeparatedTablePrinter.java b/opendj3-server-dev/src/server/org/opends/server/util/table/TabSeparatedTablePrinter.java
deleted file mode 100644
index 92d4aac..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/table/TabSeparatedTablePrinter.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2008 Sun Microsystems, Inc.
- */
-package org.opends.server.util.table;
-
-
-
-import java.io.BufferedWriter;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.io.Writer;
-
-
-
-/**
- * An interface for creating a tab-separated formatted table.
- * <p>
- * This table printer will replace any tab, line-feeds, or carriage
- * return control characters encountered in a cell with a single
- * space.
- */
-public final class TabSeparatedTablePrinter extends TablePrinter {
-
-  /**
-   * Table serializer implementation.
-   */
-  private final class Serializer extends TableSerializer {
-
-    // The current column being output.
-    private int column = 0;
-
-    // Counts the number of separators that should be output the next
-    // time a non-empty cell is displayed. The tab separators are
-    // not displayed immediately so that we can avoid displaying
-    // unnecessary trailing separators.
-    private int requiredSeparators = 0;
-
-
-
-    // Private constructor.
-    private Serializer() {
-      // No implementation required.
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void addCell(String s) {
-      // Avoid printing tab separators for trailing empty cells.
-      if (s.length() == 0) {
-        requiredSeparators++;
-      } else {
-        for (int i = 0; i < requiredSeparators; i++) {
-          writer.print('\t');
-        }
-        requiredSeparators = 1;
-      }
-
-      // Replace all new-lines and tabs with a single space.
-      writer.print(s.replaceAll("[\\t\\n\\r]", " "));
-      column++;
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void addHeading(String s) {
-      if (displayHeadings) {
-        addCell(s);
-      }
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void endHeader() {
-      if (displayHeadings) {
-        writer.println();
-      }
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void endRow() {
-      writer.println();
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void endTable() {
-      writer.flush();
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void startHeader() {
-      column = 0;
-      requiredSeparators = 0;
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void startRow() {
-      column = 0;
-      requiredSeparators = 0;
-    }
-  }
-
-  // Indicates whether or not the headings should be output.
-  private boolean displayHeadings = false;
-
-  // The output destination.
-  private PrintWriter writer = null;
-
-
-
-  /**
-   * Creates a new tab separated table printer for the specified
-   * output stream. Headings will not be displayed by default.
-   *
-   * @param stream
-   *          The stream to output tables to.
-   */
-  public TabSeparatedTablePrinter(OutputStream stream) {
-    this(new BufferedWriter(new OutputStreamWriter(stream)));
-  }
-
-
-
-  /**
-   * Creates a new tab separated table printer for the specified
-   * writer. Headings will not be displayed by default.
-   *
-   * @param writer
-   *          The writer to output tables to.
-   */
-  public TabSeparatedTablePrinter(Writer writer) {
-    this.writer = new PrintWriter(writer);
-  }
-
-
-
-  /**
-   * Specify whether or not table headings should be displayed.
-   *
-   * @param displayHeadings
-   *          <code>true</code> if table headings should be
-   *          displayed.
-   */
-  public void setDisplayHeadings(boolean displayHeadings) {
-    this.displayHeadings = displayHeadings;
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  protected TableSerializer getSerializer() {
-    return new Serializer();
-  }
-
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/table/TableBuilder.java b/opendj3-server-dev/src/server/org/opends/server/util/table/TableBuilder.java
deleted file mode 100644
index 2ae6eaa..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/table/TableBuilder.java
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2008 Sun Microsystems, Inc.
- *      Portions Copyright 2014 ForgeRock AS
- */
-package org.opends.server.util.table;
-
-
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-import org.forgerock.i18n.LocalizableMessage;
-
-
-
-/**
- * A class which can be used to construct tables of information to be
- * displayed in a terminal. Once built the table can be output using a
- * {@link TableSerializer}.
- */
-public final class TableBuilder {
-
-  // The current column number in the current row where 0 represents
-  // the left-most column in the table.
-  private int column = 0;
-
-  // The current with of each column.
-  private List<Integer> columnWidths = new ArrayList<Integer>();
-
-  // The list of column headings.
-  private List<LocalizableMessage> header = new ArrayList<LocalizableMessage>();
-
-  // The current number of rows in the table.
-  private int height = 0;
-
-  // The list of table rows.
-  private List<List<String>> rows = new ArrayList<List<String>>();
-
-  // The linked list of sort keys comparators.
-  private List<Comparator<String>> sortComparators =
-    new ArrayList<Comparator<String>>();
-
-  // The linked list of sort keys.
-  private List<Integer> sortKeys = new ArrayList<Integer>();
-
-  // The current number of columns in the table.
-  private int width = 0;
-
-
-
-  /**
-   * Creates a new table printer.
-   */
-  public TableBuilder() {
-    // No implementation required.
-  }
-
-
-
-  /**
-   * Adds a table sort key. The table will be sorted according to the
-   * case-insensitive string ordering of the cells in the specified
-   * column.
-   *
-   * @param column
-   *          The column which will be used as a sort key.
-   */
-  public void addSortKey(int column) {
-    addSortKey(column, String.CASE_INSENSITIVE_ORDER);
-  }
-
-
-
-  /**
-   * Adds a table sort key. The table will be sorted according to the
-   * provided string comparator.
-   *
-   * @param column
-   *          The column which will be used as a sort key.
-   * @param comparator
-   *          The string comparator.
-   */
-  public void addSortKey(int column, Comparator<String> comparator) {
-    sortKeys.add(column);
-    sortComparators.add(comparator);
-  }
-
-
-
-  /**
-   * Appends a new blank cell to the current row.
-   */
-  public void appendCell() {
-    appendCell("");
-  }
-
-
-
-  /**
-   * Appends a new cell to the current row containing the provided
-   * boolean value.
-   *
-   * @param value
-   *          The boolean value.
-   */
-  public void appendCell(boolean value) {
-    appendCell(String.valueOf(value));
-  }
-
-
-
-  /**
-   * Appends a new cell to the current row containing the provided
-   * byte value.
-   *
-   * @param value
-   *          The byte value.
-   */
-  public void appendCell(byte value) {
-    appendCell(String.valueOf(value));
-  }
-
-
-
-  /**
-   * Appends a new cell to the current row containing the provided
-   * char value.
-   *
-   * @param value
-   *          The char value.
-   */
-  public void appendCell(char value) {
-    appendCell(String.valueOf(value));
-  }
-
-
-
-  /**
-   * Appends a new cell to the current row containing the provided
-   * double value.
-   *
-   * @param value
-   *          The double value.
-   */
-  public void appendCell(double value) {
-    appendCell(String.valueOf(value));
-  }
-
-
-
-  /**
-   * Appends a new cell to the current row containing the provided
-   * float value.
-   *
-   * @param value
-   *          The float value.
-   */
-  public void appendCell(float value) {
-    appendCell(String.valueOf(value));
-  }
-
-
-
-  /**
-   * Appends a new cell to the current row containing the provided
-   * integer value.
-   *
-   * @param value
-   *          The boolean value.
-   */
-  public void appendCell(int value) {
-    appendCell(String.valueOf(value));
-  }
-
-
-
-  /**
-   * Appends a new cell to the current row containing the provided
-   * long value.
-   *
-   * @param value
-   *          The long value.
-   */
-  public void appendCell(long value) {
-    appendCell(String.valueOf(value));
-  }
-
-
-
-  /**
-   * Appends a new cell to the current row containing the provided
-   * object value.
-   *
-   * @param value
-   *          The object value.
-   */
-  public void appendCell(Object value) {
-    // Make sure that the first row has been created.
-    if (height == 0) {
-      startRow();
-    }
-
-    // Create the cell.
-    String s = String.valueOf(value);
-    rows.get(height - 1).add(s);
-    column++;
-
-    // Update statistics.
-    if (column > width) {
-      width = column;
-      columnWidths.add(s.length());
-    } else if (columnWidths.get(column - 1) < s.length()) {
-      columnWidths.set(column - 1, s.length());
-    }
-  }
-
-
-
-  /**
-   * Appends a new blank column heading to the header row.
-   */
-  public void appendHeading() {
-    appendHeading(LocalizableMessage.EMPTY);
-  }
-
-
-
-  /**
-   * Appends a new column heading to the header row.
-   *
-   * @param value
-   *          The column heading value.
-   */
-  public void appendHeading(LocalizableMessage value) {
-    header.add(value);
-
-    // Update statistics.
-    if (header.size() > width) {
-      width = header.size();
-      columnWidths.add(value.length());
-    } else if (columnWidths.get(header.size() - 1) < value.length()) {
-      columnWidths.set(header.size() - 1, value.length());
-    }
-  }
-
-
-
-  /**
-   * Gets the width of the current row.
-   *
-   * @return Returns the width of the current row.
-   */
-  public int getRowWidth() {
-    return column;
-  }
-
-
-
-  /**
-   * Gets the number of rows in table.
-   *
-   * @return Returns the number of rows in table.
-   */
-  public int getTableHeight() {
-    return height;
-  }
-
-
-
-  /**
-   * Gets the number of columns in table.
-   *
-   * @return Returns the number of columns in table.
-   */
-  public int getTableWidth() {
-    return width;
-  }
-
-
-
-  /**
-   * Prints the table in its current state using the provided table
-   * printer.
-   *
-   * @param printer
-   *          The table printer.
-   */
-  public void print(TablePrinter printer) {
-    // Create a new printer instance.
-    TableSerializer serializer = printer.getSerializer();
-
-    // First sort the table.
-    List<List<String>> sortedRows = new ArrayList<List<String>>(rows);
-
-    Comparator<List<String>> comparator = new Comparator<List<String>>() {
-
-      public int compare(List<String> row1, List<String> row2) {
-        for (int i = 0; i < sortKeys.size(); i++) {
-          String cell1 = row1.get(sortKeys.get(i));
-          String cell2 = row2.get(sortKeys.get(i));
-
-          int rc = sortComparators.get(i).compare(cell1, cell2);
-          if (rc != 0) {
-            return rc;
-          }
-        }
-
-        // Both rows are equal.
-        return 0;
-      }
-
-    };
-
-    Collections.sort(sortedRows, comparator);
-
-    // Now output the table.
-    serializer.startTable(height, width);
-    for (int i = 0; i < width; i++) {
-      serializer.addColumn(columnWidths.get(i));
-    }
-
-    // Column headings.
-    serializer.startHeader();
-    for (LocalizableMessage s : header) {
-      serializer.addHeading(s.toString());
-    }
-    serializer.endHeader();
-
-    // Table contents.
-    serializer.startContent();
-    for (List<String> row : sortedRows) {
-      serializer.startRow();
-
-      // Print each cell in the row, padding missing trailing cells.
-      for (int i = 0; i < width; i++) {
-        if (i < row.size()) {
-          serializer.addCell(row.get(i));
-        } else {
-          serializer.addCell("");
-        }
-      }
-
-      serializer.endRow();
-    }
-    serializer.endContent();
-    serializer.endTable();
-  }
-
-
-
-  /**
-   * Appends a new row to the table.
-   */
-  public void startRow() {
-    rows.add(new ArrayList<String>());
-    height++;
-    column = 0;
-  }
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/table/TablePrinter.java b/opendj3-server-dev/src/server/org/opends/server/util/table/TablePrinter.java
deleted file mode 100644
index 70f2b14..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/table/TablePrinter.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2008 Sun Microsystems, Inc.
- */
-package org.opends.server.util.table;
-
-
-
-/**
- * An interface for incrementally configuring a table serializer. Once
- * configured, the table printer can be used to create a new
- * {@link TableSerializer} instance using the {@link #getSerializer()}
- * method.
- */
-public abstract class TablePrinter {
-
-  /**
-   * Creates a new abstract table printer.
-   */
-  protected TablePrinter() {
-    // No implementation required.
-  }
-
-
-
-  /**
-   * Creates a new table serializer based on the configuration of this
-   * table printer.
-   *
-   * @return Returns a new table serializer based on the configuration
-   *         of this table printer.
-   */
-  protected abstract TableSerializer getSerializer();
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/table/TableSerializer.java b/opendj3-server-dev/src/server/org/opends/server/util/table/TableSerializer.java
deleted file mode 100644
index 4cb02b6..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/table/TableSerializer.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2008 Sun Microsystems, Inc.
- */
-package org.opends.server.util.table;
-
-
-
-/**
- * An interface for serializing tables.
- * <p>
- * The default implementation for each method is to do nothing.
- * Implementations must override methods as required.
- */
-public abstract class TableSerializer {
-
-  /**
-   * Create a new table serializer.
-   */
-  protected TableSerializer() {
-    // No implementation required.
-  }
-
-
-
-  /**
-   * Prints a table cell.
-   *
-   * @param s
-   *          The cell contents.
-   */
-  public void addCell(String s) {
-    // Default implementation.
-  }
-
-
-
-  /**
-   * Defines a column in the table.
-   *
-   * @param width
-   *          The width of the column in characters.
-   */
-  public void addColumn(int width) {
-    // Default implementation.
-  }
-
-
-
-  /**
-   * Prints a column heading.
-   *
-   * @param s
-   *          The column heading.
-   */
-  public void addHeading(String s) {
-    // Default implementation.
-  }
-
-
-
-  /**
-   * Finish printing the table contents.
-   */
-  public void endContent() {
-    // Default implementation.
-  }
-
-
-
-  /**
-   * Finish printing the column headings.
-   */
-  public void endHeader() {
-    // Default implementation.
-  }
-
-
-
-  /**
-   * Finish printing the current row of the table.
-   */
-  public void endRow() {
-    // Default implementation.
-  }
-
-
-
-  /**
-   * Finish printing the table.
-   */
-  public void endTable() {
-    // Default implementation.
-  }
-
-
-
-  /**
-   * Prepare to start printing the table contents.
-   */
-  public void startContent() {
-    // Default implementation.
-  }
-
-
-
-  /**
-   * Prepare to start printing the column headings.
-   */
-  public void startHeader() {
-    // Default implementation.
-  }
-
-
-
-  /**
-   * Prepare to start printing a new row of the table.
-   */
-  public void startRow() {
-    // Default implementation.
-  }
-
-
-
-  /**
-   * Start a new table having the specified number of rows and
-   * columns.
-   *
-   * @param height
-   *          The number of rows in the table.
-   * @param width
-   *          The number of columns in the table.
-   */
-  public void startTable(int height, int width) {
-    // Default implementation.
-  }
-
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/table/TextTablePrinter.java b/opendj3-server-dev/src/server/org/opends/server/util/table/TextTablePrinter.java
deleted file mode 100644
index 86419bc..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/table/TextTablePrinter.java
+++ /dev/null
@@ -1,565 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2007-2008 Sun Microsystems, Inc.
- */
-package org.opends.server.util.table;
-
-
-
-import static org.opends.server.util.ServerConstants.*;
-
-import java.io.BufferedWriter;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-
-
-/**
- * An interface for creating a text based table. Tables have
- * configurable column widths, padding, and column separators.
- */
-public final class TextTablePrinter extends TablePrinter {
-
-  /**
-   * Table serializer implementation.
-   */
-  private final class Serializer extends TableSerializer {
-
-    // The current column being output.
-    private int column = 0;
-
-    // The real column widths taking into account size constraints but
-    // not including padding or separators.
-    private final List<Integer> columnWidths = new ArrayList<Integer>();
-
-    // The cells in the current row.
-    private final List<String> currentRow = new ArrayList<String>();
-
-    // Width of the table in columns.
-    private int totalColumns = 0;
-
-    // The padding to use for indenting the table.
-    private final String indentPadding;
-
-
-
-    // Private constructor.
-    private Serializer() {
-      // Compute the indentation padding.
-      StringBuilder builder = new StringBuilder();
-      for (int i = 0; i < indentWidth; i++) {
-        builder.append(' ');
-      }
-      this.indentPadding = builder.toString();
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void addCell(String s) {
-      currentRow.add(s);
-      column++;
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void addColumn(int width) {
-      columnWidths.add(width);
-      totalColumns++;
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void addHeading(String s) {
-      if (displayHeadings) {
-        addCell(s);
-      }
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void endHeader() {
-      if (displayHeadings) {
-        endRow();
-
-        // Print the header separator.
-        StringBuilder builder = new StringBuilder(indentPadding);
-        for (int i = 0; i < totalColumns; i++) {
-          int width = columnWidths.get(i);
-          if (totalColumns > 1) {
-            if (i == 0 || i == (totalColumns - 1)) {
-              // Only one lot of padding for first and last columns.
-              width += padding;
-            } else {
-              width += padding * 2;
-            }
-          }
-
-          for (int j = 0; j < width; j++) {
-            if (headingSeparatorStartColumn > 0) {
-              if (i < headingSeparatorStartColumn) {
-                builder.append(' ');
-              } else if (i == headingSeparatorStartColumn && j < padding) {
-                builder.append(' ');
-              } else {
-                builder.append(headingSeparator);
-              }
-            } else {
-              builder.append(headingSeparator);
-            }
-          }
-
-          if ((i >= headingSeparatorStartColumn) && i < (totalColumns - 1)) {
-            builder.append(columnSeparator);
-          }
-        }
-        writer.println(builder.toString());
-      }
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void endRow() {
-      boolean isRemainingText;
-      do {
-        StringBuilder builder = new StringBuilder(indentPadding);
-        isRemainingText = false;
-        for (int i = 0; i < currentRow.size(); i++) {
-          int width = columnWidths.get(i);
-          String contents = currentRow.get(i);
-
-          // Determine what parts of contents can be displayed on this
-          // line.
-          String head;
-          String tail = null;
-
-          if (contents == null) {
-            // This cell has been displayed fully.
-            head = "";
-          } else if (contents.length() > width) {
-            // We're going to have to split the cell on next word
-            // boundary.
-            int endIndex = contents.lastIndexOf(' ', width);
-            if (endIndex == -1) {
-              endIndex = width;
-              head = contents.substring(0, endIndex);
-              tail = contents.substring(endIndex);
-
-            } else {
-              head = contents.substring(0, endIndex);
-              tail = contents.substring(endIndex + 1);
-            }
-          } else {
-            // The contents fits ok.
-            head = contents;
-          }
-
-          // Add this cell's contents to the current line.
-          if (i > 0) {
-            // Add right padding for previous cell.
-            for (int j = 0; j < padding; j++) {
-              builder.append(' ');
-            }
-
-            // Add separator.
-            builder.append(columnSeparator);
-
-            // Add left padding for this cell.
-            for (int j = 0; j < padding; j++) {
-              builder.append(' ');
-            }
-          }
-
-          // Add cell contents.
-          builder.append(head);
-
-          // Now pad with extra space to make up the width.
-          // Only if it's not the last cell (see issue #3210)
-          if (i != currentRow.size() - 1)
-          {
-            for (int j = head.length(); j < width; j++)
-            {
-              builder.append(' ');
-            }
-          }
-
-          // Update the row contents.
-          currentRow.set(i, tail);
-          if (tail != null) {
-            isRemainingText = true;
-          }
-        }
-
-        // Output the line.
-        writer.println(builder.toString());
-
-      } while (isRemainingText);
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void endTable() {
-      writer.flush();
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void startHeader() {
-      determineColumnWidths();
-
-      column = 0;
-      currentRow.clear();
-    }
-
-
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void startRow() {
-      column = 0;
-      currentRow.clear();
-    }
-
-
-
-    // We need to calculate the effective width of each column.
-    private void determineColumnWidths() {
-      // First calculate the minimum width so that we know how much
-      // expandable columns can expand.
-      int minWidth = indentWidth;
-      int expandableColumnSize = 0;
-
-      for (int i = 0; i < totalColumns; i++) {
-        int actualSize = columnWidths.get(i);
-
-        if (fixedColumns.containsKey(i)) {
-          int requestedSize = fixedColumns.get(i);
-
-          if (requestedSize == 0) {
-            expandableColumnSize += actualSize;
-          } else {
-            columnWidths.set(i, requestedSize);
-            minWidth += requestedSize;
-          }
-        } else {
-          minWidth += actualSize;
-        }
-
-        // Must also include padding and separators.
-        if (i > 0) {
-          minWidth += padding * 2 + columnSeparator.length();
-        }
-      }
-
-      if (minWidth > totalWidth) {
-        // The table is too big: leave expandable columns at their
-        // requested width, as there's not much else that can be done.
-      } else {
-        int available = totalWidth - minWidth;
-
-        if (expandableColumnSize > available) {
-          // Only modify column sizes if necessary.
-          for (int i = 0; i < totalColumns; i++) {
-            int actualSize = columnWidths.get(i);
-
-            if (fixedColumns.containsKey(i)) {
-              int requestedSize = fixedColumns.get(i);
-              if (requestedSize == 0) {
-                // Calculate size based on requested actual size as a
-                // proportion of the total.
-                requestedSize =
-                  ((actualSize * available) / expandableColumnSize);
-                columnWidths.set(i, requestedSize);
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-
-  /**
-   * The default string which should be used to separate one column
-   * from the next (not including padding).
-   */
-  private static final String DEFAULT_COLUMN_SEPARATOR = "";
-
-  /**
-   * The default character which should be used to separate the table
-   * heading row from the rows beneath.
-   */
-  private static final char DEFAULT_HEADING_SEPARATOR = '-';
-
-  /**
-   * The default padding which will be used to separate a cell's
-   * contents from its adjacent column separators.
-   */
-  private static final int DEFAULT_PADDING = 1;
-
-  // The string which should be used to separate one column
-  // from the next (not including padding).
-  private String columnSeparator = DEFAULT_COLUMN_SEPARATOR;
-
-  // Indicates whether or not the headings should be output.
-  private boolean displayHeadings = true;
-
-  // Table indicating whether or not a column is fixed width.
-  private final Map<Integer, Integer> fixedColumns =
-    new HashMap<Integer, Integer>();
-
-  // The number of characters the table should be indented.
-  private int indentWidth = 0;
-
-  // The character which should be used to separate the table
-  // heading row from the rows beneath.
-  private char headingSeparator = DEFAULT_HEADING_SEPARATOR;
-
-  // The column where the heading separator should begin.
-  private int headingSeparatorStartColumn = 0;
-
-  // The padding which will be used to separate a cell's
-  // contents from its adjacent column separators.
-  private int padding = DEFAULT_PADDING;
-
-  // Total permitted width for the table which expandable columns
-  // can use up.
-  private int totalWidth = MAX_LINE_WIDTH;
-
-  // The output destination.
-  private PrintWriter writer = null;
-
-
-
-  /**
-   * Creates a new text table printer for the specified output stream.
-   * The text table printer will have the following initial settings:
-   * <ul>
-   * <li>headings will be displayed
-   * <li>no separators between columns
-   * <li>columns are padded by one character
-   * </ul>
-   *
-   * @param stream
-   *          The stream to output tables to.
-   */
-  public TextTablePrinter(OutputStream stream) {
-    this(new BufferedWriter(new OutputStreamWriter(stream)));
-  }
-
-
-
-  /**
-   * Creates a new text table printer for the specified writer. The
-   * text table printer will have the following initial settings:
-   * <ul>
-   * <li>headings will be displayed
-   * <li>no separators between columns
-   * <li>columns are padded by one character
-   * </ul>
-   *
-   * @param writer
-   *          The writer to output tables to.
-   */
-  public TextTablePrinter(Writer writer) {
-    this.writer = new PrintWriter(writer);
-  }
-
-
-
-  /**
-   * Sets the column separator which should be used to separate one
-   * column from the next (not including padding).
-   *
-   * @param columnSeparator
-   *          The column separator.
-   */
-  public void setColumnSeparator(String columnSeparator) {
-    this.columnSeparator = columnSeparator;
-  }
-
-
-
-  /**
-   * Set the maximum width for a column. If a cell is too big to fit
-   * in its column then it will be wrapped.
-   *
-   * @param column
-   *          The column to make fixed width (0 is the first column).
-   * @param width
-   *          The width of the column (this should not include column
-   *          separators or padding), or <code>0</code> to indicate
-   *          that this column should be expandable.
-   * @throws IllegalArgumentException
-   *           If column is less than 0.
-   */
-  public void setColumnWidth(int column, int width)
-      throws IllegalArgumentException {
-    if (column < 0) {
-      throw new IllegalArgumentException("Negative column " + column);
-    }
-
-    if (width < 0) {
-      throw new IllegalArgumentException("Negative width " + width);
-    }
-
-    fixedColumns.put(column, width);
-  }
-
-
-
-  /**
-   * Specify whether the column headings should be displayed or not.
-   *
-   * @param displayHeadings
-   *          <code>true</code> if column headings should be
-   *          displayed.
-   */
-  public void setDisplayHeadings(boolean displayHeadings) {
-    this.displayHeadings = displayHeadings;
-  }
-
-
-
-  /**
-   * Sets the heading separator which should be used to separate the
-   * table heading row from the rows beneath.
-   *
-   * @param headingSeparator
-   *          The heading separator.
-   */
-  public void setHeadingSeparator(char headingSeparator) {
-    this.headingSeparator = headingSeparator;
-  }
-
-
-
-  /**
-   * Sets the heading separator start column. The heading separator
-   * will only be display in the specified column and all subsequent
-   * columns. Usually this should be left at zero (the default) but
-   * sometimes it useful to indent the heading separate in order to
-   * provide additional emphasis (for example in menus).
-   *
-   * @param startColumn
-   *          The heading separator start column.
-   */
-  public void setHeadingSeparatorStartColumn(int startColumn) {
-    if (startColumn < 0) {
-      throw new IllegalArgumentException("Negative start column "
-          + startColumn);
-    }
-    this.headingSeparatorStartColumn = startColumn;
-  }
-
-
-
-  /**
-   * Sets the amount of characters that the table should be indented.
-   * By default the table is not indented.
-   *
-   * @param indentWidth
-   *          The number of characters the table should be indented.
-   * @throws IllegalArgumentException
-   *           If indentWidth is less than 0.
-   */
-  public void setIndentWidth(int indentWidth) throws IllegalArgumentException {
-    if (indentWidth < 0) {
-      throw new IllegalArgumentException("Negative indentation width "
-          + indentWidth);
-    }
-
-    this.indentWidth = indentWidth;
-  }
-
-
-
-  /**
-   * Sets the padding which will be used to separate a cell's contents
-   * from its adjacent column separators.
-   *
-   * @param padding
-   *          The padding.
-   */
-  public void setPadding(int padding) {
-    this.padding = padding;
-  }
-
-
-
-  /**
-   * Sets the total permitted width for the table which expandable
-   * columns can use up.
-   *
-   * @param totalWidth
-   *          The total width.
-   */
-  public void setTotalWidth(int totalWidth) {
-    this.totalWidth = totalWidth;
-  }
-
-
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  protected TableSerializer getSerializer() {
-    return new Serializer();
-  }
-}

--
Gitblit v1.10.0