From 0f698970acc441f4c6fa39b8fce19929a07eea17 Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Tue, 01 Mar 2016 09:44:57 +0000
Subject: [PATCH] OPENDJ-2701 Code cleanup

---
 opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPCompare.java                     |    2 
 opendj-server-legacy/src/main/java/org/opends/server/tools/BackUpDB.java                        |    2 
 opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskTool.java                  |    2 
 opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java                      |    2 
 opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPSearch.java                      |    2 
 opendj-server-legacy/src/main/java/org/opends/server/util/cli/package-info.java                 |   67 +++++++++++++++++++++++++++++++--
 opendj-server-legacy/src/main/java/org/opends/server/tools/ExportLDIF.java                      |    2 
 opendj-server-legacy/src/main/java/org/opends/server/tools/StopDS.java                          |    2 
 opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPModify.java                      |    2 
 opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPDelete.java                      |    2 
 opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java                    |    2 
 opendj-server-legacy/src/main/java/org/opends/server/tools/ManageAccount.java                   |    2 
 opendj-server-legacy/src/main/java/org/opends/server/util/cli/LDAPConnectionArgumentParser.java |    3 -
 opendj-server-legacy/src/main/java/org/opends/server/tools/ManageTasks.java                     |    2 
 opendj-server-legacy/src/main/java/org/opends/server/tools/RestoreDB.java                       |    2 
 15 files changed, 77 insertions(+), 19 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/BackUpDB.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/BackUpDB.java
index 79dd462..4af2848 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/BackUpDB.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/BackUpDB.java
@@ -62,7 +62,7 @@
 import org.opends.server.types.InitializationException;
 import org.opends.server.types.NullOutputStream;
 import org.opends.server.types.RawAttribute;
-import org.opends.server.util.args.LDAPConnectionArgumentParser;
+import org.opends.server.util.cli.LDAPConnectionArgumentParser;
 
 import com.forgerock.opendj.cli.Argument;
 import com.forgerock.opendj.cli.ArgumentException;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/ExportLDIF.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/ExportLDIF.java
index c3e9d2c..0d87e29 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/ExportLDIF.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/ExportLDIF.java
@@ -59,7 +59,7 @@
 import org.opends.server.types.NullOutputStream;
 import org.opends.server.types.RawAttribute;
 import org.opends.server.types.SearchFilter;
-import org.opends.server.util.args.LDAPConnectionArgumentParser;
+import org.opends.server.util.cli.LDAPConnectionArgumentParser;
 
 import com.forgerock.opendj.cli.Argument;
 import com.forgerock.opendj.cli.ArgumentException;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java
index 6fecc38..265cd43 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java
@@ -65,7 +65,7 @@
 import org.opends.server.types.NullOutputStream;
 import org.opends.server.types.RawAttribute;
 import org.opends.server.types.SearchFilter;
-import org.opends.server.util.args.LDAPConnectionArgumentParser;
+import org.opends.server.util.cli.LDAPConnectionArgumentParser;
 
 import com.forgerock.opendj.cli.Argument;
 import com.forgerock.opendj.cli.ArgumentException;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPCompare.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPCompare.java
index ae8f6e2..2663bc8 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPCompare.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPCompare.java
@@ -23,7 +23,7 @@
 
 import static org.opends.messages.ToolMessages.*;
 import static org.opends.server.protocols.ldap.LDAPResultCode.*;
-import static org.opends.server.util.args.LDAPConnectionArgumentParser.*;
+import static org.opends.server.util.cli.LDAPConnectionArgumentParser.*;
 
 import java.io.BufferedReader;
 import java.io.FileReader;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPDelete.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPDelete.java
index 146a333..d7c5d9f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPDelete.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPDelete.java
@@ -23,7 +23,7 @@
 
 import static org.opends.messages.ToolMessages.*;
 import static org.opends.server.protocols.ldap.LDAPResultCode.*;
-import static org.opends.server.util.args.LDAPConnectionArgumentParser.*;
+import static org.opends.server.util.cli.LDAPConnectionArgumentParser.*;
 
 import java.io.BufferedReader;
 import java.io.FileReader;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPModify.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPModify.java
index cd5eb1c..703f55b 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPModify.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPModify.java
@@ -25,7 +25,7 @@
 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 static org.opends.server.util.cli.LDAPConnectionArgumentParser.*;
 
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPSearch.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPSearch.java
index 7765ff3..a9349c0 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPSearch.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPSearch.java
@@ -25,7 +25,7 @@
 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 static org.opends.server.util.cli.LDAPConnectionArgumentParser.*;
 
 import java.io.BufferedReader;
 import java.io.FileReader;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/ManageAccount.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/ManageAccount.java
index d766526..693efa7 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/ManageAccount.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/ManageAccount.java
@@ -54,7 +54,7 @@
 import org.opends.server.protocols.ldap.LDAPResultCode;
 import org.opends.server.types.NullOutputStream;
 import org.opends.server.util.EmbeddedUtils;
-import org.opends.server.util.args.LDAPConnectionArgumentParser;
+import org.opends.server.util.cli.LDAPConnectionArgumentParser;
 
 import com.forgerock.opendj.cli.Argument;
 import com.forgerock.opendj.cli.ArgumentException;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/ManageTasks.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/ManageTasks.java
index 6874509..2c8b75c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/ManageTasks.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/ManageTasks.java
@@ -27,7 +27,7 @@
 import org.opends.server.types.LDAPException;
 import org.opends.server.util.BuildVersion;
 import org.opends.server.util.StaticUtils;
-import org.opends.server.util.args.LDAPConnectionArgumentParser;
+import org.opends.server.util.cli.LDAPConnectionArgumentParser;
 import org.opends.server.util.cli.LDAPConnectionConsoleInteraction;
 
 import com.forgerock.opendj.cli.ArgumentException;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java
index 6da9186..f66dc21 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java
@@ -56,7 +56,7 @@
 import org.opends.server.types.NullOutputStream;
 import org.opends.server.types.RawAttribute;
 import org.opends.server.util.StaticUtils;
-import org.opends.server.util.args.LDAPConnectionArgumentParser;
+import org.opends.server.util.cli.LDAPConnectionArgumentParser;
 
 import com.forgerock.opendj.cli.ArgumentException;
 import com.forgerock.opendj.cli.BooleanArgument;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/RestoreDB.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/RestoreDB.java
index 8af5124..ae0cda5 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/RestoreDB.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/RestoreDB.java
@@ -60,7 +60,7 @@
 import org.opends.server.types.NullOutputStream;
 import org.opends.server.types.RawAttribute;
 import org.opends.server.types.RestoreConfig;
-import org.opends.server.util.args.LDAPConnectionArgumentParser;
+import org.opends.server.util.cli.LDAPConnectionArgumentParser;
 
 import com.forgerock.opendj.cli.Argument;
 import com.forgerock.opendj.cli.ArgumentException;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/StopDS.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/StopDS.java
index 646a8b1..939e8b0 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/StopDS.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/StopDS.java
@@ -66,7 +66,7 @@
 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 org.opends.server.util.cli.LDAPConnectionArgumentParser;
 
 import com.forgerock.opendj.cli.Argument;
 import com.forgerock.opendj.cli.ArgumentConstants;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskTool.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskTool.java
index d76eb65..87599b8 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskTool.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskTool.java
@@ -44,7 +44,7 @@
 import org.opends.server.types.LDAPException;
 import org.opends.server.types.OpenDsException;
 import org.opends.server.util.BuildVersion;
-import org.opends.server.util.args.LDAPConnectionArgumentParser;
+import org.opends.server.util.cli.LDAPConnectionArgumentParser;
 
 import com.forgerock.opendj.cli.Argument;
 import com.forgerock.opendj.cli.ArgumentException;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/util/args/LDAPConnectionArgumentParser.java b/opendj-server-legacy/src/main/java/org/opends/server/util/cli/LDAPConnectionArgumentParser.java
similarity index 99%
rename from opendj-server-legacy/src/main/java/org/opends/server/util/args/LDAPConnectionArgumentParser.java
rename to opendj-server-legacy/src/main/java/org/opends/server/util/cli/LDAPConnectionArgumentParser.java
index 8c08199..924c70a 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/util/args/LDAPConnectionArgumentParser.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/util/cli/LDAPConnectionArgumentParser.java
@@ -14,7 +14,7 @@
  * Copyright 2008-2010 Sun Microsystems, Inc.
  * Portions Copyright 2011-2016 ForgeRock AS.
  */
-package org.opends.server.util.args;
+package org.opends.server.util.cli;
 
 import static org.opends.messages.ToolMessages.*;
 
@@ -36,7 +36,6 @@
 import org.opends.server.tools.SSLConnectionException;
 import org.opends.server.tools.SSLConnectionFactory;
 import org.opends.server.types.OpenDsException;
-import org.opends.server.util.cli.LDAPConnectionConsoleInteraction;
 
 import com.forgerock.opendj.cli.Argument;
 import com.forgerock.opendj.cli.ArgumentException;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/util/cli/package-info.java b/opendj-server-legacy/src/main/java/org/opends/server/util/cli/package-info.java
index e061471..44fbdb8 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/util/cli/package-info.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/util/cli/package-info.java
@@ -12,17 +12,76 @@
  * information: "Portions Copyright [year] [name of copyright owner]".
  *
  * Copyright 2006-2008 Sun Microsystems, Inc.
+ * Portions Copyright 2016 ForgeRock AS.
  */
 
 /**
- * Provides a high-level framework for implementing command-line
- * tools.
+ * Provides a high-level framework for implementing command-line tools.
  * <p>
- * The {@link ConsoleApplication} interface can be used as a basis for
+ * The {@code LDAPConnectionArgumentParser} provides an implementation of
+ * an utility that can manage the processing of command-line arguments for
+ * an application.
+ * This class centralizes a significant amount of processing so that it does
+ * not need to be repeated in all tools requiring this kind of functionality,
+ * as well as helping to ensure that the interaction with program arguments
+ * is in compliance with Sun's CLIP specification.
+ * <BR><BR>
+ * Features offered by this argument parsing implementation include:
+ * <BR>
+ * <UL>
+ *   <LI>
+ *     Arguments can be denoted using either a single dash followed by a single
+ *     character or two dashes followed by a more verbose multi-character
+ *     token.
+ *   </LI>
+ *   <LI>
+ *     The parsing performed on these arguments is very lenient so that it will
+ *     likely be compatible with the style preferred by the end user.
+ *   </LI>
+ *   <LI>
+ *     Arguments are declared with or without a value, and the parser can be
+ *     used to ensure that a value is provided for arguments that require one.
+ *   </LI>
+ *   <LI>
+ *     Each type of argument is associated with a particular data type, and a
+ *     minimal amount of validation can be handled by the argument parser itself
+ *     in this case (e.g., if an argument is associated with an integer type,
+ *     then non-numeric values will be rejected, and it is also possible to
+ *     define an acceptable range of values).
+ *   </LI>
+ *   <LI>
+ *     The argument parser contains a built-in mechanism for ensuring that there
+ *     are no conflicts between option names (i.e., it ensures that two
+ *     different arguments don't both try to use "-x" to invoke them).
+ *   </LI>
+ *   <LI>
+ *     The argument parser contains a mechanism for allowing "extra" arguments
+ *     at the end of the list which are not explicitly associated with
+ *     parameters.  For example, in the ldapsearch utility, at least one of
+ *     these "extra" arguments would be used for the filter, and if there are
+ *     any more of them then they would be used for the list of attributes to
+ *     return.
+ *   </LI>
+ *   <LI>
+ *     The argument parser itself can generate usage information in a consistent
+ *     manner so that it is not necessary for each command-line application to
+ *     explicitly provide this functionality.
+ *   </LI>
+ * </UL>
+ * <BR>
+ * A second version of the argument parser is also available which does not
+ * include support for trailing arguments but does include support for
+ * the use of subcommands.  In this case, you can define a number of subcommands
+ * each with their own set of arguments.  This can be used for cases in which
+ * one umbrella utility has a number of different capabilities (e.g., the "cvs"
+ * command has a number of sub-commands like "checkout" and "commit" and "diff",
+ * each of which has its own set of options).
+ * <p>
+ * The {@code ConsoleApplication} interface can be used as a basis for
  * console based applications. It includes common utility methods for
  * interacting with the console.
  * <p>
- * The {@link MenuBuilder} and associated classes and interfaces can
+ * The {@code MenuBuilder} and associated classes and interfaces can
  * be used to implement text based menu driven applications.
  */
 @org.opends.server.types.PublicAPI(

--
Gitblit v1.10.0