From 60cf8aa539572be17e02b83fa89c6326dfb0fd21 Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Wed, 05 Feb 2014 15:38:53 +0000
Subject: [PATCH] Checkpoint commit for OPENDJ-1303 - Replaced org.opends.server.util.args by com.forgerock.opendj.cli classes. - Deleted test cases as they are already ported in the opendj-cli module.
---
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java | 12
opendj3-server-dev/src/server/org/opends/server/util/cli/ConsoleApplication.java | 1
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/GetPropSubCommandHandler.java | 10
opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java | 4
opendj3-server-dev/src/server/org/opends/server/tools/InstallDS.java | 8
opendj3-server-dev/src/server/org/opends/server/tools/LDAPCompare.java | 12
opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java | 26 +
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandlerFactory.java | 5
opendj3-server-dev/src/server/org/opends/server/util/EMailMessage.java | 8
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ControlPanelArgumentParser.java | 12
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/PropertyValueEditor.java | 4
opendj3-server-dev/src/server/org/opends/server/tools/RebuildIndex.java | 8
opendj3-server-dev/src/server/org/opends/server/admin/client/cli/TaskScheduleArgs.java | 8
opendj3-server-dev/src/server/org/opends/server/tools/LDIFModify.java | 8
opendj3-server-dev/src/server/org/opends/server/tools/RestoreDB.java | 12
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DeleteSubCommandHandler.java | 12
opendj3-server-dev/src/server/org/opends/server/util/cli/MenuBuilder.java | 1
opendj3-server-dev/src/server/org/opends/server/util/cli/CommandBuilder.java | 7
opendj3-server-dev/src/server/org/opends/server/plugins/profiler/ProfileViewer.java | 8
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ManagementContextFactory.java | 5
opendj3-server-dev/src/server/org/opends/server/util/cli/Menu.java | 3
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/InternalManagementContextFactory.java | 5
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ControlPanelLauncher.java | 2
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java | 12
opendj3-server-dev/src/server/org/opends/server/util/args/LDAPConnectionArgumentParser.java | 16 +
opendj3-server-dev/src/server/org/opends/server/tools/WaitForFileDelete.java | 10
opendj3-server-dev/src/server/org/opends/server/util/StaticUtils.java | 4
opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleUserData.java | 7
opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCli.java | 2
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ArgumentExceptionFactory.java | 6
opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleInteraction.java | 2
opendj3-server-dev/src/quicksetup/org/opends/quicksetup/Launcher.java | 2
opendj3-server-dev/src/server/org/opends/server/tools/ConfigureWindowsService.java | 8
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java | 6
opendj3-server-dev/src/server/org/opends/server/tools/ListBackends.java | 8
opendj3-server-dev/src/server/org/opends/server/util/Base64.java | 10
opendj3-server-dev/src/server/org/opends/server/tools/CreateRCScript.java | 8
opendj3-server-dev/src/server/org/opends/server/tools/ImportLDIF.java | 13
opendj3-server-dev/src/server/org/opends/server/util/cli/MenuCallback.java | 6
opendj3-server-dev/src/server/org/opends/server/tools/LDAPDelete.java | 12
opendj3-server-dev/src/server/org/opends/server/tools/VerifyIndex.java | 8
opendj3-server-dev/src/server/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java | 12
opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliAds.java | 9
opendj3-server-dev/src/server/org/opends/server/tools/ExportLDIF.java | 12
opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallerArgumentParser.java | 8
opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java | 18 +
opendj3-server-dev/src/server/org/opends/server/tools/makeldif/MakeLDIF.java | 10
opendj3-server-dev/src/server/org/opends/server/tools/LDAPPasswordModify.java | 12
opendj3-server-dev/src/server/org/opends/server/tools/StopDS.java | 18
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/ListSubCommandHandler.java | 10
opendj3-server-dev/src/server/org/opends/server/tools/LDAPSearch.java | 14
opendj3-server-dev/src/server/org/opends/server/tools/BackUpDB.java | 6
opendj3-server-dev/src/server/org/opends/server/tools/EncodePassword.java | 6
opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliParser.java | 6
opendj3-server-dev/src/server/org/opends/server/tools/LDIFDiff.java | 8
opendj3-server-dev/src/quicksetup/org/opends/quicksetup/installer/SetupLauncher.java | 4
opendj3-server-dev/src/server/org/opends/server/tools/ManageTasks.java | 17
opendj3-server-dev/src/server/org/opends/server/tools/DBTest.java | 8
opendj3-server-dev/src/server/org/opends/server/tools/ManageAccount.java | 18
opendj3-server-dev/src/server/org/opends/server/tools/LDAPModify.java | 12
opendj3-server-dev/src/server/org/opends/server/tools/ConfigureDS.java | 12
opendj3-server-dev/src/server/org/opends/server/tools/JavaPropertiesToolArgumentParser.java | 8
opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ControlPanel.java | 2
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java | 12
opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliGlobalAdmin.java | 10
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java | 12
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/DSConfig.java | 14
opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCliArgumentParser.java | 12
opendj3-server-dev/src/server/org/opends/server/tools/InstallDSArgumentParser.java | 14
opendj3-server-dev/src/server/org/opends/server/tools/JavaPropertiesTool.java | 2
opendj3-server-dev/src/server/org/opends/server/tools/LDIFSearch.java | 12
opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServerGroup.java | 9
opendj3-server-dev/src/quicksetup/org/opends/quicksetup/CliUserInteraction.java | 2
opendj3-server-dev/src/server/org/opends/server/util/cli/ValidationCallback.java | 2
opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java | 6
/dev/null | 170 -----------
opendj3-server-dev/src/server/org/opends/server/tools/upgrade/UpgradeCli.java | 10
opendj3-server-dev/src/quicksetup/org/opends/quicksetup/QuickSetupCli.java | 2
opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliSubCommandGroup.java | 7
opendj3-server-dev/src/server/org/opends/server/admin/client/cli/SecureConnectionCliParser.java | 8
opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskTool.java | 21
opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServer.java | 12
opendj3-server-dev/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java | 3
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/admin/client/cli/CliTest.java | 2
opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallLauncher.java | 4
opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliMain.java | 2
86 files changed, 403 insertions(+), 496 deletions(-)
diff --git a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ControlPanel.java b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ControlPanel.java
index fe13e27..4188242 100644
--- a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ControlPanel.java
+++ b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ControlPanel.java
@@ -56,7 +56,7 @@
import org.opends.quicksetup.ui.UIFactory;
import org.opends.quicksetup.util.Utils;
import org.opends.server.util.DynamicConstants;
-import org.opends.server.util.args.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentException;
/**
* The class that is in charge of creating the main dialog of the ControlPanel
diff --git a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ControlPanelArgumentParser.java b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ControlPanelArgumentParser.java
index 5210225..874abba 100644
--- a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ControlPanelArgumentParser.java
+++ b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ControlPanelArgumentParser.java
@@ -38,12 +38,12 @@
import org.opends.quicksetup.UserData;
import org.opends.quicksetup.util.Utils;
import org.opends.server.admin.AdministrationConnector;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.FileBasedArgument;
-import org.opends.server.util.args.IntegerArgument;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.FileBasedArgument;
+import com.forgerock.opendj.cli.IntegerArgument;
+import com.forgerock.opendj.cli.StringArgument;
/**
* Class used to parse the arguments of the control panel command-line.
diff --git a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ControlPanelLauncher.java b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ControlPanelLauncher.java
index 8a5728a..de51ef5 100644
--- a/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ControlPanelLauncher.java
+++ b/opendj3-server-dev/src/guitools/org/opends/guitools/controlpanel/ControlPanelLauncher.java
@@ -48,7 +48,7 @@
import org.opends.server.util.BuildVersion;
import org.opends.server.util.DynamicConstants;
import org.opends.server.util.StaticUtils;
-import org.opends.server.util.args.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentException;
/**
* The class that is invoked directly by the control-panel command-line. This
diff --git a/opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java b/opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
index 94d11d0..a9e670b 100644
--- a/opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
+++ b/opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
@@ -53,8 +53,8 @@
import org.opends.server.tools.ToolConstants;
import org.opends.server.tools.dsconfig.LDAPManagementContextFactory;
import org.opends.server.util.StaticUtils;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.cli.CLIException;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.CLIException;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.LDAPConnectionConsoleInteraction;
import org.opends.server.util.cli.Menu;
diff --git a/opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallLauncher.java b/opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallLauncher.java
index ad77fe3..b7904ec 100644
--- a/opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallLauncher.java
+++ b/opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallLauncher.java
@@ -42,8 +42,8 @@
import org.opends.quicksetup.util.Utils;
import org.opends.server.util.DynamicConstants;
import org.opends.server.util.ServerConstants;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
/**
* This class is called by the uninstall command lines to launch the uninstall
diff --git a/opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallerArgumentParser.java b/opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallerArgumentParser.java
index c872576..ae770fe 100644
--- a/opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallerArgumentParser.java
+++ b/opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallerArgumentParser.java
@@ -42,10 +42,10 @@
import org.opends.server.admin.client.cli.SecureConnectionCliArgs;
import org.opends.server.admin.client.cli.SecureConnectionCliParser;
import org.opends.server.tools.ToolConstants;
-import org.opends.server.util.args.Argument;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.Argument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.StringArgument;
/**
* Class used to parse and populate the arguments of the Uninstaller.
diff --git a/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/CliUserInteraction.java b/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/CliUserInteraction.java
index ce7f084..ada834e 100644
--- a/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/CliUserInteraction.java
+++ b/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/CliUserInteraction.java
@@ -34,7 +34,7 @@
import org.opends.quicksetup.util.Utils;
import org.opends.server.util.StaticUtils;
-import org.opends.server.util.cli.CLIException;
+import com.forgerock.opendj.cli.CLIException;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.Menu;
import org.opends.server.util.cli.MenuBuilder;
diff --git a/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/Launcher.java b/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/Launcher.java
index bfc72fe..43ddd95 100644
--- a/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/Launcher.java
+++ b/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/Launcher.java
@@ -28,7 +28,7 @@
package org.opends.quicksetup;
import org.forgerock.i18n.LocalizableMessage;
-import org.opends.server.util.args.ArgumentParser;
+import com.forgerock.opendj.cli.ArgumentParser;
import static org.opends.messages.QuickSetupMessages.*;
import static org.opends.server.tools.ToolConstants.*;
diff --git a/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/QuickSetupCli.java b/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/QuickSetupCli.java
index aacc9ab..352c76f 100644
--- a/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/QuickSetupCli.java
+++ b/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/QuickSetupCli.java
@@ -37,7 +37,7 @@
import org.opends.quicksetup.event.ProgressUpdateListener;
import org.opends.quicksetup.event.ProgressUpdateEvent;
import org.opends.server.util.StaticUtils;
-import org.opends.server.util.cli.CLIException;
+import com.forgerock.opendj.cli.CLIException;
/**
* Class used by Launcher to start a CLI application.
diff --git a/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/installer/SetupLauncher.java b/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/installer/SetupLauncher.java
index 2d56f89..e71d1a0 100644
--- a/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/installer/SetupLauncher.java
+++ b/opendj3-server-dev/src/quicksetup/org/opends/quicksetup/installer/SetupLauncher.java
@@ -46,8 +46,8 @@
import org.opends.server.tools.InstallDSArgumentParser;
import org.opends.server.util.DynamicConstants;
import org.opends.server.util.ServerConstants;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
/**
* This class is called by the setup command line to launch the setup
diff --git a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliAds.java b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliAds.java
index cb706f2..84803b4 100644
--- a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliAds.java
+++ b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliAds.java
@@ -22,6 +22,7 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
+ * Portions Copyright 2014 ForgeRock AS
*/
package org.opends.server.admin.client.cli;
@@ -41,10 +42,10 @@
import org.opends.admin.ads.ADSContext;
import org.opends.admin.ads.ADSContextException;
import org.opends.admin.ads.ADSContextHelper;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.StringArgument;
-import org.opends.server.util.args.SubCommand;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.SubCommand;
import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*;
diff --git a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliGlobalAdmin.java b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliGlobalAdmin.java
index 04f9561..03e8b93 100644
--- a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliGlobalAdmin.java
+++ b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliGlobalAdmin.java
@@ -55,11 +55,11 @@
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.opends.server.tools.dsconfig.ArgumentExceptionFactory;
import org.opends.server.types.Privilege;
-import org.opends.server.util.args.Argument;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.StringArgument;
-import org.opends.server.util.args.SubCommand;
+import com.forgerock.opendj.cli.Argument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.SubCommand;
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/admin/client/cli/DsFrameworkCliMain.java b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliMain.java
index 5f25b17..716769d 100644
--- a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliMain.java
+++ b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliMain.java
@@ -37,7 +37,7 @@
import org.opends.server.types.NullOutputStream;
import org.opends.server.util.BuildVersion;
import org.opends.server.util.StaticUtils;
-import org.opends.server.util.args.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentException;
import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*;
import static org.opends.messages.AdminMessages.*;
diff --git a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliParser.java b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliParser.java
index 7bc489d..ae6b489 100644
--- a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliParser.java
+++ b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliParser.java
@@ -47,9 +47,9 @@
import org.opends.admin.ads.ADSContextException;
import org.opends.admin.ads.util.ConnectionUtils;
import org.forgerock.i18n.LocalizableMessage;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.SubCommand;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.SubCommand;
/**
* This class will parse CLI arguments for the dsframework command lines.
diff --git a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServer.java b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServer.java
index 19b96f2..f372aaa 100644
--- a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServer.java
+++ b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServer.java
@@ -54,12 +54,12 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.opends.server.tools.dsconfig.ArgumentExceptionFactory;
-import org.opends.server.util.args.Argument;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.IntegerArgument;
-import org.opends.server.util.args.StringArgument;
-import org.opends.server.util.args.SubCommand;
+import com.forgerock.opendj.cli.Argument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.IntegerArgument;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.SubCommand;
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/admin/client/cli/DsFrameworkCliServerGroup.java b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServerGroup.java
index b4064cb..acdd601 100644
--- a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServerGroup.java
+++ b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliServerGroup.java
@@ -22,6 +22,7 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
+ * Portions Copyright 2014 ForgeRock AS
*/
package org.opends.server.admin.client.cli;
@@ -48,10 +49,10 @@
import org.opends.admin.ads.ADSContext.ServerGroupProperty;
import org.opends.admin.ads.ADSContext.ServerProperty;
import org.opends.admin.ads.ADSContextException.ErrorType;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.StringArgument;
-import org.opends.server.util.args.SubCommand;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.SubCommand;
import static org.opends.server.admin.client.cli.DsFrameworkCliReturnCode.*;
/**
diff --git a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliSubCommandGroup.java b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliSubCommandGroup.java
index e4e9387..3132daa 100644
--- a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliSubCommandGroup.java
+++ b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/DsFrameworkCliSubCommandGroup.java
@@ -22,6 +22,7 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
+ * Portions Copyright 2014 ForgeRock AS
*/
package org.opends.server.admin.client.cli;
@@ -29,9 +30,9 @@
import java.util.Set;
import org.opends.admin.ads.ADSContextException;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.SubCommand;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.SubCommand;
/**
* This Interface defines method that a group of subcommand shoud implement.
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 c2b56b4..c600958 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
@@ -67,12 +67,12 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.util.PasswordReader;
import org.opends.server.util.SelectableCertificateKeyManager;
-import org.opends.server.util.args.Argument;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.FileBasedArgument;
-import org.opends.server.util.args.IntegerArgument;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.Argument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.FileBasedArgument;
+import com.forgerock.opendj.cli.IntegerArgument;
+import com.forgerock.opendj.cli.StringArgument;
/**
* This is a commodity class that can be used to check the arguments required
diff --git a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/SecureConnectionCliParser.java b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/SecureConnectionCliParser.java
index 849fd2e..6af3818 100644
--- a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/SecureConnectionCliParser.java
+++ b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/SecureConnectionCliParser.java
@@ -46,13 +46,7 @@
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.util.PasswordReader;
-import org.opends.server.util.args.Argument;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentGroup;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.FileBasedArgument;
-import org.opends.server.util.args.StringArgument;
-import org.opends.server.util.args.SubCommandArgumentParser;
+import com.forgerock.opendj.cli.*;
/**
* This is a commodity class that can be used to check the arguments required
diff --git a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/TaskScheduleArgs.java b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/TaskScheduleArgs.java
index 938433ab..f364845 100644
--- a/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/TaskScheduleArgs.java
+++ b/opendj3-server-dev/src/server/org/opends/server/admin/client/cli/TaskScheduleArgs.java
@@ -42,10 +42,10 @@
import org.opends.server.backends.task.RecurringTask;
import org.opends.server.types.DirectoryException;
import org.opends.server.util.StaticUtils;
-import org.opends.server.util.args.Argument;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.StringArgument;
-import org.opends.server.util.cli.CLIException;
+import com.forgerock.opendj.cli.Argument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.CLIException;
/**
* A class that contains all the arguments related to the task scheduling.
diff --git a/opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java b/opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java
index 351b394..d4f4391 100644
--- a/opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java
+++ b/opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java
@@ -88,7 +88,11 @@
import org.opends.server.util.*;
import org.forgerock.util.Reject;
import org.forgerock.util.Utils;
-import org.opends.server.util.args.*;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.IntegerArgument;
+import com.forgerock.opendj.cli.StringArgument;
import org.opends.server.workflowelement.WorkflowElement;
import org.opends.server.workflowelement.WorkflowElementConfigManager;
import org.opends.server.workflowelement.localbackend.*;
diff --git a/opendj3-server-dev/src/server/org/opends/server/plugins/profiler/ProfileViewer.java b/opendj3-server-dev/src/server/org/opends/server/plugins/profiler/ProfileViewer.java
index be2e1e9..c69bfd9 100644
--- a/opendj3-server-dev/src/server/org/opends/server/plugins/profiler/ProfileViewer.java
+++ b/opendj3-server-dev/src/server/org/opends/server/plugins/profiler/ProfileViewer.java
@@ -50,10 +50,10 @@
import javax.swing.event.TreeSelectionListener;
import org.opends.server.protocols.asn1.*;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.StringArgument;
import static org.opends.messages.PluginMessages.*;
import static org.opends.messages.ToolMessages.*;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/BackUpDB.java b/opendj3-server-dev/src/server/org/opends/server/tools/BackUpDB.java
index 99e50d0..6a02a0c 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/BackUpDB.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/BackUpDB.java
@@ -67,11 +67,9 @@
import org.opends.server.types.NullOutputStream;
import org.opends.server.types.RawAttribute;
import org.opends.server.util.BuildVersion;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.BooleanArgument;
import org.opends.server.util.args.LDAPConnectionArgumentParser;
-import org.opends.server.util.args.StringArgument;
-import org.opends.server.util.cli.CLIException;
+
+import com.forgerock.opendj.cli.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/ConfigureDS.java b/opendj3-server-dev/src/server/org/opends/server/tools/ConfigureDS.java
index 03f4a78..10fd203 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/ConfigureDS.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/ConfigureDS.java
@@ -64,12 +64,12 @@
import org.opends.server.types.NullOutputStream;
import org.opends.server.util.LDIFReader;
import org.opends.server.util.SetupUtils;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.FileBasedArgument;
-import org.opends.server.util.args.IntegerArgument;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.FileBasedArgument;
+import com.forgerock.opendj.cli.IntegerArgument;
+import com.forgerock.opendj.cli.StringArgument;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.messages.ConfigMessages.*;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/ConfigureWindowsService.java b/opendj3-server-dev/src/server/org/opends/server/tools/ConfigureWindowsService.java
index 7eec715..24439fa 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/ConfigureWindowsService.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/ConfigureWindowsService.java
@@ -41,10 +41,10 @@
import org.opends.server.types.NullOutputStream;
import org.opends.server.util.DynamicConstants;
import org.opends.server.util.SetupUtils;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.StringArgument;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.util.ServerConstants.MAX_LINE_WIDTH;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/CreateRCScript.java b/opendj3-server-dev/src/server/org/opends/server/tools/CreateRCScript.java
index e6a7d4b..99dfc3f 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/CreateRCScript.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/CreateRCScript.java
@@ -40,10 +40,10 @@
import org.opends.server.types.OperatingSystem;
import org.opends.server.util.EmbeddedUtils;
import org.opends.server.util.SetupUtils;
-import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.ArgumentParser;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.StringArgument;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
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 e6b683f..8ac7e71 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
@@ -47,7 +47,13 @@
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.opends.server.util.BuildVersion;
import org.opends.server.util.StaticUtils;
-import org.opends.server.util.args.*;
+import com.forgerock.opendj.cli.Argument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.IntegerArgument;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.SubCommand;
+import com.forgerock.opendj.cli.SubCommandArgumentParser;
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/EncodePassword.java b/opendj3-server-dev/src/server/org/opends/server/tools/EncodePassword.java
index b4a3d66..3e1f0b7 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/EncodePassword.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/EncodePassword.java
@@ -58,7 +58,11 @@
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.util.BuildVersion;
-import org.opends.server.util.args.*;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.FileBasedArgument;
+import com.forgerock.opendj.cli.StringArgument;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.messages.ToolMessages.*;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/ExportLDIF.java b/opendj3-server-dev/src/server/org/opends/server/tools/ExportLDIF.java
index 01da5bf..7f5dbc0 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/ExportLDIF.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/ExportLDIF.java
@@ -55,12 +55,14 @@
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.util.BuildVersion;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.IntegerArgument;
-import org.opends.server.util.args.StringArgument;
import org.opends.server.util.args.LDAPConnectionArgumentParser;
-import org.opends.server.util.cli.CLIException;
+
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.IntegerArgument;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.CLIException;
+
import org.forgerock.i18n.LocalizableMessage;
import static org.opends.messages.ToolMessages.*;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/ImportLDIF.java b/opendj3-server-dev/src/server/org/opends/server/tools/ImportLDIF.java
index 9f49d6b..25a5e58 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/ImportLDIF.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/ImportLDIF.java
@@ -29,7 +29,9 @@
import static org.opends.messages.ToolMessages.*;
+
import org.forgerock.i18n.slf4j.LocalizedLogger;
+
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.tools.ToolConstants.*;
import static org.opends.server.util.ServerConstants.*;
@@ -74,12 +76,13 @@
import org.opends.server.types.ResultCode;
import org.opends.server.types.SearchFilter;
import org.opends.server.util.BuildVersion;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.IntegerArgument;
import org.opends.server.util.args.LDAPConnectionArgumentParser;
-import org.opends.server.util.args.StringArgument;
-import org.opends.server.util.cli.CLIException;
+
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.IntegerArgument;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.CLIException;
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 aa26bd0..0af6f73 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
@@ -70,10 +70,10 @@
import org.opends.server.util.CertificateManager;
import org.opends.server.util.SetupUtils;
import org.opends.server.util.StaticUtils;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.IntegerArgument;
-import org.opends.server.util.args.StringArgument;
-import org.opends.server.util.cli.CLIException;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.IntegerArgument;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.CLIException;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.Menu;
import org.opends.server.util.cli.MenuBuilder;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/InstallDSArgumentParser.java b/opendj3-server-dev/src/server/org/opends/server/tools/InstallDSArgumentParser.java
index 9158b98..f1c2ebd 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/InstallDSArgumentParser.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/InstallDSArgumentParser.java
@@ -44,13 +44,13 @@
import org.opends.quicksetup.util.Utils;
import org.opends.server.admin.AdministrationConnector;
import org.opends.server.util.SetupUtils;
-import org.opends.server.util.args.Argument;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.FileBasedArgument;
-import org.opends.server.util.args.IntegerArgument;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.Argument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.FileBasedArgument;
+import com.forgerock.opendj.cli.IntegerArgument;
+import com.forgerock.opendj.cli.StringArgument;
/**
* Class used to parse the arguments of the setup command-line and to check
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/JavaPropertiesTool.java b/opendj3-server-dev/src/server/org/opends/server/tools/JavaPropertiesTool.java
index 6c3e469..1ca2afa 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/JavaPropertiesTool.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/JavaPropertiesTool.java
@@ -48,7 +48,7 @@
import org.opends.quicksetup.Constants;
import org.opends.quicksetup.util.Utils;
import org.opends.server.types.NullOutputStream;
-import org.opends.server.util.args.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentException;
import org.opends.server.util.cli.ConsoleApplication;
/**
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 ed45e50..13c1f13 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
@@ -36,10 +36,10 @@
import org.opends.quicksetup.Constants;
import org.opends.quicksetup.Installation;
import org.opends.quicksetup.util.Utils;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.StringArgument;
/**
* Class used to parse the arguments of the java properties tool command-line.
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/LDAPCompare.java b/opendj3-server-dev/src/server/org/opends/server/tools/LDAPCompare.java
index 984baa9..a62dd6c 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/LDAPCompare.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/LDAPCompare.java
@@ -52,12 +52,12 @@
import org.opends.server.util.Base64;
import org.opends.server.util.EmbeddedUtils;
import org.opends.server.util.PasswordReader;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.FileBasedArgument;
-import org.opends.server.util.args.IntegerArgument;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.FileBasedArgument;
+import com.forgerock.opendj.cli.IntegerArgument;
+import com.forgerock.opendj.cli.StringArgument;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/LDAPDelete.java b/opendj3-server-dev/src/server/org/opends/server/tools/LDAPDelete.java
index f1bb54f..21a4b1e 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/LDAPDelete.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/LDAPDelete.java
@@ -48,12 +48,12 @@
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.util.EmbeddedUtils;
import org.opends.server.util.PasswordReader;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.FileBasedArgument;
-import org.opends.server.util.args.IntegerArgument;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.FileBasedArgument;
+import com.forgerock.opendj.cli.IntegerArgument;
+import com.forgerock.opendj.cli.StringArgument;
import org.opends.server.controls.SubtreeDeleteControl;
import org.forgerock.i18n.slf4j.LocalizedLogger;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/LDAPModify.java b/opendj3-server-dev/src/server/org/opends/server/tools/LDAPModify.java
index 6c022e8..7ce740f 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/LDAPModify.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/LDAPModify.java
@@ -68,12 +68,12 @@
import org.opends.server.util.ModifyChangeRecordEntry;
import org.opends.server.util.ModifyDNChangeRecordEntry;
import org.opends.server.util.PasswordReader;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.FileBasedArgument;
-import org.opends.server.util.args.IntegerArgument;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.FileBasedArgument;
+import com.forgerock.opendj.cli.IntegerArgument;
+import com.forgerock.opendj.cli.StringArgument;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/LDAPPasswordModify.java b/opendj3-server-dev/src/server/org/opends/server/tools/LDAPPasswordModify.java
index 50162f4..1ef44b4 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/LDAPPasswordModify.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/LDAPPasswordModify.java
@@ -49,12 +49,12 @@
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.opends.server.util.EmbeddedUtils;
import org.opends.server.util.PasswordReader;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.FileBasedArgument;
-import org.opends.server.util.args.IntegerArgument;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.FileBasedArgument;
+import com.forgerock.opendj.cli.IntegerArgument;
+import com.forgerock.opendj.cli.StringArgument;
import static org.opends.server.extensions.ExtensionsConstants.*;
import static org.opends.messages.ToolMessages.*;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/LDAPSearch.java b/opendj3-server-dev/src/server/org/opends/server/tools/LDAPSearch.java
index 990ff0e..e067fcb 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/LDAPSearch.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/LDAPSearch.java
@@ -42,13 +42,13 @@
import org.opends.server.util.Base64;
import org.opends.server.util.EmbeddedUtils;
import org.opends.server.util.PasswordReader;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.FileBasedArgument;
-import org.opends.server.util.args.IntegerArgument;
-import org.opends.server.util.args.MultiChoiceArgument;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.FileBasedArgument;
+import com.forgerock.opendj.cli.IntegerArgument;
+import com.forgerock.opendj.cli.MultiChoiceArgument;
+import com.forgerock.opendj.cli.StringArgument;
import org.opends.server.protocols.asn1.ASN1Exception;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/LDIFDiff.java b/opendj3-server-dev/src/server/org/opends/server/tools/LDIFDiff.java
index b94a54d..c71da15 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/LDIFDiff.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/LDIFDiff.java
@@ -60,10 +60,10 @@
import org.opends.server.util.LDIFReader;
import org.opends.server.util.LDIFWriter;
import org.opends.server.util.StaticUtils;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.StringArgument;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/LDIFModify.java b/opendj3-server-dev/src/server/org/opends/server/tools/LDIFModify.java
index 7a417c2..cf4db51 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/LDIFModify.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/LDIFModify.java
@@ -64,10 +64,10 @@
import org.opends.server.util.LDIFReader;
import org.opends.server.util.LDIFWriter;
import org.opends.server.util.ModifyChangeRecordEntry;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.StringArgument;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.tools.ToolConstants.*;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/LDIFSearch.java b/opendj3-server-dev/src/server/org/opends/server/tools/LDIFSearch.java
index 161e0b5..7652bfe 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/LDIFSearch.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/LDIFSearch.java
@@ -54,12 +54,12 @@
import org.opends.server.util.LDIFException;
import org.opends.server.util.LDIFReader;
import org.opends.server.util.LDIFWriter;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.IntegerArgument;
-import org.opends.server.util.args.MultiChoiceArgument;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.IntegerArgument;
+import com.forgerock.opendj.cli.MultiChoiceArgument;
+import com.forgerock.opendj.cli.StringArgument;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.tools.ToolConstants.*;
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 0bd60b6..3b1de0a 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
@@ -47,10 +47,10 @@
import org.opends.server.types.InitializationException;
import org.opends.server.types.NullOutputStream;
import org.opends.server.util.BuildVersion;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.StringArgument;
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/ManageAccount.java b/opendj3-server-dev/src/server/org/opends/server/tools/ManageAccount.java
index 585d461..95a3662 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/ManageAccount.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/ManageAccount.java
@@ -46,16 +46,16 @@
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.types.NullOutputStream;
import org.forgerock.opendj.ldap.ByteStringBuilder;
-import org.opends.server.util.args.Argument;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.FileBasedArgument;
-import org.opends.server.util.args.IntegerArgument;
+import com.forgerock.opendj.cli.Argument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.FileBasedArgument;
+import com.forgerock.opendj.cli.IntegerArgument;
+import com.forgerock.opendj.cli.MultiChoiceArgument;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.SubCommand;
+import com.forgerock.opendj.cli.SubCommandArgumentParser;
import org.opends.server.util.args.LDAPConnectionArgumentParser;
-import org.opends.server.util.args.MultiChoiceArgument;
-import org.opends.server.util.args.StringArgument;
-import org.opends.server.util.args.SubCommand;
-import org.opends.server.util.args.SubCommandArgumentParser;
import static org.opends.server.extensions.
PasswordPolicyStateExtendedOperation.*;
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 0acc9ce..bab053b 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
@@ -28,27 +28,34 @@
package org.opends.server.tools;
import org.forgerock.i18n.LocalizableMessage;
+
import static org.opends.messages.ToolMessages.*;
import org.opends.server.api.ErrorLogPublisher;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
+
import static org.opends.server.loggers.ErrorLogger.removeErrorLogPublisher;
import org.opends.server.protocols.asn1.ASN1Exception;
+
import static org.opends.server.tools.ToolConstants.*;
+
import org.opends.server.tools.tasks.TaskClient;
import org.opends.server.tools.tasks.TaskEntry;
import org.opends.server.types.InitializationException;
import org.opends.server.types.LDAPException;
import org.opends.server.util.BuildVersion;
import org.opends.server.util.StaticUtils;
+
import static org.opends.server.util.StaticUtils.filterExitCode;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.BooleanArgument;
+
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.CLIException;
+import com.forgerock.opendj.cli.StringArgument;
+
import org.opends.server.util.args.LDAPConnectionArgumentParser;
-import org.opends.server.util.args.StringArgument;
-import org.opends.server.util.cli.CLIException;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.LDAPConnectionConsoleInteraction;
import org.opends.server.util.cli.Menu;
@@ -58,7 +65,6 @@
import org.opends.server.util.table.TableBuilder;
import org.opends.server.util.table.TextTablePrinter;
-
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -67,6 +73,7 @@
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+
import org.opends.server.backends.task.TaskState;
/**
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/RebuildIndex.java b/opendj3-server-dev/src/server/org/opends/server/tools/RebuildIndex.java
index 1346c0d..52558b5 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/RebuildIndex.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/RebuildIndex.java
@@ -36,10 +36,12 @@
import org.opends.server.util.BuildVersion;
import org.opends.server.util.StaticUtils;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.BooleanArgument;
+
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.StringArgument;
import org.opends.server.util.args.LDAPConnectionArgumentParser;
-import org.opends.server.util.args.StringArgument;
+
import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.config.ConfigException;
import org.opends.server.loggers.DebugLogger;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/RestoreDB.java b/opendj3-server-dev/src/server/org/opends/server/tools/RestoreDB.java
index 14ebd93..59eb54e 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/RestoreDB.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/RestoreDB.java
@@ -25,12 +25,10 @@
* Portions Copyright 2012-2014 ForgeRock AS.
*/
package org.opends.server.tools;
+
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
-
-
-
import java.io.OutputStream;
import java.io.PrintStream;
import java.text.DateFormat;
@@ -59,11 +57,11 @@
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.util.BuildVersion;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.CLIException;
+import com.forgerock.opendj.cli.StringArgument;
import org.opends.server.util.args.LDAPConnectionArgumentParser;
-import org.opends.server.util.cli.CLIException;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.util.ServerConstants.*;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/StopDS.java b/opendj3-server-dev/src/server/org/opends/server/tools/StopDS.java
index 0bf300d..1688b52 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/StopDS.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/StopDS.java
@@ -36,6 +36,7 @@
import java.util.TimeZone;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
+
import javax.net.ssl.SSLException;
import org.forgerock.i18n.LocalizableMessage;
@@ -54,15 +55,16 @@
import org.opends.server.tasks.ShutdownTask;
import org.opends.server.tools.tasks.TaskTool;
import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ByteString;
-import org.opends.server.util.args.Argument;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.FileBasedArgument;
-import org.opends.server.util.args.IntegerArgument;
import org.opends.server.util.args.LDAPConnectionArgumentParser;
-import org.opends.server.util.args.StringArgument;
+import org.forgerock.opendj.ldap.ByteString;
+
+import com.forgerock.opendj.cli.Argument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.FileBasedArgument;
+import com.forgerock.opendj.cli.IntegerArgument;
+import com.forgerock.opendj.cli.StringArgument;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.messages.ToolMessages.*;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/VerifyIndex.java b/opendj3-server-dev/src/server/org/opends/server/tools/VerifyIndex.java
index d127703..b741f16 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/VerifyIndex.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/VerifyIndex.java
@@ -47,10 +47,10 @@
import org.opends.server.loggers.TraceSettings;
import org.opends.server.types.*;
import org.opends.server.util.BuildVersion;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.StringArgument;
import java.io.OutputStream;
import java.io.PrintStream;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/WaitForFileDelete.java b/opendj3-server-dev/src/server/org/opends/server/tools/WaitForFileDelete.java
index 5b59aae..5f7c4a3 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/WaitForFileDelete.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/WaitForFileDelete.java
@@ -35,11 +35,11 @@
import org.forgerock.i18n.LocalizableMessage;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.NullOutputStream;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.IntegerArgument;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.IntegerArgument;
+import com.forgerock.opendj.cli.StringArgument;
import org.opends.server.util.cli.ConsoleApplication;
import static org.opends.messages.ToolMessages.*;
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 3945755..748787a 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
@@ -41,9 +41,9 @@
import org.opends.server.admin.client.ManagedObjectDecodingException;
import org.opends.server.admin.client.MissingMandatoryPropertiesException;
import org.opends.server.admin.client.OperationRejectedException;
-import org.opends.server.util.args.Argument;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.cli.CLIException;
+import com.forgerock.opendj.cli.Argument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.CLIException;
import org.opends.server.util.cli.ConsoleApplication;
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/CreateSubCommandHandler.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java
index e229ae7..fa7e740 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
@@ -80,12 +80,12 @@
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.tools.ClientException;
import org.opends.server.tools.ToolConstants;
-import org.opends.server.util.args.Argument;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.StringArgument;
-import org.opends.server.util.args.SubCommand;
-import org.opends.server.util.args.SubCommandArgumentParser;
-import org.opends.server.util.cli.CLIException;
+import com.forgerock.opendj.cli.Argument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.SubCommand;
+import com.forgerock.opendj.cli.SubCommandArgumentParser;
+import com.forgerock.opendj.cli.CLIException;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.HelpCallback;
import org.opends.server.util.cli.MenuBuilder;
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 f1500f4..277dfc2 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
@@ -74,13 +74,13 @@
import org.opends.server.util.EmbeddedUtils;
import org.opends.server.util.ServerConstants;
import org.opends.server.util.StaticUtils;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.StringArgument;
-import org.opends.server.util.args.SubCommand;
-import org.opends.server.util.args.SubCommandArgumentParser;
-import org.opends.server.util.args.ArgumentGroup;
-import org.opends.server.util.cli.CLIException;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.BooleanArgument;
+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.CLIException;
import org.opends.server.util.cli.CommandBuilder;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.Menu;
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 afde008..8fb3574 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
@@ -51,12 +51,12 @@
import org.opends.server.admin.client.OperationRejectedException;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.tools.ClientException;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.StringArgument;
-import org.opends.server.util.args.SubCommand;
-import org.opends.server.util.args.SubCommandArgumentParser;
-import org.opends.server.util.cli.CLIException;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.SubCommand;
+import com.forgerock.opendj.cli.SubCommandArgumentParser;
+import com.forgerock.opendj.cli.CLIException;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.MenuResult;
import org.opends.server.util.table.TableBuilder;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/GetPropSubCommandHandler.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/GetPropSubCommandHandler.java
index 89a4ae3..d06d18c 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/GetPropSubCommandHandler.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/GetPropSubCommandHandler.java
@@ -64,11 +64,11 @@
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.tools.ClientException;
import org.opends.server.tools.ToolConstants;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.StringArgument;
-import org.opends.server.util.args.SubCommand;
-import org.opends.server.util.args.SubCommandArgumentParser;
-import org.opends.server.util.cli.CLIException;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.SubCommand;
+import com.forgerock.opendj.cli.SubCommandArgumentParser;
+import com.forgerock.opendj.cli.CLIException;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.MenuResult;
import org.opends.server.util.table.TableBuilder;
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 12a5216..c405746 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
@@ -65,12 +65,12 @@
import org.opends.server.admin.UndefinedDefaultBehaviorProvider;
import org.opends.server.admin.PropertyException;
import org.opends.server.tools.ClientException;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.StringArgument;
-import org.opends.server.util.args.SubCommand;
-import org.opends.server.util.args.SubCommandArgumentParser;
-import org.opends.server.util.cli.CLIException;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.SubCommand;
+import com.forgerock.opendj.cli.SubCommandArgumentParser;
+import com.forgerock.opendj.cli.CLIException;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.MenuResult;
import org.opends.server.util.cli.OutputStreamConsoleApplication;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/InternalManagementContextFactory.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/InternalManagementContextFactory.java
index 780dfae..06fb35b 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/InternalManagementContextFactory.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/InternalManagementContextFactory.java
@@ -22,6 +22,7 @@
*
*
* Copyright 2007-2009 Sun Microsystems, Inc.
+ * Portions Copyright 2014 ForgeRock AS
*/
package org.opends.server.tools.dsconfig;
@@ -29,8 +30,8 @@
import org.opends.server.admin.client.ManagementContext;
import org.opends.server.tools.ClientException;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.SubCommandArgumentParser;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.SubCommandArgumentParser;
import org.opends.server.util.cli.CommandBuilder;
import org.opends.server.util.cli.ConsoleApplication;
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 0ec11ca..c225cf0 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
@@ -45,9 +45,9 @@
import org.opends.server.config.ConfigException;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.tools.ClientException;
-import org.opends.server.util.args.Argument;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.SubCommandArgumentParser;
+import com.forgerock.opendj.cli.Argument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.SubCommandArgumentParser;
import org.opends.server.util.cli.CommandBuilder;
import org.opends.server.util.cli.LDAPConnectionConsoleInteraction;
import org.opends.server.util.cli.ConsoleApplication;
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 760f2cc..6e2560f 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,11 +56,11 @@
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.tools.ClientException;
import org.opends.server.tools.ToolConstants;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.StringArgument;
-import org.opends.server.util.args.SubCommand;
-import org.opends.server.util.args.SubCommandArgumentParser;
-import org.opends.server.util.cli.CLIException;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.SubCommand;
+import com.forgerock.opendj.cli.SubCommandArgumentParser;
+import com.forgerock.opendj.cli.CLIException;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.MenuResult;
import org.opends.server.util.table.TableBuilder;
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 82ad4e0..3153f4a 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
@@ -22,6 +22,7 @@
*
*
* Copyright 2007-2009 Sun Microsystems, Inc.
+ * Portions Copyright 2014 ForgeRock AS
*/
package org.opends.server.tools.dsconfig;
@@ -29,8 +30,8 @@
import org.opends.server.admin.client.ManagementContext;
import org.opends.server.tools.ClientException;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.SubCommandArgumentParser;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.SubCommandArgumentParser;
import org.opends.server.util.cli.CommandBuilder;
import org.opends.server.util.cli.ConsoleApplication;
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 6999aed..73e776f 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
@@ -72,8 +72,7 @@
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.tools.ClientException;
import org.forgerock.util.Reject;
-import org.opends.server.util.cli.CLIException;
-import org.opends.server.util.cli.ConsoleApplication;
+import com.forgerock.opendj.cli.CLIException;
import org.opends.server.util.cli.HelpCallback;
import org.opends.server.util.cli.Menu;
import org.opends.server.util.cli.MenuBuilder;
@@ -81,6 +80,7 @@
import org.opends.server.util.cli.MenuResult;
import org.opends.server.util.table.TableBuilder;
import org.opends.server.util.table.TextTablePrinter;
+import org.opends.server.util.cli.ConsoleApplication;
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 6b3d9fe..a24c02a 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
@@ -66,12 +66,12 @@
import org.opends.server.admin.condition.ContainsCondition;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.tools.ClientException;
-import org.opends.server.util.args.Argument;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.StringArgument;
-import org.opends.server.util.args.SubCommand;
-import org.opends.server.util.args.SubCommandArgumentParser;
-import org.opends.server.util.cli.CLIException;
+import com.forgerock.opendj.cli.Argument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.SubCommand;
+import com.forgerock.opendj.cli.SubCommandArgumentParser;
+import com.forgerock.opendj.cli.CLIException;
import org.opends.server.util.cli.CommandBuilder;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.MenuResult;
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 6b06b18..bb73a60 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
@@ -73,12 +73,12 @@
import org.opends.server.admin.client.ManagementContext;
import org.opends.server.tools.ClientException;
import org.opends.server.util.ServerConstants;
-import org.opends.server.util.args.Argument;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.StringArgument;
-import org.opends.server.util.args.SubCommand;
-import org.opends.server.util.cli.CLIException;
+import com.forgerock.opendj.cli.Argument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.SubCommand;
+import com.forgerock.opendj.cli.CLIException;
import org.opends.server.util.cli.CommandBuilder;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.Menu;
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 743a81a..866178d 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
@@ -22,6 +22,7 @@
*
*
* Copyright 2009 Sun Microsystems, Inc.
+ * Portions Copyright 2014 ForgeRock AS
*/
package org.opends.server.tools.dsconfig;
@@ -41,8 +42,8 @@
import org.opends.server.admin.RelationOption;
import org.opends.server.admin.SetRelationDefinition;
import org.opends.server.admin.SingletonRelationDefinition;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.SubCommandArgumentParser;
+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 e6c2df1..f0824f5 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
@@ -47,15 +47,15 @@
import org.opends.server.admin.client.cli.TaskScheduleArgs;
import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.tasks.PurgeConflictsHistoricalTask;
-import org.opends.server.types.OpenDsException;
-import org.opends.server.util.args.Argument;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentGroup;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.FileBasedArgument;
-import org.opends.server.util.args.IntegerArgument;
-import org.opends.server.util.args.StringArgument;
-import org.opends.server.util.args.SubCommand;
+import com.forgerock.opendj.cli.Argument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentGroup;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.CLIException;
+import com.forgerock.opendj.cli.FileBasedArgument;
+import com.forgerock.opendj.cli.IntegerArgument;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.SubCommand;
/**
* This class is used to parse the arguments passed to the replication CLI.
@@ -1915,9 +1915,13 @@
taskArgs.validateArgs();
}
}
- catch (OpenDsException ode)
+ catch (CLIException ce)
{
- addMessage(buf, ode.getMessageObject());
+ addMessage(buf, ce.getMessageObject());
+ }
+ catch (ArgumentException ae)
+ {
+ addMessage(buf, ae.getMessageObject());
}
}
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java
index 97aff49..65b120e 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java
@@ -79,12 +79,25 @@
import org.opends.server.util.ServerConstants;
import org.opends.server.util.SetupUtils;
import org.opends.server.util.StaticUtils;
-import org.opends.server.util.args.*;
-import org.opends.server.util.cli.*;
+
+import com.forgerock.opendj.cli.Argument;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.CLIException;
+import com.forgerock.opendj.cli.FileBasedArgument;
+import com.forgerock.opendj.cli.IntegerArgument;
+
+import org.opends.server.util.cli.CommandBuilder;
+import org.opends.server.util.cli.ConsoleApplication;
+import org.opends.server.util.cli.LDAPConnectionConsoleInteraction;
+import org.opends.server.util.cli.MenuBuilder;
import org.opends.server.util.table.TabSeparatedTablePrinter;
import org.opends.server.util.table.TableBuilder;
import org.opends.server.util.table.TablePrinter;
import org.opends.server.util.table.TextTablePrinter;
+import org.opends.server.util.cli.PointAdder;
+import org.opends.server.util.cli.MenuResult;
import javax.naming.NameAlreadyBoundException;
import javax.naming.NameNotFoundException;
@@ -92,6 +105,7 @@
import javax.naming.NamingException;
import javax.naming.directory.*;
import javax.naming.ldap.InitialLdapContext;
+
import java.io.*;
import java.util.*;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/makeldif/MakeLDIF.java b/opendj3-server-dev/src/server/org/opends/server/tools/makeldif/MakeLDIF.java
index 6f523c2..c7072e3 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/makeldif/MakeLDIF.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/makeldif/MakeLDIF.java
@@ -42,11 +42,11 @@
import org.opends.server.types.NullOutputStream;
import org.opends.server.util.BuildVersion;
import org.opends.server.util.LDIFWriter;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.IntegerArgument;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.IntegerArgument;
+import com.forgerock.opendj.cli.StringArgument;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.tools.ToolConstants.*;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCli.java b/opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCli.java
index f6d64cd..165586a 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCli.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCli.java
@@ -75,7 +75,7 @@
import org.opends.server.types.OpenDsException;
import org.opends.server.util.BuildVersion;
import org.opends.server.util.StaticUtils;
-import org.opends.server.util.args.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentException;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.LDAPConnectionConsoleInteraction;
import org.opends.server.util.table.TableBuilder;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCliArgumentParser.java b/opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCliArgumentParser.java
index 3001e5e..f9b8a87 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCliArgumentParser.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/status/StatusCliArgumentParser.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2008-2009 Sun Microsystems, Inc.
- * Portions Copyright 2012 ForgeRock AS
+ * Portions Copyright 2012-2014 ForgeRock AS
*/
package org.opends.server.tools.status;
@@ -38,11 +38,11 @@
import org.opends.server.admin.client.cli.SecureConnectionCliArgs;
import org.opends.server.admin.client.cli.SecureConnectionCliParser;
import org.opends.server.tools.ToolConstants;
-import org.opends.server.util.args.Argument;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.IntegerArgument;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.Argument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.IntegerArgument;
+import com.forgerock.opendj.cli.StringArgument;
/**
* The class that is used to parse the arguments provided in the status command
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleInteraction.java b/opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleInteraction.java
index 06d5e27..47d20c5 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleInteraction.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleInteraction.java
@@ -44,7 +44,7 @@
import org.opends.server.backends.task.RecurringTask;
import org.opends.server.types.DirectoryException;
import org.opends.server.util.StaticUtils;
-import org.opends.server.util.cli.CLIException;
+import com.forgerock.opendj.cli.CLIException;
import org.opends.server.util.cli.ConsoleApplication;
import org.opends.server.util.cli.MenuBuilder;
import org.opends.server.util.cli.MenuResult;
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleUserData.java b/opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleUserData.java
index ceac67a..3cafc90 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleUserData.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskScheduleUserData.java
@@ -22,6 +22,7 @@
*
*
* Copyright 2010 Sun Microsystems, Inc.
+ * Portions Copyright 2014 ForgeRock AS
*/
package org.opends.server.tools.tasks;
@@ -34,8 +35,8 @@
import org.opends.server.admin.client.cli.TaskScheduleArgs;
import org.opends.server.backends.task.FailedDependencyAction;
import org.opends.server.util.StaticUtils;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.StringArgument;
import org.opends.server.util.cli.CommandBuilder;
/**
@@ -299,4 +300,4 @@
}
return arg;
}
-}
+}
\ No newline at end of file
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskTool.java b/opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskTool.java
index 16ab2a2..d0deb88 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskTool.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/tasks/TaskTool.java
@@ -27,29 +27,32 @@
package org.opends.server.tools.tasks;
-import org.opends.server.util.args.Argument;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.LDAPConnectionArgumentParser;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.StringArgument;
-import org.opends.server.util.args.ArgumentGroup;
-import org.opends.server.util.cli.CLIException;
+import com.forgerock.opendj.cli.Argument;
+import com.forgerock.opendj.cli.ArgumentGroup;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.CLIException;
import static org.opends.server.util.StaticUtils.wrapText;
import static org.opends.server.util.StaticUtils.getExceptionMessage;
import static org.opends.server.util.ServerConstants.MAX_LINE_WIDTH;
+
import org.opends.server.protocols.asn1.ASN1Exception;
import org.opends.server.tools.LDAPConnection;
import org.opends.server.tools.LDAPConnectionException;
+
import static org.opends.server.tools.ToolConstants.*;
import org.opends.server.types.LDAPException;
import org.opends.server.types.OpenDsException;
+import org.opends.server.util.args.LDAPConnectionArgumentParser;
import org.opends.server.core.DirectoryServer;
import org.opends.server.admin.client.cli.TaskScheduleArgs;
import org.opends.server.backends.task.TaskState;
import org.opends.server.backends.task.FailedDependencyAction;
import org.forgerock.i18n.LocalizableMessage;
+
import static org.opends.messages.ToolMessages.*;
import static org.opends.messages.TaskMessages.*;
@@ -349,6 +352,10 @@
}
}
ret = 0;
+ } catch (ArgumentException e) {
+ LocalizableMessage message = e.getMessageObject();
+ if (err != null) err.println(wrapText(message, MAX_LINE_WIDTH));
+ ret = 1;
} catch (LDAPConnectionException e) {
LocalizableMessage message;
if (isWrongPortException(e,
diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/upgrade/UpgradeCli.java b/opendj3-server-dev/src/server/org/opends/server/tools/upgrade/UpgradeCli.java
index 10f860a..309ae3e 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/upgrade/UpgradeCli.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/upgrade/UpgradeCli.java
@@ -52,11 +52,11 @@
import org.opends.server.tools.ClientException;
import org.opends.server.util.ServerConstants;
import org.opends.server.util.StaticUtils;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.StringArgument;
-import org.opends.server.util.args.SubCommandArgumentParser;
-import org.opends.server.util.cli.CLIException;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.SubCommandArgumentParser;
+import com.forgerock.opendj.cli.CLIException;
import org.opends.server.util.cli.ConsoleApplication;
/**
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/Base64.java b/opendj3-server-dev/src/server/org/opends/server/util/Base64.java
index 6b1015a..6a93d6c 100644
--- a/opendj3-server-dev/src/server/org/opends/server/util/Base64.java
+++ b/opendj3-server-dev/src/server/org/opends/server/util/Base64.java
@@ -48,11 +48,11 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.NullOutputStream;
import org.forgerock.opendj.ldap.ByteSequence;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.StringArgument;
-import org.opends.server.util.args.SubCommand;
-import org.opends.server.util.args.SubCommandArgumentParser;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.StringArgument;
+import com.forgerock.opendj.cli.SubCommand;
+import com.forgerock.opendj.cli.SubCommandArgumentParser;
import static org.opends.messages.UtilityMessages.*;
import static org.opends.messages.ToolMessages.*;
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/EMailMessage.java b/opendj3-server-dev/src/server/org/opends/server/util/EMailMessage.java
index 1c5577f..dddfb8b 100644
--- a/opendj3-server-dev/src/server/org/opends/server/util/EMailMessage.java
+++ b/opendj3-server-dev/src/server/org/opends/server/util/EMailMessage.java
@@ -52,10 +52,10 @@
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.opends.server.core.DirectoryServer;
import org.forgerock.i18n.slf4j.LocalizedLogger;
-import org.opends.server.util.args.ArgumentException;
-import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.StringArgument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.StringArgument;
import static org.opends.messages.ToolMessages.*;
import static org.opends.messages.UtilityMessages.*;
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/StaticUtils.java b/opendj3-server-dev/src/server/org/opends/server/util/StaticUtils.java
index c2a344a..f3109b4 100644
--- a/opendj3-server-dev/src/server/org/opends/server/util/StaticUtils.java
+++ b/opendj3-server-dev/src/server/org/opends/server/util/StaticUtils.java
@@ -54,8 +54,8 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ServerContext;
import org.opends.server.types.*;
-import org.opends.server.util.args.Argument;
-import org.opends.server.util.args.ArgumentException;
+import com.forgerock.opendj.cli.Argument;
+import com.forgerock.opendj.cli.ArgumentException;
import static org.opends.messages.CoreMessages.*;
import static org.opends.messages.UtilityMessages.*;
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/args/Argument.java b/opendj3-server-dev/src/server/org/opends/server/util/args/Argument.java
deleted file mode 100644
index d2c1e52..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/args/Argument.java
+++ /dev/null
@@ -1,704 +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 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2013-2014 ForgeRock AS
- */
-package org.opends.server.util.args;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-
-import static org.opends.messages.UtilityMessages.*;
-import static org.opends.server.util.StaticUtils.*;
-
-/**
- * This class defines a generic argument that may be used in the argument list
- * for an application. This is an abstract class that must be subclassed in
- * order to provide specific functionality.
- */
-public abstract class Argument
-{
- /**
- * Indicates whether this argument should be hidden in the usage information.
- */
- private boolean isHidden;
-
- /**
- * Indicates whether this argument may be specified more than once for
- * multiple values.
- */
- private boolean isMultiValued;
-
- /**
- * Indicates whether this argument was provided in the set of command-line
- * arguments.
- */
- private boolean isPresent;
-
- /** Indicates whether this argument is required to have a value. */
- private boolean isRequired;
-
- /** Indicates whether this argument requires a value. */
- private boolean needsValue;
-
- /** The single-character identifier for this argument. */
- private Character shortIdentifier;
-
- /** The unique ID of the description for this argument. */
- private LocalizableMessage description;
-
- /** The set of provided values for this argument. */
- private LinkedList<String> values;
-
- /** The default value for the argument if none other is provided. */
- private String defaultValue;
-
- /** The long identifier for this argument. */
- private String longIdentifier;
-
- /** The generic name that will be used to refer to this argument. */
- private String name;
-
- /** The name of the property that can be used to set the default value. */
- private String propertyName;
-
- /**
- * The value placeholder for this argument, which will be used in usage
- * information. It describes the format that must be used to specify the
- * values for this argument.
- */
- private LocalizableMessage valuePlaceholder;
-
- /**
- * Indicates whether this argument was provided in the set of properties found
- * is a properties file.
- */
- private boolean isValueSetByProperty;
-
-
- /**
- * Creates a new argument with the provided information.
- *
- * @param name The generic name that should be used to refer to
- * this argument.
- * @param shortIdentifier The single-character identifier for this
- * argument, or <CODE>null</CODE> if there is none.
- * @param longIdentifier The long identifier for this argument, or
- * <CODE>null</CODE> if there is none.
- * @param isRequired Indicates whether this argument must be specified
- * on the command line.
- * @param isMultiValued Indicates whether this argument may be specified
- * more than once to provide multiple values.
- * @param needsValue Indicates whether this argument requires a value.
- * @param valuePlaceholder The placeholder for the argument value that will
- * be displayed in usage information, or
- * <CODE>null</CODE> if this argument does not
- * require a value.
- * @param defaultValue The default value that should be used for this
- * argument if none is provided in a properties file
- * or on the command line. This may be
- * <CODE>null</CODE> if there is no generic default.
- * @param propertyName The name of the property in a property file that
- * may be used to override the default value but
- * will be overridden by a command-line argument.
- * @param description LocalizableMessage for the description of this
- * argument.
- *
- * @throws ArgumentException If there is a problem with any of the
- * parameters used to create this argument.
- */
- protected Argument(String name, Character shortIdentifier,
- String longIdentifier, boolean isRequired,
- boolean isMultiValued, boolean needsValue,
- LocalizableMessage valuePlaceholder, String defaultValue,
- String propertyName,
- LocalizableMessage description)
- throws ArgumentException
- {
- this.name = name;
- this.shortIdentifier = shortIdentifier;
- this.longIdentifier = longIdentifier;
- this.isRequired = isRequired;
- this.isMultiValued = isMultiValued;
- this.needsValue = needsValue;
- this.valuePlaceholder = valuePlaceholder;
- this.defaultValue = defaultValue;
- this.propertyName = propertyName;
- this.description = description;
- this.isValueSetByProperty = false ;
-
- if (shortIdentifier == null && longIdentifier == null)
- {
- LocalizableMessage message = ERR_ARG_NO_IDENTIFIER.get(name);
- throw new ArgumentException(message);
- }
-
- if (needsValue && valuePlaceholder == null)
- {
- LocalizableMessage message = ERR_ARG_NO_VALUE_PLACEHOLDER.get(name);
- throw new ArgumentException(message);
- }
-
- values = new LinkedList<String>();
- isPresent = false;
- isHidden = false;
- }
-
-
-
- /**
- * Retrieves the generic name that will be used to refer to this argument.
- *
- * @return The generic name that will be used to refer to this argument.
- */
- public String getName()
- {
- return name;
- }
-
-
-
- /**
- * Retrieves the single-character identifier that may be used to specify the
- * value of this argument.
- *
- * @return The single-character identifier that may be used to specify the
- * value of this argument, or <CODE>null</CODE> if there is none.
- */
- public Character getShortIdentifier()
- {
- return shortIdentifier;
- }
-
-
-
- /**
- * Retrieves the long (multi-character) identifier that may be used to specify
- * the value of this argument.
- *
- * @return The long (multi-character) identifier that may be used to specify
- * the value of this argument.
- */
- public String getLongIdentifier()
- {
- return longIdentifier;
- }
-
-
-
- /**
- * Indicates whether this argument is required to have at least one value.
- *
- * @return <CODE>true</CODE> if this argument is required to have at least
- * one value, or <CODE>false</CODE> if it does not need to have a
- * value.
- */
- public boolean isRequired()
- {
- return isRequired;
- }
-
-
-
- /**
- * Specifies whether this argument is required to have at least one value.
- *
- * @param isRequired Indicates whether this argument is required to have at
- * least one value.
- */
- public void setRequired(boolean isRequired)
- {
- this.isRequired = isRequired;
- }
-
-
-
- /**
- * Indicates whether this argument is present in the parsed set of
- * command-line arguments.
- *
- * @return <CODE>true</CODE> if this argument is present in the parsed set of
- * command-line arguments, or <CODE>false</CODE> if not.
- */
- public boolean isPresent()
- {
- return isPresent;
- }
-
-
-
- /**
- * Specifies whether this argument is present in the parsed set of
- * command-line arguments.
- *
- * @param isPresent Indicates whether this argument is present in the set of
- * command-line arguments.
- */
- public void setPresent(boolean isPresent)
- {
- this.isPresent = isPresent;
- }
-
-
-
- /**
- * Indicates whether this argument should be hidden from the usage
- * information.
- *
- * @return <CODE>true</CODE> if this argument should be hidden from the usage
- * information, or <CODE>false</CODE> if not.
- */
- public boolean isHidden()
- {
- return isHidden;
- }
-
-
-
- /**
- * Specifies whether this argument should be hidden from the usage
- * information.
- *
- * @param isHidden Indicates whether this argument should be hidden from the
- * usage information.
- */
- public void setHidden(boolean isHidden)
- {
- this.isHidden = isHidden;
- }
-
-
-
- /**
- * Indicates whether this argument may be provided more than once on the
- * command line to specify multiple values.
- *
- * @return <CODE>true</CODE> if this argument may be provided more than once
- * on the command line to specify multiple values, or
- * <CODE>false</CODE> if it may have at most one value.
- */
- public boolean isMultiValued()
- {
- return isMultiValued;
- }
-
-
-
- /**
- * Specifies whether this argument may be provided more than once on the
- * command line to specify multiple values.
- *
- * @param isMultiValued Indicates whether this argument may be provided more
- * than once on the command line to specify multiple
- * values.
- */
- public void setMultiValued(boolean isMultiValued)
- {
- this.isMultiValued = isMultiValued;
- }
-
-
-
- /**
- * Indicates whether a value must be provided with this argument if it is
- * present.
- *
- * @return <CODE>true</CODE> if a value must be provided with the argument if
- * it is present, or <CODE>false</CODE> if the argument does not take
- * a value and the presence of the argument identifier itself is
- * sufficient to convey the necessary information.
- */
- public boolean needsValue()
- {
- return needsValue;
- }
-
-
-
- /**
- * Specifies whether a value must be provided with this argument if it is
- * present. If this is changed from <CODE>false</CODE> to <CODE>true</CODE>,
- * then a value placeholder must also be provided.
- *
- * @param needsValue Indicates whether a value must be provided with this
- * argument if it is present.
-
- */
- public void setNeedsValue(boolean needsValue)
- {
- this.needsValue = needsValue;
- }
-
-
-
- /**
- * Retrieves the value placeholder that will be displayed for this argument in
- * the generated usage information.
- *
- * @return The value placeholder that will be displayed for this argument in
- * the generated usage information, or <CODE>null</CODE> if there is
- * none.
- */
- public LocalizableMessage getValuePlaceholder()
- {
- return valuePlaceholder;
- }
-
-
-
- /**
- * Specifies the value placeholder that will be displayed for this argument in
- * the generated usage information. It may be <CODE>null</CODE> only if
- * <CODE>needsValue()</CODE> returns <CODE>false</CODE>.
- *
- * @param valuePlaceholder The value placeholder that will be displayed for
- * this argument in the generated usage information.
- */
- public void setValuePlaceholder(LocalizableMessage valuePlaceholder)
- {
- this.valuePlaceholder = valuePlaceholder;
- }
-
-
-
- /**
- * Retrieves the default value that will be used for this argument if it is
- * not specified on the command line and it is not set from a properties file.
- *
- * @return The default value that will be used for this argument if it is not
- * specified on the command line and it is not set from a properties
- * file, or <CODE>null</CODE> if there is no default value.
- */
- public String getDefaultValue()
- {
- return defaultValue;
- }
-
-
-
- /**
- * Specifies the default value that will be used for this argument if it is
- * not specified on the command line and it is not set from a properties file.
- *
- * @param defaultValue The default value that will be used for this argument
- * if it is not specified on the command line and it is
- * not set from a properties file.
- */
- public void setDefaultValue(String defaultValue)
- {
- this.defaultValue = defaultValue;
- }
-
-
-
- /**
- * Retrieves the name of a property in a properties file that may be used to
- * set the default value for this argument if it is present. A value read
- * from a properties file will override the default value returned from the
- * <CODE>getDefaultValue</CODE>, but the properties file value will be
- * overridden by a value supplied on the command line.
- *
- * @return The name of a property in a properties file that may be used to
- * set the default value for this argument if it is present.
- */
- public String getPropertyName()
- {
- return propertyName;
- }
-
- /**
- * Specifies the name of a property in a properties file that may be used to
- * set the default value for this argument if it is present.
- *
- * @param propertyName The name of a property in a properties file that may
- * be used to set the default value for this argument if
- * it is present.
- */
- public void setPropertyName(String propertyName)
- {
- this.propertyName = propertyName;
- }
-
- /**
- * Indicates whether this argument was provided in the set of
- * properties found is a properties file.
- *
- * @return <CODE>true</CODE> if this argument was provided in the
- * set of properties found is a properties file, or
- * <CODE>false</CODE> if not.
- */
- public boolean isValueSetByProperty()
- {
- return isValueSetByProperty;
- }
-
- /**
- * Specifies whether this argument was provided in the set of
- * properties found is a properties file.
- *
- * @param isValueSetByProperty
- * Specify whether this argument was provided in the set
- * of properties found is a properties file.
- */
- public void setValueSetByProperty(boolean isValueSetByProperty)
- {
- this.isValueSetByProperty = isValueSetByProperty;
- }
-
- /**
- * Retrieves the human-readable description for this argument.
- *
- * @return The human-readable description for this argument.
- */
- public LocalizableMessage getDescription()
- {
- return description != null ? description : LocalizableMessage.EMPTY;
- }
-
- /**
- * Indicates whether this argument has at least one value.
- *
- * @return <CODE>true</CODE> if this argument has at least one value, or
- * <CODE>false</CODE> if it does not have any values.
- */
- public boolean hasValue()
- {
- return !values.isEmpty();
- }
-
- /**
- * Retrieves the string value for this argument. If it has multiple values,
- * then the first will be returned. If it does not have any values, then the
- * default value will be returned.
- *
- * @return The string value for this argument, or <CODE>null</CODE> if there
- * are no values and no default value has been given.
- */
- public String getValue()
- {
- if (values.isEmpty())
- {
- return defaultValue;
- }
- return values.getFirst();
- }
-
- /**
- * Retrieves the set of string values for this argument.
- *
- * @return The set of string values for this argument.
- */
- public LinkedList<String> getValues()
- {
- return values;
- }
-
- /**
- * Retrieves the value of this argument as an integer.
- *
- * @return The value of this argument as an integer.
- *
- * @throws ArgumentException If there are multiple values, or the value
- * cannot be parsed as an integer.
- */
- public int getIntValue()
- throws ArgumentException
- {
- if (values.isEmpty())
- {
- LocalizableMessage message = ERR_ARG_NO_INT_VALUE.get(name);
- throw new ArgumentException(message);
- }
-
- Iterator<String> iterator = values.iterator();
- String valueString = iterator.next();
-
- int intValue;
- try
- {
- intValue = Integer.parseInt(valueString);
- }
- catch (Exception e)
- {
- LocalizableMessage message = ERR_ARG_CANNOT_DECODE_AS_INT.get(valueString, name);
- throw new ArgumentException(message, e);
- }
-
- if (iterator.hasNext())
- {
- LocalizableMessage message = ERR_ARG_INT_MULTIPLE_VALUES.get(name);
- throw new ArgumentException(message);
- }
- return intValue;
- }
-
- /**
- * Retrieves the set of values for this argument as a list of integers.
- *
- * @return A list of the integer representations of the values for this
- * argument.
- *
- * @throws ArgumentException If any of the values cannot be parsed as an
- * integer.
- */
- public LinkedList<Integer> getIntValues()
- throws ArgumentException
- {
- LinkedList<Integer> intList = new LinkedList<Integer>();
-
- for (String valueString : values)
- {
- try
- {
- intList.add(Integer.valueOf(valueString));
- }
- catch (Exception e)
- {
- LocalizableMessage message = ERR_ARG_CANNOT_DECODE_AS_INT.get(valueString, name);
- throw new ArgumentException(message, e);
- }
- }
-
- return intList;
- }
-
-
-
- /**
- * Retrieves the value of this argument as a <CODE>Boolean</CODE>.
- *
- * @return The value of this argument as a <CODE>Boolean</CODE>.
- *
- * @throws ArgumentException If this argument cannot be interpreted as a
- * Boolean value.
- */
- public boolean getBooleanValue()
- throws ArgumentException
- {
- if (values.isEmpty())
- {
- LocalizableMessage message = ERR_ARG_NO_BOOLEAN_VALUE.get(name);
- throw new ArgumentException(message);
- }
-
- Iterator<String> iterator = values.iterator();
- String valueString = toLowerCase(iterator.next());
-
- boolean booleanValue;
- if ("true".equals(valueString) || "yes".equals(valueString) ||
- "on".equals(valueString) || "1".equals(valueString))
- {
- booleanValue = true;
- }
- else if ("false".equals(valueString) || "no".equals(valueString) ||
- "off".equals(valueString) || "0".equals(valueString))
- {
- booleanValue = false;
- }
- else
- {
- LocalizableMessage message = ERR_ARG_CANNOT_DECODE_AS_BOOLEAN.get(valueString, name);
- throw new ArgumentException(message);
- }
-
- if (iterator.hasNext())
- {
- LocalizableMessage message = ERR_ARG_BOOLEAN_MULTIPLE_VALUES.get(name);
- throw new ArgumentException(message);
- }
- return booleanValue;
- }
-
-
-
- /**
- * Indicates whether the provided value is acceptable for use in this
- * argument.
- *
- * @param valueString The value for which to make the determination.
- * @param invalidReason A buffer into which the invalid reason may be
- * written if the value is not acceptable.
- *
- * @return <CODE>true</CODE> if the value is acceptable, or
- * <CODE>false</CODE> if it is not.
- */
- public abstract boolean valueIsAcceptable(String valueString,
- LocalizableMessageBuilder invalidReason);
-
- /**
- * Adds a value to the set of values for this argument. This should only be
- * called if the value is allowed by the <CODE>valueIsAcceptable</CODE>
- * method.
- *
- * @param valueString The string representation of the value to add to this
- * argument.
- */
- public void addValue(String valueString)
- {
- values.add(valueString);
- }
-
- /**
- * Clears the set of values assigned to this argument.
- */
- public void clearValues()
- {
- values.clear();
- }
-
- /** {@inheritDoc} */
- @Override
- public String toString()
- {
- final StringBuilder sb = new StringBuilder(getClass().getSimpleName());
- sb.append("[name=\"").append(this.name).append("\"");
- if (shortIdentifier != null || longIdentifier != null)
- {
- sb.append(", options=");
- if (shortIdentifier != null)
- {
- sb.append("-").append(shortIdentifier);
- }
- if (longIdentifier != null)
- {
- if (shortIdentifier != null)
- {
- sb.append(" ");
- }
- sb.append("--").append(longIdentifier);
- }
- }
- sb.append(", ").append(isRequired ? "required" : "optional");
- sb.append(", ").append(isMultiValued ? "multiValued" : "singleValued");
- sb.append(", defaultValue=\"").append(defaultValue)
- .append("\", valueFormat=\"").append(valuePlaceholder)
- .append("\", providedValues=\"").append(values)
- .append("\", description=\"").append(description)
- .append("\"]");
- return sb.toString();
- }
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/args/ArgumentException.java b/opendj3-server-dev/src/server/org/opends/server/util/args/ArgumentException.java
deleted file mode 100644
index f49269f..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/args/ArgumentException.java
+++ /dev/null
@@ -1,82 +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 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
- */
-package org.opends.server.util.args;
-import org.forgerock.i18n.LocalizableMessage;
-
-
-
-import org.opends.server.types.IdentifiedException;
-
-
-
-/**
- * This class defines an exception that may be thrown if there is a problem with
- * an argument definition.
- */
-public class ArgumentException
- extends IdentifiedException
-{
- /**
- * The serial version identifier required to satisfy the compiler because this
- * class extends <CODE>java.lang.Exception</CODE>, which implements the
- * <CODE>java.io.Serializable</CODE> interface. This value was generated
- * using the <CODE>serialver</CODE> command-line utility included with the
- * Java SDK.
- */
- private static final long serialVersionUID = 5623155045312160730L;
-
-
-
-
-
- /**
- * Creates a new argument exception with the provided message.
- *
- * @param message The message that explains the problem that occurred.
- */
- public ArgumentException(LocalizableMessage message)
- {
- super(message);
- }
-
-
-
- /**
- * Creates a new argument exception with the provided message and root cause.
- *
- * @param message The message that explains the problem that occurred.
- * @param cause The exception that was caught to trigger this exception.
- */
- public ArgumentException(LocalizableMessage message, Throwable cause)
- {
- super(message, cause);
- }
-
-
-
-}
-
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/args/ArgumentGroup.java b/opendj3-server-dev/src/server/org/opends/server/util/args/ArgumentGroup.java
deleted file mode 100644
index 0b47273..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/args/ArgumentGroup.java
+++ /dev/null
@@ -1,175 +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.args;
-
-import org.forgerock.i18n.LocalizableMessage;
-
-import java.util.List;
-import java.util.LinkedList;
-import java.util.Collections;
-import java.util.Iterator;
-
-/**
- * Class for organizing options into logical groups when arguement
- * usage is printed. To use an argument group, create an instance
- * and use {@link org.opends.server.util.args.ArgumentParser
- * #addArgument(Argument, ArgumentGroup)} when adding arguments for
- * to the parser.
- */
-public class ArgumentGroup implements Comparable<ArgumentGroup> {
-
- // Description for this group of arguments
- private LocalizableMessage description = null;
-
- // List of arguments belonging to this group
- private List<Argument> args = null;
-
- // Governs groups position within usage statement
- private Integer priority;
-
- /**
- * Creates a parameterized instance.
- *
- * @param description for options in this group that is printed before
- * argument descriptions in usage output
- * @param priority number governing the position of this group within
- * the usage statement. Groups with higher priority values appear
- * before groups with lower priority.
- */
- public ArgumentGroup(LocalizableMessage description, int priority) {
- this.description = description;
- this.priority = priority;
- this.args = new LinkedList<Argument>();
- }
-
- /**
- * Gets the description for this group of arguments.
- *
- * @return description for this argument group
- */
- public LocalizableMessage getDescription() {
- return this.description;
- }
-
- /**
- * Sets the description for this group of arguments.
- *
- * @param description for this argument group
- */
- public void setDescription(LocalizableMessage description) {
- this.description = description;
- }
-
- /**
- * Gets the list of arguments associated with this group.
- *
- * @return list of associated arguments
- */
- List<Argument> getArguments() {
- return Collections.unmodifiableList(args);
- }
-
- /**
- * {@inheritDoc}
- */
- public int compareTo(ArgumentGroup o)
- {
- // Groups with higher priority numbers appear before
- // those with lower priority in the usage output
- return -1 * priority.compareTo(o.priority);
- }
-
- /**
- * Indicates whether this group contains any members.
- *
- * @return boolean where true means this group contains members
- */
- boolean containsArguments()
- {
- return this.args.size() > 0;
- }
-
-
- /**
- * Indicates whether this group contains any non-hidden members.
- *
- * @return boolean where true means this group contains non-hidden members
- */
- boolean containsNonHiddenArguments()
- {
- for (Argument arg : args)
- {
- if (!arg.isHidden())
- {
- return true;
- }
- }
- return false;
- }
-
-
- /**
- * Adds an argument to this group.
- *
- * @param arg to add
- * @return boolean where true indicates the add was successful
- */
- boolean addArgument(Argument arg) {
- boolean success = false;
- if (arg != null) {
- Character newShort = arg.getShortIdentifier();
- String newLong = arg.getLongIdentifier();
-
- // See if there is already an argument in this group that the
- // new argument should replace
- for (Iterator<Argument> it = this.args.iterator(); it.hasNext();)
- {
- Argument a = it.next();
- if (newShort != null && newShort.equals(a.getShortIdentifier()) ||
- newLong != null && newLong.equals(a.getLongIdentifier())) {
- it.remove();
- break;
- }
- }
-
- success = this.args.add(arg);
- }
- return success;
- }
-
- /**
- * Removes an argument from this group.
- *
- * @param arg to remove
- * @return boolean where true indicates the remove was successful
- */
- boolean removeArgument(Argument arg) {
- return this.args.remove(arg);
- }
-
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/args/ArgumentParser.java b/opendj3-server-dev/src/server/org/opends/server/util/args/ArgumentParser.java
deleted file mode 100644
index a29b1d9..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/args/ArgumentParser.java
+++ /dev/null
@@ -1,1779 +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 2006-2010 Sun Microsystems, Inc.
- * Portions Copyright 2011-2014 ForgeRock AS
- */
-package org.opends.server.util.args;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.OutputStream;
-import java.util.*;
-
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-import org.opends.server.core.DirectoryServer;
-import org.opends.server.util.SetupUtils;
-
-import static org.opends.messages.ToolMessages.*;
-import static org.opends.messages.UtilityMessages.*;
-import static org.opends.server.tools.ToolConstants.*;
-import static org.opends.server.util.ServerConstants.*;
-import static org.opends.server.util.StaticUtils.*;
-
-/**
- * This class defines a utility that can be used to deal with command-line
- * arguments for applications in a CLIP-compliant manner using either short
- * one-character or longer word-based arguments. It is also integrated with the
- * Directory Server message catalog so that it can display messages in an
- * internationalizeable format, can automatically generate usage information,
- * can detect conflicts between arguments, and can interact with a properties
- * file to obtain default values for arguments there if they are not specified
- * on the command-line.
- */
-public class ArgumentParser
-{
- /**
- * The argument that will be used to indicate the file properties.
- */
- private StringArgument filePropertiesPathArgument;
-
- /**
- * The argument that will be used to indicate that we'll not look for
- * default properties file.
- */
- private BooleanArgument noPropertiesFileArgument;
-
- /**
- * The argument that will be used to trigger the display of usage information.
- */
- private Argument usageArgument;
-
- /**
- * The argument that will be used to trigger the display of the OpenDJ
- * version.
- */
- private Argument versionArgument;
-
- /** The set of unnamed trailing arguments that were provided for this parser.
- */
- private ArrayList<String> trailingArguments;
-
- /**
- * Indicates whether this parser will allow additional unnamed arguments at
- * the end of the list.
- */
- private boolean allowsTrailingArguments;
-
- /**
- * Indicates whether long arguments should be treated in a case-sensitive
- * manner.
- */
- private boolean longArgumentsCaseSensitive;
-
- /** Indicates whether the usage or version information has been displayed. */
- private boolean usageOrVersionDisplayed;
-
- /** Indicates whether the version argument was provided. */
- private boolean versionPresent;
-
- /** The set of arguments defined for this parser, referenced by short ID. */
- private Map<Character,Argument> shortIDMap;
-
- /**
- * The set of arguments defined for this parser, referenced by argument name.
- */
- private Map<String,Argument> argumentMap;
-
- /** The set of arguments defined for this parser, referenced by long ID. */
- private Map<String,Argument> longIDMap;
-
- /** The maximum number of unnamed trailing arguments that may be provided. */
- private int maxTrailingArguments;
-
- /** The minimum number of unnamed trailing arguments that may be provided. */
- private int minTrailingArguments;
-
- /** The total set of arguments defined for this parser. */
- private LinkedList<Argument> argumentList;
-
- /** The output stream to which usage information should be printed. */
- private OutputStream usageOutputStream;
-
- /**
- * The fully-qualified name of the Java class that should be invoked to launch
- * the program with which this argument parser is associated.
- */
- private String mainClassName;
-
- /**
- * A human-readable description for the tool, which will be included when
- * displaying usage information.
- */
- private LocalizableMessage toolDescription;
-
- /**
- * The display name that will be used for the trailing arguments in the usage
- * information.
- */
- private String trailingArgsDisplayName;
-
- /** The raw set of command-line arguments that were provided. */
- private String[] rawArguments;
-
- /** Set of argument groups. */
- protected Set<ArgumentGroup> argumentGroups;
-
-
- /**
- * Group for arguments that have not been explicitly grouped.
- * These will appear at the top of the usage statement without
- * a header.
- */
- protected ArgumentGroup defaultArgGroup = new ArgumentGroup(
- LocalizableMessage.EMPTY, Integer.MAX_VALUE);
-
-
- /**
- * Group for arguments that are related to connection through LDAP. This
- * includes options like the bind DN, the port, etc.
- */
- protected ArgumentGroup ldapArgGroup = new ArgumentGroup(
- INFO_DESCRIPTION_LDAP_CONNECTION_ARGS.get(), Integer.MIN_VALUE + 2);
-
-
- /**
- * Group for arguments that are related to utility input/output like
- * properties file, no-prompt etc. These will appear toward the bottom
- * of the usage statement.
- */
- protected ArgumentGroup ioArgGroup = new ArgumentGroup(
- INFO_DESCRIPTION_IO_ARGS.get(), Integer.MIN_VALUE + 1);
-
-
- /**
- * Group for arguments that are general like help, version etc.
- * These will appear at the end of the usage statement.
- */
- protected ArgumentGroup generalArgGroup = new ArgumentGroup(
- INFO_DESCRIPTION_GENERAL_ARGS.get(), Integer.MIN_VALUE);
-
-
- private static final String INDENT = " ";
- private static final int MAX_LENGTH = SetupUtils.isWindows() ? 79 : 80;
-
- /**
- * Creates a new instance of this argument parser with no arguments.
- * Unnamed trailing arguments will not be allowed.
- *
- * @param mainClassName The fully-qualified name of the Java
- * class that should be invoked to launch
- * the program with which this argument
- * parser is associated.
- * @param toolDescription A human-readable description for the
- * tool, which will be included when
- * displaying usage information.
- * @param longArgumentsCaseSensitive Indicates whether long arguments should
- * be treated in a case-sensitive manner.
- */
- public ArgumentParser(String mainClassName, LocalizableMessage toolDescription,
- boolean longArgumentsCaseSensitive)
- {
- this.mainClassName = mainClassName;
- this.toolDescription = toolDescription;
- this.longArgumentsCaseSensitive = longArgumentsCaseSensitive;
-
- argumentList = new LinkedList<Argument>();
- argumentMap = new HashMap<String,Argument>();
- shortIDMap = new HashMap<Character,Argument>();
- longIDMap = new HashMap<String,Argument>();
- allowsTrailingArguments = false;
- usageOrVersionDisplayed = false;
- versionPresent = false;
- trailingArgsDisplayName = null;
- maxTrailingArguments = 0;
- minTrailingArguments = 0;
- trailingArguments = new ArrayList<String>();
- rawArguments = null;
- usageArgument = null;
- filePropertiesPathArgument = null;
- noPropertiesFileArgument = null;
- usageOutputStream = System.out;
- initGroups();
- }
-
-
-
-
-
- /**
- * Creates a new instance of this argument parser with no arguments that may
- * or may not be allowed to have unnamed trailing arguments.
- *
- * @param mainClassName The fully-qualified name of the Java
- * class that should be invoked to launch
- * the program with which this argument
- * parser is associated.
- * @param toolDescription A human-readable description for the
- * tool, which will be included when
- * displaying usage information.
- * @param longArgumentsCaseSensitive Indicates whether long arguments should
- * be treated in a case-sensitive manner.
- * @param allowsTrailingArguments Indicates whether this parser allows
- * unnamed trailing arguments to be
- * provided.
- * @param minTrailingArguments The minimum number of unnamed trailing
- * arguments that must be provided. A
- * value less than or equal to zero
- * indicates that no minimum will be
- * enforced.
- * @param maxTrailingArguments The maximum number of unnamed trailing
- * arguments that may be provided. A
- * value less than or equal to zero
- * indicates that no maximum will be
- * enforced.
- * @param trailingArgsDisplayName The display name that should be used
- * as a placeholder for unnamed trailing
- * arguments in the generated usage
- * information.
- */
- public ArgumentParser(String mainClassName, LocalizableMessage toolDescription,
- boolean longArgumentsCaseSensitive,
- boolean allowsTrailingArguments,
- int minTrailingArguments, int maxTrailingArguments,
- String trailingArgsDisplayName)
- {
- this.mainClassName = mainClassName;
- this.toolDescription = toolDescription;
- this.longArgumentsCaseSensitive = longArgumentsCaseSensitive;
- this.allowsTrailingArguments = allowsTrailingArguments;
- this.minTrailingArguments = minTrailingArguments;
- this.maxTrailingArguments = maxTrailingArguments;
- this.trailingArgsDisplayName = trailingArgsDisplayName;
-
- argumentList = new LinkedList<Argument>();
- argumentMap = new HashMap<String,Argument>();
- shortIDMap = new HashMap<Character,Argument>();
- longIDMap = new HashMap<String,Argument>();
- trailingArguments = new ArrayList<String>();
- usageOrVersionDisplayed = false;
- versionPresent = false;
- rawArguments = null;
- usageArgument = null;
- usageOutputStream = System.out;
- initGroups();
- }
-
-
-
- /**
- * Retrieves the fully-qualified name of the Java class that should be invoked
- * to launch the program with which this argument parser is associated.
- *
- * @return The fully-qualified name of the Java class that should be invoked
- * to launch the program with which this argument parser is
- * associated.
- */
- public String getMainClassName()
- {
- return mainClassName;
- }
-
-
-
- /**
- * Retrieves a human-readable description for this tool, which should be
- * included at the top of the command-line usage information.
- *
- * @return A human-readable description for this tool, or {@code null} if
- * none is available.
- */
- public LocalizableMessage getToolDescription()
- {
- return toolDescription;
- }
-
-
-
- /**
- * Indicates whether this parser will allow unnamed trailing arguments. These
- * will be arguments at the end of the list that are not preceded by either a
- * long or short identifier and will need to be manually parsed by the
- * application using this parser. Note that once an unnamed trailing argument
- * has been identified, all remaining arguments will be classified as such.
- *
- * @return <CODE>true</CODE> if this parser allows unnamed trailing
- * arguments, or <CODE>false</CODE> if it does not.
- */
- public boolean allowsTrailingArguments()
- {
- return allowsTrailingArguments;
- }
-
-
-
- /**
- * Retrieves the minimum number of unnamed trailing arguments that must be
- * provided.
- *
- * @return The minimum number of unnamed trailing arguments that must be
- * provided, or a value less than or equal to zero if no minimum will
- * be enforced.
- */
- public int getMinTrailingArguments()
- {
- return minTrailingArguments;
- }
-
-
-
- /**
- * Retrieves the maximum number of unnamed trailing arguments that may be
- * provided.
- *
- * @return The maximum number of unnamed trailing arguments that may be
- * provided, or a value less than or equal to zero if no maximum will
- * be enforced.
- */
- public int getMaxTrailingArguments()
- {
- return maxTrailingArguments;
- }
-
-
-
- /**
- * Retrieves the list of all arguments that have been defined for this
- * argument parser.
- *
- * @return The list of all arguments that have been defined for this argument
- * parser.
- */
- public LinkedList<Argument> getArgumentList()
- {
- return argumentList;
- }
-
-
-
- /**
- * Retrieves the argument with the specified name.
- *
- * @param name The name of the argument to retrieve.
- *
- * @return The argument with the specified name, or <CODE>null</CODE> if
- * there is no such argument.
- */
- public Argument getArgument(String name)
- {
- return argumentMap.get(name);
- }
-
-
-
- /**
- * Retrieves the set of arguments mapped by the short identifier that may be
- * used to reference them. Note that arguments that do not have a short
- * identifier will not be present in this list.
- *
- * @return The set of arguments mapped by the short identifier that may be
- * used to reference them.
- */
- public Map<Character, Argument> getArgumentsByShortID()
- {
- return shortIDMap;
- }
-
-
-
- /**
- * Retrieves the argument with the specified short identifier.
- *
- * @param shortID The short ID for the argument to retrieve.
- *
- * @return The argument with the specified short identifier, or
- * <CODE>null</CODE> if there is no such argument.
- */
- public Argument getArgumentForShortID(Character shortID)
- {
- return shortIDMap.get(shortID);
- }
-
-
-
- /**
- * Retrieves the set of arguments mapped by the long identifier that may be
- * used to reference them. Note that arguments that do not have a long
- * identifier will not be present in this list.
- *
- * @return The set of arguments mapped by the long identifier that may be
- * used to reference them.
- */
- public Map<String, Argument> getArgumentsByLongID()
- {
- return longIDMap;
- }
-
-
-
- /**
- * Retrieves the argument with the specified long identifier.
- *
- * @param longID The long identifier of the argument to retrieve.
- *
- * @return The argument with the specified long identifier, or
- * <CODE>null</CODE> if there is no such argument.
- */
- public Argument getArgumentForLongID(String longID)
- {
- return longIDMap.get(longID);
- }
-
-
-
- /**
- * Retrieves the set of unnamed trailing arguments that were provided on the
- * command line.
- *
- * @return The set of unnamed trailing arguments that were provided on the
- * command line.
- */
- public ArrayList<String> getTrailingArguments()
- {
- return trailingArguments;
- }
-
-
-
- /**
- * Retrieves the raw set of arguments that were provided.
- *
- * @return The raw set of arguments that were provided, or <CODE>null</CODE>
- * if the argument list has not yet been parsed.
- */
- public String[] getRawArguments()
- {
- return rawArguments;
- }
-
-
- /**
- * Sets the usage group description for the default argument group.
- *
- * @param description for the default group
- */
- public void setDefaultArgumentGroupDescription(LocalizableMessage description)
- {
- this.defaultArgGroup.setDescription(description);
- }
-
-
- /**
- * Sets the usage group description for the LDAP argument group.
- *
- * @param description for the LDAP group
- */
- public void setLdapArgumentGroupDescription(LocalizableMessage description)
- {
- this.ldapArgGroup.setDescription(description);
- }
-
-
- /**
- * Sets the usage group description for the input/output argument group.
- *
- * @param description for the input/output group
- */
- public void setInputOutputArgumentGroupDescription(LocalizableMessage description)
- {
- this.ioArgGroup.setDescription(description);
- }
-
-
- /**
- * Sets the usage group description for the general argument group.
- *
- * @param description for the general group
- */
- public void setGeneralArgumentGroupDescription(LocalizableMessage description)
- {
- this.generalArgGroup.setDescription(description);
- }
-
-
- /**
- * Adds the provided argument to the set of arguments handled by this parser.
- *
- * @param argument The argument to be added.
- *
- * @throws ArgumentException If the provided argument conflicts with another
- * argument that has already been defined.
- */
- public void addArgument(Argument argument)
- throws ArgumentException
- {
- addArgument(argument, null);
- }
-
- /**
- * Adds the provided argument to the set of arguments handled by this parser
- * and puts the argument in the default group.
- *
- * @param argument The argument to be added.
- *
- * @throws ArgumentException If the provided argument conflicts with another
- * argument that has already been defined.
- */
- public void addDefaultArgument(Argument argument)
- throws ArgumentException
- {
- addArgument(argument, defaultArgGroup);
- }
-
- /**
- * Adds the provided argument to the set of arguments handled by this parser
- * and puts the argument in the LDAP connection group.
- *
- * @param argument The argument to be added.
- *
- * @throws ArgumentException If the provided argument conflicts with another
- * argument that has already been defined.
- */
- public void addLdapConnectionArgument(Argument argument)
- throws ArgumentException
- {
- addArgument(argument, ldapArgGroup);
- }
-
- /**
- * Adds the provided argument to the set of arguments handled by this parser
- * and puts the argument in the input/output group.
- *
- * @param argument The argument to be added.
- *
- * @throws ArgumentException If the provided argument conflicts with another
- * argument that has already been defined.
- */
- public void addInputOutputArgument(Argument argument)
- throws ArgumentException
- {
- addArgument(argument, ioArgGroup);
- }
-
- /**
- * Adds the provided argument to the set of arguments handled by this parser
- * and puts the argument in the general group.
- *
- * @param argument The argument to be added.
- *
- * @throws ArgumentException If the provided argument conflicts with another
- * argument that has already been defined.
- */
- public void addGeneralArgument(Argument argument)
- throws ArgumentException
- {
- addArgument(argument, generalArgGroup);
- }
-
- /**
- * Adds the provided argument to the set of arguments handled by this parser.
- *
- * @param argument The argument to be added.
- * @param group The argument group to which the argument belongs.
- *
- * @throws ArgumentException If the provided argument conflicts with another
- * argument that has already been defined.
- */
- public void addArgument(Argument argument, ArgumentGroup group)
- throws ArgumentException
- {
-
- Character shortID = argument.getShortIdentifier();
- if (shortID != null && shortIDMap.containsKey(shortID))
- {
- String conflictingName = shortIDMap.get(shortID).getName();
- throw new ArgumentException(ERR_ARGPARSER_DUPLICATE_SHORT_ID.get(
- argument.getName(), shortID, conflictingName));
- }
-
- if (versionArgument != null
- && shortID != null
- && shortID.equals(versionArgument.getShortIdentifier()))
- {
- // Update the version argument to not display its short identifier.
- try
- {
- versionArgument = new BooleanArgument(
- OPTION_LONG_PRODUCT_VERSION,
- null,
- OPTION_LONG_PRODUCT_VERSION,
- INFO_DESCRIPTION_PRODUCT_VERSION.get());
- this.generalArgGroup.addArgument(versionArgument);
- }
- catch (ArgumentException e) {
- // ignore
- }
- }
-
- String longID = argument.getLongIdentifier();
- if (longID != null)
- {
- if (! longArgumentsCaseSensitive)
- {
- longID = toLowerCase(longID);
- }
- if (longIDMap.containsKey(longID))
- {
- String conflictingName = longIDMap.get(longID).getName();
-
- LocalizableMessage message = ERR_ARGPARSER_DUPLICATE_LONG_ID.get(
- argument.getName(), argument.getLongIdentifier(), conflictingName);
- throw new ArgumentException(message);
- }
- }
-
- if (shortID != null)
- {
- shortIDMap.put(shortID, argument);
- }
-
- if (longID != null)
- {
- longIDMap.put(longID, argument);
- }
-
- argumentList.add(argument);
-
- if (group == null) {
- group = getStandardGroup(argument);
- }
- group.addArgument(argument);
- argumentGroups.add(group);
- }
-
-
-
- /**
- * Sets the provided argument as one which will automatically trigger the
- * output of usage information if it is provided on the command line and no
- * further argument validation will be performed. Note that the caller will
- * still need to add this argument to the parser with the
- * <CODE>addArgument</CODE> method, and the argument should not be required
- * and should not take a value. Also, the caller will still need to check
- * for the presence of the usage argument after calling
- * <CODE>parseArguments</CODE> to know that no further processing will be
- * required.
- *
- * @param argument The argument whose presence should automatically
- * trigger the display of usage information.
- */
- public void setUsageArgument(Argument argument)
- {
- usageArgument = argument;
- usageOutputStream = System.out;
- }
-
-
-
- /**
- * Sets the provided argument as one which will automatically trigger the
- * output of usage information if it is provided on the command line and no
- * further argument validation will be performed. Note that the caller will
- * still need to add this argument to the parser with the
- * <CODE>addArgument</CODE> method, and the argument should not be required
- * and should not take a value. Also, the caller will still need to check
- * for the presence of the usage argument after calling
- * <CODE>parseArguments</CODE> to know that no further processing will be
- * required.
- *
- * @param argument The argument whose presence should automatically
- * trigger the display of usage information.
- * @param outputStream The output stream to which the usage information
- * should be written.
- */
- public void setUsageArgument(Argument argument, OutputStream outputStream)
- {
- usageArgument = argument;
- usageOutputStream = outputStream;
- }
-
-
- /**
- * Sets the provided argument which will be used to identify the
- * file properties.
- *
- * @param argument
- * The argument which will be used to identify the file
- * properties.
- */
- public void setFilePropertiesArgument(StringArgument argument)
- {
- filePropertiesPathArgument= argument;
- }
-
- /**
- * Sets the provided argument which will be used to identify the
- * file properties.
- *
- * @param argument
- * The argument which will be used to indicate if we have to
- * look for properties file.
- */
- public void setNoPropertiesFileArgument(BooleanArgument argument)
- {
- noPropertiesFileArgument = argument;
- }
-
- /**
- * Parses the provided set of arguments and updates the information associated
- * with this parser accordingly.
- *
- * @param rawArguments The raw set of arguments to parse.
- *
- * @throws ArgumentException If a problem was encountered while parsing the
- * provided arguments.
- */
- public void parseArguments(String[] rawArguments)
- throws ArgumentException
- {
- parseArguments(rawArguments, null);
- }
-
- /**
- * Parses the provided set of arguments and updates the information associated
- * with this parser accordingly. Default values for unspecified arguments may
- * be read from the specified properties if any are provided.
- *
- * @param rawArguments The set of raw arguments to parse.
- * @param argumentProperties A set of properties that may be used to provide
- * default values for arguments not included in
- * the given raw arguments.
- *
- * @throws ArgumentException If a problem was encountered while parsing the
- * provided arguments.
- */
- public void parseArguments(String[] rawArguments,
- Properties argumentProperties)
- throws ArgumentException
- {
- this.rawArguments = rawArguments;
-
- boolean inTrailingArgs = false;
-
- int numArguments = rawArguments.length;
- for (int i=0; i < numArguments; i++)
- {
- String arg = rawArguments[i];
-
- if (inTrailingArgs)
- {
- trailingArguments.add(arg);
- if (maxTrailingArguments > 0 &&
- trailingArguments.size() > maxTrailingArguments)
- {
- LocalizableMessage message =
- ERR_ARGPARSER_TOO_MANY_TRAILING_ARGS.get(maxTrailingArguments);
- throw new ArgumentException(message);
- }
-
- continue;
- }
-
- if (arg.equals("--"))
- {
- // This is a special indicator that we have reached the end of the named
- // arguments and that everything that follows after this should be
- // considered trailing arguments.
- inTrailingArgs = true;
- }
- else if (arg.startsWith("--"))
- {
- // This indicates that we are using the long name to reference the
- // argument. It may be in any of the following forms:
- // --name
- // --name value
- // --name=value
-
- String argName = arg.substring(2);
- String argValue = null;
- int equalPos = argName.indexOf('=');
- if (equalPos < 0)
- {
- // This is fine. The value is not part of the argument name token.
- }
- else if (equalPos == 0)
- {
- // The argument starts with "--=", which is not acceptable.
- LocalizableMessage message = ERR_ARGPARSER_LONG_ARG_WITHOUT_NAME.get(arg);
- throw new ArgumentException(message);
- }
- else
- {
- // The argument is in the form --name=value, so parse them both out.
- argValue = argName.substring(equalPos+1);
- argName = argName.substring(0, equalPos);
- }
-
- // If we're not case-sensitive, then convert the name to lowercase.
- String origArgName = argName;
- if (! longArgumentsCaseSensitive)
- {
- argName = toLowerCase(argName);
- }
-
- // Get the argument with the specified name.
- Argument a = longIDMap.get(argName);
- if (a == null)
- {
- if (argName.equals(OPTION_LONG_HELP))
- {
- // "--help" will always be interpreted as requesting usage
- // information.
- getUsage(usageOutputStream);
- return;
- }
- else
- if (argName.equals(OPTION_LONG_PRODUCT_VERSION))
- {
- // "--version" will always be interpreted as requesting version
- // information.
- usageOrVersionDisplayed = true;
- versionPresent = true;
- printVersion();
- return;
- }
- else
- {
- // There is no such argument registered.
- LocalizableMessage message =
- ERR_ARGPARSER_NO_ARGUMENT_WITH_LONG_ID.get(origArgName);
- throw new ArgumentException(message);
- }
- }
- else
- {
- a.setPresent(true);
-
- // If this is the usage argument, then immediately stop and print
- // usage information.
- if (usageArgument != null &&
- usageArgument.getName().equals(a.getName()))
- {
- getUsage(usageOutputStream);
- return;
- }
- }
-
- // See if the argument takes a value. If so, then make sure one was
- // provided. If not, then make sure none was provided.
- if (a.needsValue())
- {
- if (argValue == null)
- {
- if ((i+1) == numArguments)
- {
- LocalizableMessage message =
- ERR_ARGPARSER_NO_VALUE_FOR_ARGUMENT_WITH_LONG_ID.get(
- origArgName);
- throw new ArgumentException(message);
- }
-
- argValue = rawArguments[++i];
- }
-
- LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder();
- if (! a.valueIsAcceptable(argValue, invalidReason))
- {
- LocalizableMessage message = ERR_ARGPARSER_VALUE_UNACCEPTABLE_FOR_LONG_ID.get(
- argValue, origArgName, invalidReason);
- throw new ArgumentException(message);
- }
-
- // If the argument already has a value, then make sure it is
- // acceptable to have more than one.
- if (a.hasValue() && !a.isMultiValued())
- {
- LocalizableMessage message =
- ERR_ARGPARSER_NOT_MULTIVALUED_FOR_LONG_ID.get(origArgName);
- throw new ArgumentException(message);
- }
-
- a.addValue(argValue);
- }
- else
- {
- if (argValue != null)
- {
- LocalizableMessage message =
- ERR_ARGPARSER_ARG_FOR_LONG_ID_DOESNT_TAKE_VALUE.get(
- origArgName);
- throw new ArgumentException(message);
- }
- }
- }
- else if (arg.startsWith("-"))
- {
- // This indicates that we are using the 1-character name to reference
- // the argument. It may be in any of the following forms:
- // -n
- // -nvalue
- // -n value
- if (arg.equals("-"))
- {
- LocalizableMessage message = ERR_ARGPARSER_INVALID_DASH_AS_ARGUMENT.get();
- throw new ArgumentException(message);
- }
-
- char argCharacter = arg.charAt(1);
- String argValue;
- if (arg.length() > 2)
- {
- argValue = arg.substring(2);
- }
- else
- {
- argValue = null;
- }
-
-
- // Get the argument with the specified short ID.
- Argument a = shortIDMap.get(argCharacter);
- if (a == null)
- {
- if (argCharacter == '?')
- {
- // "-?" will always be interpreted as requesting usage information.
- getUsage(usageOutputStream);
- return;
- }
- else
- if (argCharacter == OPTION_SHORT_PRODUCT_VERSION
- && !shortIDMap.containsKey(OPTION_SHORT_PRODUCT_VERSION))
- {
- // "-V" will always be interpreted as requesting
- // version information except if it's already defined (e.g in
- // ldap tools).
- usageOrVersionDisplayed = true ;
- versionPresent = true;
- printVersion();
- return;
- }
- else
- {
- // There is no such argument registered.
- throw new ArgumentException(
- ERR_ARGPARSER_NO_ARGUMENT_WITH_SHORT_ID.get(argCharacter));
- }
- }
- else
- {
- a.setPresent(true);
-
- // If this is the usage argument, then immediately stop and print
- // usage information.
- if (usageArgument != null &&
- usageArgument.getName().equals(a.getName()))
- {
- getUsage(usageOutputStream);
- return;
- }
- }
-
- // See if the argument takes a value. If so, then make sure one was
- // provided. If not, then make sure none was provided.
- if (a.needsValue())
- {
- if (argValue == null)
- {
- if ((i+1) == numArguments)
- {
- throw new ArgumentException(
- ERR_ARGPARSER_NO_VALUE_FOR_ARGUMENT_WITH_SHORT_ID.get(argCharacter));
- }
-
- argValue = rawArguments[++i];
- }
-
- LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder();
- if (! a.valueIsAcceptable(argValue, invalidReason))
- {
- throw new ArgumentException(ERR_ARGPARSER_VALUE_UNACCEPTABLE_FOR_SHORT_ID.get(
- argValue, argCharacter, invalidReason));
- }
-
- // If the argument already has a value, then make sure it is
- // acceptable to have more than one.
- if (a.hasValue() && !a.isMultiValued())
- {
- throw new ArgumentException(ERR_ARGPARSER_NOT_MULTIVALUED_FOR_SHORT_ID.get(argCharacter));
- }
-
- a.addValue(argValue);
- }
- else
- {
- if (argValue != null)
- {
- // If we've gotten here, then it means that we're in a scenario like
- // "-abc" where "a" is a valid argument that doesn't take a value.
- // However, this could still be valid if all remaining characters in
- // the value are also valid argument characters that don't take
- // values.
- int valueLength = argValue.length();
- for (int j=0; j < valueLength; j++)
- {
- char c = argValue.charAt(j);
- Argument b = shortIDMap.get(c);
- if (b == null)
- {
- // There is no such argument registered.
- throw new ArgumentException(
- ERR_ARGPARSER_NO_ARGUMENT_WITH_SHORT_ID.get(argCharacter));
- }
- else if (b.needsValue())
- {
- // This means we're in a scenario like "-abc" where b is a
- // valid argument that takes a value. We don't support that.
- throw new ArgumentException(
- ERR_ARGPARSER_CANT_MIX_ARGS_WITH_VALUES.get(argCharacter, argValue, c));
- }
- else
- {
- b.setPresent(true);
-
- // If this is the usage argument, then immediately stop and
- // print usage information.
- if (usageArgument != null &&
- usageArgument.getName().equals(b.getName()))
- {
- getUsage(usageOutputStream);
- return;
- }
- }
- }
- }
- }
- }
- else if (allowsTrailingArguments)
- {
- // It doesn't start with a dash, so it must be a trailing argument if
- // that is acceptable.
- inTrailingArgs = true;
- trailingArguments.add(arg);
- }
- else
- {
- // It doesn't start with a dash and we don't allow trailing arguments,
- // so this is illegal.
- LocalizableMessage message = ERR_ARGPARSER_DISALLOWED_TRAILING_ARGUMENT.get(arg);
- throw new ArgumentException(message);
- }
- }
-
-
- if (allowsTrailingArguments
- && minTrailingArguments > 0
- && trailingArguments.size() < minTrailingArguments)
- {
- LocalizableMessage message =
- ERR_ARGPARSER_TOO_FEW_TRAILING_ARGUMENTS.get(minTrailingArguments);
- throw new ArgumentException(message);
- }
-
- // If we don't have the argumentProperties, try to load a properties file.
- if (argumentProperties == null)
- {
- argumentProperties = checkExternalProperties();
- }
-
- normalizeArguments(argumentProperties, argumentList);
- }
-
- /**
- * Iterate through all the arguments and make sure that they have values or a
- * suitable default is available.
- *
- * @param argumentProperties
- * A set of properties that may be used to provide default values for
- * arguments not included in the given raw arguments.
- * @param arguments
- * the arguments to normalize
- * @throws ArgumentException
- * if no value or default value exists for a required argument
- */
- protected void normalizeArguments(Properties argumentProperties,
- List<Argument> arguments) throws ArgumentException
- {
- for (Argument a : arguments)
- {
- if (!a.isPresent()
- // See if there is a value in the properties that can be used
- && argumentProperties != null
- && a.getPropertyName() != null)
- {
- String value =
- argumentProperties.getProperty(a.getPropertyName().toLowerCase());
- LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder();
- if (value != null)
- {
- Boolean addValue = true;
- if (!(a instanceof BooleanArgument))
- {
- addValue = a.valueIsAcceptable(value, invalidReason);
- }
- if (addValue)
- {
- a.addValue(value);
- if (a.needsValue())
- {
- a.setPresent(true);
- }
- a.setValueSetByProperty(true);
- }
- }
- }
-
- if (!a.isPresent() && a.needsValue())
- {
- // See if the argument defines a default.
- if (a.getDefaultValue() != null)
- {
- a.addValue(a.getDefaultValue());
- }
-
- // If there is still no value and the argument is required, then that's
- // a problem.
- if (!a.hasValue() && a.isRequired())
- {
- LocalizableMessage message =
- ERR_ARGPARSER_NO_VALUE_FOR_REQUIRED_ARG.get(a.getName());
- throw new ArgumentException(message);
- }
- }
- }
- }
-
- /**
- * Prints out the version string of the server.
- */
- protected void printVersion()
- {
- try
- {
- DirectoryServer.printVersion(usageOutputStream);
- } catch (Exception e) {}
- }
-
- /**
- * Check if we have a properties file.
- *
- * @return The properties found in the properties file or null.
- * @throws ArgumentException
- * If a problem was encountered while parsing the provided
- * arguments.
- */
- protected Properties checkExternalProperties()
- throws ArgumentException
- {
- // We don't look for properties file.
- if (noPropertiesFileArgument != null
- && noPropertiesFileArgument.isPresent())
- {
- return null;
- }
-
- // Check if we have a properties file argument
- if (filePropertiesPathArgument == null)
- {
- return null;
- }
-
- // check if the properties file argument has been set. If not
- // look for default location.
- String propertiesFilePath = null;
- if (filePropertiesPathArgument.isPresent())
- {
- propertiesFilePath = filePropertiesPathArgument.getValue();
- }
- else
- {
- // Check in "user home"/.opends directory
- String userDir = System.getProperty("user.home");
- propertiesFilePath = findPropertiesFile(userDir + File.separator
- + DEFAULT_OPENDS_CONFIG_DIR);
-
- if (propertiesFilePath == null)
- {
- // check "Opends instance"/config directory
- String instanceDir = DirectoryServer.getInstanceRoot();
- propertiesFilePath = findPropertiesFile(instanceDir+ File.separator
- + "config");
- }
- }
-
- // We don't have a properties file location
- if (propertiesFilePath == null)
- {
- return null;
- }
-
- // We have a location for the properties file.
- Properties argumentProperties = new Properties();
- String scriptName = System.getProperty(PROPERTY_SCRIPT_NAME);
- try
- {
- Properties p = new Properties();
- FileInputStream fis = new FileInputStream(propertiesFilePath);
- p.load(fis);
- fis.close();
-
- for (Enumeration<?> e = p.propertyNames(); e.hasMoreElements();)
- {
- String currentPropertyName = (String) e.nextElement();
- String propertyName = currentPropertyName;
-
- // Property name form <script name>.<property name> has the
- // precedence to <property name>
- if (scriptName != null)
- {
- if (currentPropertyName.startsWith(scriptName))
- {
- propertyName = currentPropertyName
- .substring(scriptName.length() + 1);
- }
- else
- {
- if (p.containsKey(scriptName + "." + currentPropertyName ))
- {
- continue;
- }
- }
- }
- argumentProperties.setProperty(propertyName.toLowerCase(), p
- .getProperty(currentPropertyName));
- }
- }
- catch (Exception e)
- {
- LocalizableMessage message = ERR_ARGPARSER_CANNOT_READ_PROPERTIES_FILE.get(
- propertiesFilePath, getExceptionMessage(e));
- throw new ArgumentException(message, e);
- }
- return argumentProperties;
- }
-
-
- /**
- * Get the absolute path of the properties file.
- *
- * @param directory
- * The location in which we should look for properties file
- * @return The absolute path of the properties file or null
- */
- private String findPropertiesFile(String directory)
- {
- // Look for the tools properties file
- File f = new File(directory,DEFAULT_OPENDS_PROPERTIES_FILE_NAME
- + DEFAULT_OPENDS_PROPERTIES_FILE_EXTENSION);
- if (f.exists() && f.canRead())
- {
- return f.getAbsolutePath();
- }
- return null;
- }
-
- /**
- * Appends usage information based on the defined arguments to the
- * provided buffer.
- *
- * @param buffer
- * The buffer to which the usage information should be
- * appended.
- */
- public void getUsage(StringBuilder buffer)
- {
- usageOrVersionDisplayed = true;
- if (toolDescription != null && toolDescription.length() > 0)
- {
- buffer.append(wrapText(toolDescription.toString(), MAX_LENGTH - 1));
- buffer.append(EOL);
- buffer.append(EOL);
- }
-
- String scriptName = System.getProperty(PROPERTY_SCRIPT_NAME);
- if (scriptName == null || scriptName.length() == 0)
- {
- buffer.append(INFO_ARGPARSER_USAGE_JAVA_CLASSNAME.get(mainClassName));
- }
- else
- {
- buffer.append(INFO_ARGPARSER_USAGE_JAVA_SCRIPTNAME.get(scriptName));
- }
-
- if (allowsTrailingArguments)
- {
- if (trailingArgsDisplayName == null)
- {
- buffer.append(" ");
- buffer.append(INFO_ARGPARSER_USAGE_TRAILINGARGS.get());
- }
- else
- {
- buffer.append(" ");
- buffer.append(trailingArgsDisplayName);
- }
- }
- buffer.append(EOL);
- buffer.append(INFO_SUBCMDPARSER_WHERE_OPTIONS_INCLUDE.get());
- buffer.append(EOL);
- buffer.append(EOL);
-
- Argument helpArgument = null ;
-
- boolean printHeaders = printUsageGroupHeaders();
- for (ArgumentGroup argGroup : argumentGroups)
- {
- if (argGroup.containsArguments() && printHeaders)
- {
- // Print the groups description if any
- LocalizableMessage groupDesc = argGroup.getDescription();
- if (groupDesc != null && !LocalizableMessage.EMPTY.equals(groupDesc)) {
- buffer.append(EOL);
- buffer.append(wrapText(groupDesc.toString(), MAX_LENGTH - 1));
- buffer.append(EOL);
- buffer.append(EOL);
- }
- }
-
- for (Argument a : argGroup.getArguments())
- {
- // If this argument is hidden, then skip it.
- if (a.isHidden())
- {
- continue;
- }
-
- // Help argument should be printed at the end
- if (usageArgument != null
- && usageArgument.getName().equals(a.getName()))
- {
- helpArgument = a ;
- continue ;
- }
- printArgumentUsage(a, buffer);
- }
- }
- if (helpArgument != null)
- {
- printArgumentUsage(helpArgument, buffer);
- }
- else
- {
- buffer.append(EOL);
- buffer.append("-?");
- buffer.append(EOL);
- }
- }
-
-
-
- /**
- * Retrieves a message containing usage information based on the defined
- * arguments.
- *
- * @return A string containing usage information based on the defined
- * arguments.
- */
- public LocalizableMessage getUsageMessage()
- {
- StringBuilder buffer = new StringBuilder();
- getUsage(buffer);
-
- // TODO: rework getUsage(OutputStream) to work with messages framework
- return LocalizableMessage.raw(buffer.toString());
- }
-
- /**
- * Retrieves a string containing usage information based on the defined
- * arguments.
- *
- * @return A string containing usage information based on the defined
- * arguments.
- */
- public String getUsage()
- {
- StringBuilder buffer = new StringBuilder();
- getUsage(buffer);
-
- return buffer.toString();
- }
-
-
-
- /**
- * Writes usage information based on the defined arguments to the provided
- * output stream.
- *
- * @param outputStream The output stream to which the usage information
- * should be written.
- */
- public void getUsage(OutputStream outputStream)
- {
- StringBuilder buffer = new StringBuilder();
- getUsage(buffer);
-
- try
- {
- outputStream.write(buffer.toString().getBytes());
- }
- catch (Exception e) {}
- }
-
-
-
- /**
- * Indicates whether the version or the usage information has been
- * displayed to the end user either by an explicit argument like
- * "-H" or "--help", or by a built-in argument like "-?".
- *
- * @return {@code true} if the usage information has been displayed,
- * or {@code false} if not.
- */
- public boolean usageOrVersionDisplayed()
- {
- return usageOrVersionDisplayed;
- }
-
- /**
- * Appends argument usage information to the provided buffer.
- *
- * @param a The argument to handle.
- * @param buffer
- * The buffer to which the usage information should be
- * appended.
- */
- private void printArgumentUsage(Argument a, StringBuilder buffer)
- {
- // Write a line with the short and/or long identifiers that may be
- // used for the argument.
- Character shortID = a.getShortIdentifier();
- String longID = a.getLongIdentifier();
- if (shortID != null)
- {
- int currentLength = buffer.length();
-
- if (usageArgument.getName().equals(a.getName()))
- {
- buffer.append("-?, ");
- }
-
- buffer.append("-");
- buffer.append(shortID.charValue());
-
- if (a.needsValue() && longID == null)
- {
- buffer.append(" ");
- buffer.append(a.getValuePlaceholder());
- }
-
- if (longID != null)
- {
- StringBuilder newBuffer = new StringBuilder();
- newBuffer.append(", --");
- newBuffer.append(longID);
-
- if (a.needsValue())
- {
- newBuffer.append(" ");
- newBuffer.append(a.getValuePlaceholder());
- }
-
- int lineLength = (buffer.length() - currentLength) +
- newBuffer.length();
- if (lineLength > MAX_LENGTH)
- {
- buffer.append(EOL);
- }
- buffer.append(newBuffer.toString());
- }
-
- buffer.append(EOL);
- }
- else
- {
- if (longID != null)
- {
- if (usageArgument.getName().equals(a.getName()))
- {
- buffer.append("-?, ");
- }
- buffer.append("--");
- buffer.append(longID);
-
- if (a.needsValue())
- {
- buffer.append(" ");
- buffer.append(a.getValuePlaceholder());
- }
-
- buffer.append(EOL);
- }
- }
-
-
- indentAndWrap(INDENT, a.getDescription(), buffer);
- if (a.needsValue()
- && a.getDefaultValue() != null
- && a.getDefaultValue().length() > 0)
- {
- indentAndWrap(INDENT, INFO_ARGPARSER_USAGE_DEFAULT_VALUE.get(a
- .getDefaultValue()), buffer);
- }
- }
-
- /**
- * Write one or more lines with the description of the argument. We will
- * indent the description five characters and try our best to wrap at or
- * before column 79 so it will be friendly to 80-column displays.
- */
- private void indentAndWrap(String indent, LocalizableMessage text, StringBuilder buffer)
- {
- int actualSize = MAX_LENGTH - indent.length() - 1;
- if (text.length() <= actualSize)
- {
- buffer.append(indent);
- buffer.append(text);
- buffer.append(EOL);
- }
- else
- {
- String s = text.toString();
- while (s.length() > actualSize)
- {
- int spacePos = s.lastIndexOf(' ', actualSize);
- if (spacePos > 0)
- {
- buffer.append(indent);
- buffer.append(s.substring(0, spacePos).trim());
- s = s.substring(spacePos + 1).trim();
- buffer.append(EOL);
- }
- else
- {
- // There are no spaces in the first 74 columns.
- // See if there is one after that point.
- // If so, then break there. If not, then don't break at all.
- spacePos = s.indexOf(' ');
- if (spacePos > 0)
- {
- buffer.append(indent);
- buffer.append(s.substring(0, spacePos).trim());
- s = s.substring(spacePos + 1).trim();
- buffer.append(EOL);
- }
- else
- {
- buffer.append(indent);
- buffer.append(s);
- s = "";
- buffer.append(EOL);
- }
- }
- }
-
- if (s.length() > 0)
- {
- buffer.append(indent);
- buffer.append(s);
- buffer.append(EOL);
- }
- }
- }
-
- /**
- * Given an argument, returns an appropriate group. Arguments may
- * be part of one of the special groups or the default group.
- *
- * @param argument for which a group is requested
- * @return argument group appropriate for <code>argument</code>
- */
- protected ArgumentGroup getStandardGroup(Argument argument) {
- if (isInputOutputArgument(argument)) {
- return ioArgGroup;
- } else if (isGeneralArgument(argument)) {
- return generalArgGroup;
- } else if (isLdapConnectionArgument(argument)) {
- return ldapArgGroup;
- }
- return defaultArgGroup;
- }
-
- /**
- * Indicates whether or not argument group description headers
- * should be printed.
- *
- * @return boolean where true means print the descriptions
- */
- protected boolean printUsageGroupHeaders() {
- // If there is only a single group then we won't print them.
- int groupsContainingArgs = 0;
- for (ArgumentGroup argGroup : argumentGroups)
- {
- if (argGroup.containsNonHiddenArguments())
- {
- groupsContainingArgs++;
- }
- }
- return groupsContainingArgs > 1;
- }
-
- private void initGroups() {
- this.argumentGroups = new TreeSet<ArgumentGroup>();
- this.argumentGroups.add(defaultArgGroup);
- this.argumentGroups.add(ldapArgGroup);
- this.argumentGroups.add(generalArgGroup);
- this.argumentGroups.add(ioArgGroup);
-
- try {
- versionArgument = new BooleanArgument(
- OPTION_LONG_PRODUCT_VERSION,
- OPTION_SHORT_PRODUCT_VERSION,
- OPTION_LONG_PRODUCT_VERSION,
- INFO_DESCRIPTION_PRODUCT_VERSION.get());
- this.generalArgGroup.addArgument(versionArgument);
- } catch (ArgumentException e) {
- // ignore
- }
- }
-
-
- private boolean isInputOutputArgument(Argument arg) {
- if (arg != null) {
- String longId = arg.getLongIdentifier();
- return OPTION_LONG_VERBOSE.equals(longId) ||
- OPTION_LONG_QUIET.equals(longId) ||
- OPTION_LONG_NO_PROMPT.equals(longId) ||
- OPTION_LONG_PROP_FILE_PATH.equals(longId) ||
- OPTION_LONG_NO_PROP_FILE.equals(longId) ||
- OPTION_LONG_SCRIPT_FRIENDLY.equals(longId) ||
- OPTION_LONG_DONT_WRAP.equals(longId) ||
- OPTION_LONG_ENCODING.equals(longId) ||
- OPTION_DSCFG_LONG_DISPLAY_EQUIVALENT.equals(longId) ||
- OPTION_LONG_EQUIVALENT_COMMAND_FILE_PATH.equals(longId) ||
- OPTION_LONG_BATCH_FILE_PATH.equals(longId);
- }
- return false;
- }
-
- private boolean isLdapConnectionArgument(Argument arg) {
- if (arg != null) {
- String longId = arg.getLongIdentifier();
- return OPTION_LONG_USE_SSL.equals(longId) ||
- OPTION_LONG_START_TLS.equals(longId) ||
- OPTION_LONG_HOST.equals(longId) ||
- OPTION_LONG_PORT.equals(longId) ||
- OPTION_LONG_BINDDN.equals(longId) ||
- OPTION_LONG_BINDPWD.equals(longId) ||
- OPTION_LONG_BINDPWD_FILE.equals(longId) ||
- OPTION_LONG_SASLOPTION.equals(longId) ||
- OPTION_LONG_TRUSTALL.equals(longId) ||
- OPTION_LONG_TRUSTSTOREPATH.equals(longId) ||
- OPTION_LONG_TRUSTSTORE_PWD.equals(longId) ||
- OPTION_LONG_TRUSTSTORE_PWD_FILE.equals(longId) ||
- OPTION_LONG_KEYSTOREPATH.equals(longId) ||
- OPTION_LONG_KEYSTORE_PWD.equals(longId) ||
- OPTION_LONG_KEYSTORE_PWD_FILE.equals(longId) ||
- OPTION_LONG_CERT_NICKNAME.equals(longId) ||
- OPTION_LONG_REFERENCED_HOST_NAME.equals(longId) ||
- OPTION_LONG_ADMIN_UID.equals(longId) ||
- OPTION_LONG_ADMIN_PWD.equals(longId) ||
- OPTION_LONG_ADMIN_PWD_FILE.equals(longId) ||
- OPTION_LONG_REPORT_AUTHZ_ID.equals(longId) ||
- OPTION_LONG_USE_PW_POLICY_CTL.equals(longId) ||
- OPTION_LONG_USE_SASL_EXTERNAL.equals(longId) ||
- OPTION_LONG_PROTOCOL_VERSION.equals(longId) ||
- OPTION_LONG_CONNECT_TIMEOUT.equals(longId);
- }
- return false;
- }
-
-
- private boolean isGeneralArgument(Argument arg) {
- if (arg != null) {
- String longId = arg.getLongIdentifier();
- return OPTION_LONG_HELP.equals(longId)
- || OPTION_LONG_PRODUCT_VERSION.equals(longId);
- }
- return false;
- }
-
- /**
- * Returns whether the usage argument was provided or not. This method
- * should be called after a call to parseArguments.
- * @return <CODE>true</CODE> if the usage argument was provided and
- * <CODE>false</CODE> otherwise.
- */
- public boolean isUsageArgumentPresent()
- {
- return usageArgument != null && usageArgument.isPresent();
- }
-
- /**
- * Returns whether the version argument was provided or not. This method
- * should be called after a call to parseArguments.
- * @return <CODE>true</CODE> if the version argument was provided and
- * <CODE>false</CODE> otherwise.
- */
- public boolean isVersionArgumentPresent()
- {
- return versionPresent;
- }
-
-
-
- /**
- * Get the password which has to be used for the command without prompting
- * the user. If no password was specified, return null.
- *
- * @param clearArg
- * The password StringArgument argument.
- * @param fileArg
- * The password FileBased argument.
- * @return The password stored into the specified file on by the
- * command line argument, or null it if not specified.
- */
- public static String getBindPassword(StringArgument clearArg,
- FileBasedArgument fileArg)
- {
- if (clearArg.isPresent())
- {
- return clearArg.getValue();
- }
- else if (fileArg.isPresent())
- {
- return fileArg.getValue();
- }
- return null;
- }
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/args/BooleanArgument.java b/opendj3-server-dev/src/server/org/opends/server/util/args/BooleanArgument.java
deleted file mode 100644
index 55157f5..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/args/BooleanArgument.java
+++ /dev/null
@@ -1,115 +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 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
- */
-package org.opends.server.util.args;
-import org.forgerock.i18n.LocalizableMessage;
-
-
-
-import static org.opends.messages.UtilityMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-
-
-/**
- * This class defines an argument type that will be used to represent Boolean
- * values. These arguments will never take values from the command line but
- * and will never be required. If the argument is provided, then it will be
- * considered true, and if not then it will be considered false. As such,
- * the default value will always be "false".
- */
-public class BooleanArgument
- extends Argument
-{
- /**
- * Creates a new Boolean argument with the provided information.
- *
- * @param name The generic name that should be used to refer to
- * this argument.
- * @param shortIdentifier The single-character identifier for this
- * argument, or <CODE>null</CODE> if there is none.
- * @param longIdentifier The long identifier for this argument, or
- * <CODE>null</CODE> if there is none.
- * @param description LocalizableMessage for the description of this
- * argument.
- *
- * @throws ArgumentException If there is a problem with any of the
- * parameters used to create this argument.
- */
- public BooleanArgument(String name, Character shortIdentifier,
- String longIdentifier,
- LocalizableMessage description)
- throws ArgumentException
- {
- super(name, shortIdentifier, longIdentifier, false, false, false, null,
- String.valueOf(false), null, description);
- }
-
-
-
- /**
- * Indicates whether the provided value is acceptable for use in this
- * argument.
- *
- * @param valueString The value for which to make the determination.
- * @param invalidReason A buffer into which the invalid reason may be
- * written if the value is not acceptable.
- *
- * @return <CODE>true</CODE> if the value is acceptable, or
- * <CODE>false</CODE> if it is not.
- */
- public boolean valueIsAcceptable(String valueString,
- LocalizableMessageBuilder invalidReason)
- {
- // This argument type should never have a value, so any value provided will
- // be unacceptable.
-
- invalidReason.append(ERR_BOOLEANARG_NO_VALUE_ALLOWED.get(getName()));
-
- return false;
- }
-
-
- /**
- * {@inheritDoc}
- */
- final public void addValue(String valueString) {
- if (valueString != null) {
- clearValues();
- super.addValue(valueString);
- super.setPresent(Boolean.valueOf(valueString));
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
- final public void setPresent(boolean isPresent) {
- addValue(String.valueOf(isPresent));
- }
-
-}
-
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/args/FileBasedArgument.java b/opendj3-server-dev/src/server/org/opends/server/util/args/FileBasedArgument.java
deleted file mode 100644
index c364f30..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/args/FileBasedArgument.java
+++ /dev/null
@@ -1,269 +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 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
- */
-package org.opends.server.util.args;
-import org.forgerock.i18n.LocalizableMessage;
-
-
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.util.LinkedHashMap;
-
-import static org.opends.messages.UtilityMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-import static org.opends.server.util.StaticUtils.*;
-
-
-
-/**
- * This class defines an argument whose value will be read from a file rather
- * than actually specified on the command-line. When a value is specified on
- * the command line, it will be treated as the path to the file containing the
- * actual value rather than the value itself.
- * <BR><BR>
- * Note that if if no filename is provided on the command line but a default
- * value is specified programatically or if the default value is read from a
- * specified property, then that default value will be taken as the actual value
- * rather than a filename.
- * <BR><BR>
- * Also note that this argument type assumes that the entire value for the
- * argument is on a single line in the specified file. If the file contains
- * multiple lines, then only the first line will be read.
- */
-public class FileBasedArgument
- extends Argument
-{
- // The mapping between filenames specified and the first lines read from those
- // files.
- private LinkedHashMap<String,String> namesToValues;
-
-
-
- /**
- * Creates a new file-based argument with the provided information.
- *
- * @param name The generic name that should be used to refer to
- * this argument.
- * @param shortIdentifier The single-character identifier for this
- * argument, or <CODE>null</CODE> if there is none.
- * @param longIdentifier The long identifier for this argument, or
- * <CODE>null</CODE> if there is none.
- * @param isRequired Indicates whether this argument must be specified
- * on the command line.
- * @param valuePlaceholder The placeholder for the argument value that will
- * be displayed in usage information, or
- * <CODE>null</CODE> if this argument does not
- * require a value.
- * @param description LocalizableMessage for the description of this
- * argument.
- *
- * @throws ArgumentException If there is a problem with any of the
- * parameters used to create this argument.
- */
- public FileBasedArgument(String name, Character shortIdentifier,
- String longIdentifier, boolean isRequired,
- LocalizableMessage valuePlaceholder,
- LocalizableMessage description)
- throws ArgumentException
- {
- super(name, shortIdentifier, longIdentifier, isRequired, false, true,
- valuePlaceholder, null, null, description);
-
-
- namesToValues = new LinkedHashMap<String,String>();
- }
-
-
-
- /**
- * Creates a new file-based argument with the provided information.
- *
- * @param name The generic name that should be used to refer to
- * this argument.
- * @param shortIdentifier The single-character identifier for this
- * argument, or <CODE>null</CODE> if there is none.
- * @param longIdentifier The long identifier for this argument, or
- * <CODE>null</CODE> if there is none.
- * @param isRequired Indicates whether this argument must be specified
- * on the command line.
- * @param isMultiValued Indicates whether this argument may be specified
- * more than once to provide multiple values.
- * @param valuePlaceholder The placeholder for the argument value that will
- * be displayed in usage information, or
- * <CODE>null</CODE> if this argument does not
- * require a value.
- * @param defaultValue The default value that should be used for this
- * argument if none is provided in a properties file
- * or on the command line. This may be
- * <CODE>null</CODE> if there is no generic default.
- * @param propertyName The name of the property in a property file that
- * may be used to override the default value but
- * will be overridden by a command-line argument.
- * @param description LocalizableMessage for the description of this
- * argument.
- *
- * @throws ArgumentException If there is a problem with any of the
- * parameters used to create this argument.
- */
- public FileBasedArgument(String name, Character shortIdentifier,
- String longIdentifier, boolean isRequired,
- boolean isMultiValued, LocalizableMessage valuePlaceholder,
- String defaultValue, String propertyName,
- LocalizableMessage description)
- throws ArgumentException
- {
- super(name, shortIdentifier, longIdentifier, isRequired, isMultiValued,
- true, valuePlaceholder, defaultValue, propertyName,
- description);
-
- namesToValues = new LinkedHashMap<String,String>();
- }
-
-
-
- /**
- * Retrieves a map between the filenames specified on the command line and the
- * first lines read from those files.
- *
- * @return A map between the filenames specified on the command line and the
- * first lines read from those files.
- */
- public LinkedHashMap<String,String> getNameToValueMap()
- {
- return namesToValues;
- }
-
-
-
- /**
- * Indicates whether the provided value is acceptable for use in this
- * argument.
- *
- * @param valueString The value for which to make the determination.
- * @param invalidReason A buffer into which the invalid reason may be
- * written if the value is not acceptable.
- *
- * @return <CODE>true</CODE> if the value is acceptable, or
- * <CODE>false</CODE> if it is not.
- */
- public boolean valueIsAcceptable(String valueString,
- LocalizableMessageBuilder invalidReason)
- {
- // First, make sure that the specified file exists.
- File valueFile;
- try
- {
- valueFile = new File(valueString);
- if (! valueFile.exists())
- {
- invalidReason.append(ERR_FILEARG_NO_SUCH_FILE.get(
- valueString, getName()));
- return false;
- }
- }
- catch (Exception e)
- {
- invalidReason.append(ERR_FILEARG_CANNOT_VERIFY_FILE_EXISTENCE.get(
- valueString, getName(),
- getExceptionMessage(e)));
- return false;
- }
-
-
- // Open the file for reading.
- BufferedReader reader;
- try
- {
- reader = new BufferedReader(new FileReader(valueFile));
- }
- catch (Exception e)
- {
- invalidReason.append(ERR_FILEARG_CANNOT_OPEN_FILE.get(
- valueString, getName(),
- getExceptionMessage(e)));
- return false;
- }
-
-
- // Read the first line and close the file.
- String line;
- try
- {
- line = reader.readLine();
- }
- catch (Exception e)
- {
- invalidReason.append(ERR_FILEARG_CANNOT_READ_FILE.get(
- valueString, getName(),
- getExceptionMessage(e)));
- return false;
- }
- finally
- {
- close(reader);
- }
-
-
- // If the line read is null, then that means the file was empty.
- if (line == null)
- {
- invalidReason.append(ERR_FILEARG_EMPTY_FILE.get(valueString, getName()));
- return false;
- }
-
-
- // Store the value in the hash so it will be available for addValue. We
- // won't do any validation on the value itself, so anything that we read
- // will be considered acceptable.
- namesToValues.put(valueString, line);
- return true;
- }
-
-
-
- /**
- * Adds a value to the set of values for this argument. This should only be
- * called if the value is allowed by the <CODE>valueIsAcceptable</CODE>
- * method. Note that in this case, correct behavior depends on a previous
- * successful call to <CODE>valueIsAcceptable</CODE> so that the value read
- * from the file may be stored in the name-to-value hash and used in place of
- * the filename here.
- *
- * @param valueString The string representation of the value to add to this
- * argument.
- */
- public void addValue(String valueString)
- {
- String actualValue = namesToValues.get(valueString);
- if (actualValue != null)
- {
- super.addValue(actualValue);
- }
- }
-}
-
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/args/IntegerArgument.java b/opendj3-server-dev/src/server/org/opends/server/util/args/IntegerArgument.java
deleted file mode 100644
index f67ba53..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/args/IntegerArgument.java
+++ /dev/null
@@ -1,374 +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 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
- */
-package org.opends.server.util.args;
-import org.forgerock.i18n.LocalizableMessage;
-
-
-
-import static org.opends.messages.UtilityMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-
-
-/**
- * This class defines an argument type that will only accept integer values,
- * and potentially only those in a given range.
- */
-public class IntegerArgument
- extends Argument
-{
- // Indicates whether a lower bound will be enforced for this argument.
- private boolean hasLowerBound;
-
- // Indicates whether an upper bound will be enforced for this argument.
- private boolean hasUpperBound;
-
- // The lower bound that will be enforced for this argument.
- private int lowerBound;
-
- // The upper bound that will be enforced for this argument.
- private int upperBound;
-
-
-
- /**
- * Creates a new integer argument with the provided information.
- *
- * @param name The generic name that should be used to refer to
- * this argument.
- * @param shortIdentifier The single-character identifier for this
- * argument, or <CODE>null</CODE> if there is none.
- * @param longIdentifier The long identifier for this argument, or
- * <CODE>null</CODE> if there is none.
- * @param isRequired Indicates whether this argument must be specified
- * on the command line.
- * @param needsValue Indicates whether this argument requires a value.
- * @param valuePlaceholder The placeholder for the argument value that will
- * be displayed in usage information, or
- * <CODE>null</CODE> if this argument does not
- * require a value.
- * @param description LocalizableMessage for the description of this
- * argument.
- *
- * @throws ArgumentException If there is a problem with any of the
- * parameters used to create this argument.
- */
- public IntegerArgument(String name, Character shortIdentifier,
- String longIdentifier, boolean isRequired,
- boolean needsValue, LocalizableMessage valuePlaceholder,
- LocalizableMessage description)
- throws ArgumentException
- {
- super(name, shortIdentifier, longIdentifier, isRequired, false, needsValue,
- valuePlaceholder, null, null, description);
-
- hasLowerBound = false;
- hasUpperBound = false;
- lowerBound = Integer.MIN_VALUE;
- upperBound = Integer.MAX_VALUE;
- }
-
-
-
- /**
- * Creates a new integer argument with the provided information.
- *
- * @param name The generic name that should be used to refer to
- * this argument.
- * @param shortIdentifier The single-character identifier for this
- * argument, or <CODE>null</CODE> if there is none.
- * @param longIdentifier The long identifier for this argument, or
- * <CODE>null</CODE> if there is none.
- * @param isRequired Indicates whether this argument must be specified
- * on the command line.
- * @param needsValue Indicates whether this argument requires a value.
- * @param valuePlaceholder The placeholder for the argument value that will
- * be displayed in usage information, or
- * <CODE>null</CODE> if this argument does not
- * require a value.
- * @param hasLowerBound Indicates whether a lower bound should be
- * enforced for values of this argument.
- * @param lowerBound The lower bound that should be enforced for
- * values of this argument.
- * @param hasUpperBound Indicates whether an upperbound should be
- * enforced for values of this argument.
- * @param upperBound The upper bound that should be enforced for
- * values of this argument.
- * @param description LocalizableMessage for the description of this
- * argument.
- *
- * @throws ArgumentException If there is a problem with any of the
- * parameters used to create this argument.
- */
- public IntegerArgument(String name, Character shortIdentifier,
- String longIdentifier, boolean isRequired,
- boolean needsValue, LocalizableMessage valuePlaceholder,
- boolean hasLowerBound, int lowerBound,
- boolean hasUpperBound, int upperBound,
- LocalizableMessage description)
- throws ArgumentException
- {
- super(name, shortIdentifier, longIdentifier, isRequired, false, needsValue,
- valuePlaceholder, null, null, description);
-
- this.hasLowerBound = hasLowerBound;
- this.hasUpperBound = hasUpperBound;
- this.lowerBound = lowerBound;
- this.upperBound = upperBound;
-
- if (hasLowerBound && hasUpperBound && (lowerBound > upperBound))
- {
- LocalizableMessage message = ERR_INTARG_LOWER_BOUND_ABOVE_UPPER_BOUND.get(
- name, lowerBound, upperBound);
- throw new ArgumentException(message);
- }
- }
-
-
-
- /**
- * Creates a new integer argument with the provided information.
- *
- * @param name The generic name that should be used to refer to
- * this argument.
- * @param shortIdentifier The single-character identifier for this
- * argument, or <CODE>null</CODE> if there is none.
- * @param longIdentifier The long identifier for this argument, or
- * <CODE>null</CODE> if there is none.
- * @param isRequired Indicates whether this argument must be specified
- * on the command line.
- * @param isMultiValued Indicates whether this argument may be specified
- * more than once to provide multiple values.
- * @param needsValue Indicates whether this argument requires a value.
- * @param valuePlaceholder The placeholder for the argument value that will
- * be displayed in usage information, or
- * <CODE>null</CODE> if this argument does not
- * require a value.
- * @param defaultValue The default value that should be used for this
- * argument if none is provided in a properties file
- * or on the command line. This may be
- * <CODE>null</CODE> if there is no generic default.
- * @param propertyName The name of the property in a property file that
- * may be used to override the default value but
- * will be overridden by a command-line argument.
- * @param description LocalizableMessage for the description of this
- * argument.
- *
- * @throws ArgumentException If there is a problem with any of the
- * parameters used to create this argument.
- */
- public IntegerArgument(String name, Character shortIdentifier,
- String longIdentifier, boolean isRequired,
- boolean isMultiValued, boolean needsValue,
- LocalizableMessage valuePlaceholder, int defaultValue,
- String propertyName,
- LocalizableMessage description)
- throws ArgumentException
- {
- super(name, shortIdentifier, longIdentifier, isRequired, isMultiValued,
- needsValue, valuePlaceholder, String.valueOf(defaultValue),
- propertyName, description);
-
- hasLowerBound = false;
- hasUpperBound = false;
- lowerBound = Integer.MIN_VALUE;
- upperBound = Integer.MAX_VALUE;
- }
-
-
-
- /**
- * Creates a new integer argument with the provided information.
- *
- * @param name The generic name that should be used to refer to
- * this argument.
- * @param shortIdentifier The single-character identifier for this
- * argument, or <CODE>null</CODE> if there is none.
- * @param longIdentifier The long identifier for this argument, or
- * <CODE>null</CODE> if there is none.
- * @param isRequired Indicates whether this argument must be specified
- * on the command line.
- * @param isMultiValued Indicates whether this argument may be specified
- * more than once to provide multiple values.
- * @param needsValue Indicates whether this argument requires a value.
- * @param valuePlaceholder The placeholder for the argument value that will
- * be displayed in usage information, or
- * <CODE>null</CODE> if this argument does not
- * require a value.
- * @param defaultValue The default value that should be used for this
- * argument if none is provided in a properties file
- * or on the command line. This may be
- * <CODE>null</CODE> if there is no generic default.
- * @param propertyName The name of the property in a property file that
- * may be used to override the default value but
- * will be overridden by a command-line argument.
- * @param hasLowerBound Indicates whether a lower bound should be
- * enforced for values of this argument.
- * @param lowerBound The lower bound that should be enforced for
- * values of this argument.
- * @param hasUpperBound Indicates whether an upperbound should be
- * enforced for values of this argument.
- * @param upperBound The upper bound that should be enforced for
- * values of this argument.
- * @param description LocalizableMessage for the description of this
- * argument.
- *
- * @throws ArgumentException If there is a problem with any of the
- * parameters used to create this argument.
- */
- public IntegerArgument(String name, Character shortIdentifier,
- String longIdentifier, boolean isRequired,
- boolean isMultiValued, boolean needsValue,
- LocalizableMessage valuePlaceholder, int defaultValue,
- String propertyName, boolean hasLowerBound,
- int lowerBound, boolean hasUpperBound, int upperBound,
- LocalizableMessage description)
- throws ArgumentException
- {
- super(name, shortIdentifier, longIdentifier, isRequired, isMultiValued,
- needsValue, valuePlaceholder, String.valueOf(defaultValue),
- propertyName, description);
-
- this.hasLowerBound = hasLowerBound;
- this.hasUpperBound = hasUpperBound;
- this.lowerBound = lowerBound;
- this.upperBound = upperBound;
-
- if (hasLowerBound && hasUpperBound && (lowerBound > upperBound))
- {
- LocalizableMessage message = ERR_INTARG_LOWER_BOUND_ABOVE_UPPER_BOUND.get(
- name, lowerBound, upperBound);
- throw new ArgumentException(message);
- }
- }
-
-
-
- /**
- * Indicates whether a lower bound should be enforced for values of this
- * argument.
- *
- * @return <CODE>true</CODE> if a lower bound should be enforced for values
- * of this argument, or <CODE>false</CODE> if not.
- */
- public boolean hasLowerBound()
- {
- return hasLowerBound;
- }
-
-
-
- /**
- * Retrieves the lower bound that may be enforced for values of this argument.
- *
- * @return The lower bound that may be enforced for values of this argument.
- */
- public int getLowerBound()
- {
- return lowerBound;
- }
-
-
-
- /**
- * Indicates whether a upper bound should be enforced for values of this
- * argument.
- *
- * @return <CODE>true</CODE> if a upper bound should be enforced for values
- * of this argument, or <CODE>false</CODE> if not.
- */
- public boolean hasUpperBound()
- {
- return hasUpperBound;
- }
-
-
-
- /**
- * Retrieves the upper bound that may be enforced for values of this argument.
- *
- * @return The upper bound that may be enforced for values of this argument.
- */
- public int getUpperBound()
- {
- return upperBound;
- }
-
-
-
- /**
- * Indicates whether the provided value is acceptable for use in this
- * argument.
- *
- * @param valueString The value for which to make the determination.
- * @param invalidReason A buffer into which the invalid reason may be
- * written if the value is not acceptable.
- *
- * @return <CODE>true</CODE> if the value is acceptable, or
- * <CODE>false</CODE> if it is not.
- */
- public boolean valueIsAcceptable(String valueString,
- LocalizableMessageBuilder invalidReason)
- {
- // First, the value must be decodable as an integer.
- int intValue;
- try
- {
- intValue = Integer.parseInt(valueString);
- }
- catch (Exception e)
- {
- invalidReason.append(ERR_ARG_CANNOT_DECODE_AS_INT.get(
- valueString, getName()));
- return false;
- }
-
-
- // If there is a lower bound, then the value must be greater than or equal
- // to it.
- if (hasLowerBound && (intValue < lowerBound))
- {
- invalidReason.append(ERR_INTARG_VALUE_BELOW_LOWER_BOUND.get(
- getName(), intValue, lowerBound));
- return false;
- }
-
-
- // If there is an upper bound, then the value must be less than or equal to
- // it.
- if (hasUpperBound && (intValue > upperBound))
- {
- invalidReason.append(ERR_INTARG_VALUE_ABOVE_UPPER_BOUND.get(
- getName(), intValue, upperBound));
- return false;
- }
-
-
- // At this point, the value should be acceptable.
- return true;
- }
-}
-
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/args/LDAPConnectionArgumentParser.java b/opendj3-server-dev/src/server/org/opends/server/util/args/LDAPConnectionArgumentParser.java
index 94fa19c..430aec1 100644
--- a/opendj3-server-dev/src/server/org/opends/server/util/args/LDAPConnectionArgumentParser.java
+++ b/opendj3-server-dev/src/server/org/opends/server/util/args/LDAPConnectionArgumentParser.java
@@ -40,6 +40,13 @@
import org.opends.server.admin.client.cli.SecureConnectionCliArgs;
import org.opends.server.types.OpenDsException;
+import com.forgerock.opendj.cli.Argument;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentParser;
+import com.forgerock.opendj.cli.ArgumentGroup;
+import com.forgerock.opendj.cli.FileBasedArgument;
+import com.forgerock.opendj.cli.StringArgument;
+
import java.util.LinkedList;
import java.util.LinkedHashSet;
import java.util.concurrent.atomic.AtomicInteger;
@@ -373,7 +380,14 @@
ui.populateLDAPOptions(options),
ui.getConnectTimeout(),
out, err);
- } catch (OpenDsException e) {
+ } catch (ArgumentException e) {
+ if ((e.getCause() != null) && (e.getCause().getCause() != null) &&
+ e.getCause().getCause() instanceof SSLException) {
+ err.println(ERR_TASKINFO_LDAP_EXCEPTION_SSL.get(ui.getHostName(), ui.getPortNumber()));
+ } else {
+ err.println(e.getMessageObject());
+ }
+ } catch (OpenDsException e) {
if ((e.getCause() != null) && (e.getCause().getCause() != null) &&
e.getCause().getCause() instanceof SSLException) {
err.println(ERR_TASKINFO_LDAP_EXCEPTION_SSL.get(ui.getHostName(), ui.getPortNumber()));
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/args/MultiChoiceArgument.java b/opendj3-server-dev/src/server/org/opends/server/util/args/MultiChoiceArgument.java
deleted file mode 100644
index 8834f4b..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/args/MultiChoiceArgument.java
+++ /dev/null
@@ -1,225 +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 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
- */
-package org.opends.server.util.args;
-import org.forgerock.i18n.LocalizableMessage;
-
-
-
-import java.util.HashSet;
-
-import static org.opends.messages.UtilityMessages.*;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-import static org.opends.server.util.StaticUtils.*;
-
-
-
-/**
- * This class defines an argument type that will only accept one or more of a
- * specific set of string values.
- */
-public class MultiChoiceArgument
- extends Argument
-{
- // Indicates whether argument values should be treated in a case-sensitive
- // manner.
- private boolean caseSensitive;
-
- // The set of values that will be allowed for use with this argument.
- private HashSet<String> allowedValues;
-
-
-
-
- /**
- * Creates a new string argument with the provided information.
- *
- * @param name The generic name that should be used to refer to
- * this argument.
- * @param shortIdentifier The single-character identifier for this
- * argument, or <CODE>null</CODE> if there is none.
- * @param longIdentifier The long identifier for this argument, or
- * <CODE>null</CODE> if there is none.
- * @param isRequired Indicates whether this argument must be specified
- * on the command line.
- * @param needsValue Indicates whether this argument requires a value.
- * @param valuePlaceholder The placeholder for the argument value that will
- * be displayed in usage information, or
- * <CODE>null</CODE> if this argument does not
- * require a value.
- * @param allowedValues The set of values that are allowed for use for
- * this argument. If they are not to be treated in
- * a case-sensitive value then they should all be
- * formatted in lowercase.
- * @param caseSensitive Indicates whether the set of allowed values
- * should be treated in a case-sensitive manner.
- * @param description LocalizableMessage for the description of this
- * argument.
- *
- * @throws ArgumentException If there is a problem with any of the
- * parameters used to create this argument.
- */
- public MultiChoiceArgument(String name, Character shortIdentifier,
- String longIdentifier, boolean isRequired,
- boolean needsValue, LocalizableMessage valuePlaceholder,
- HashSet<String> allowedValues,
- boolean caseSensitive,
- LocalizableMessage description)
- throws ArgumentException
- {
- super(name, shortIdentifier, longIdentifier, isRequired, false, needsValue,
- valuePlaceholder, null, null, description);
-
- this.allowedValues = allowedValues;
- this.caseSensitive = caseSensitive;
- }
-
-
-
- /**
- * Creates a new string argument with the provided information.
- *
- * @param name The generic name that should be used to refer to
- * this argument.
- * @param shortIdentifier The single-character identifier for this
- * argument, or <CODE>null</CODE> if there is none.
- * @param longIdentifier The long identifier for this argument, or
- * <CODE>null</CODE> if there is none.
- * @param isRequired Indicates whether this argument must be specified
- * on the command line.
- * @param isMultiValued Indicates whether this argument may be specified
- * more than once to provide multiple values.
- * @param needsValue Indicates whether this argument requires a value.
- * @param valuePlaceholder The placeholder for the argument value that will
- * be displayed in usage information, or
- * <CODE>null</CODE> if this argument does not
- * require a value.
- * @param defaultValue The default value that should be used for this
- * argument if none is provided in a properties file
- * or on the command line. This may be
- * <CODE>null</CODE> if there is no generic default.
- * @param propertyName The name of the property in a property file that
- * may be used to override the default value but
- * will be overridden by a command-line argument.
- * @param allowedValues The set of values that are allowed for use for
- * this argument. If they are not to be treated in
- * a case-sensitive value then they should all be
- * formatted in lowercase.
- * @param caseSensitive Indicates whether the set of allowed values
- * should be treated in a case-sensitive manner.
- * @param description LocalizableMessage for the description of this
- * argument.
- *
- * @throws ArgumentException If there is a problem with any of the
- * parameters used to create this argument.
- */
- public MultiChoiceArgument(String name, Character shortIdentifier,
- String longIdentifier, boolean isRequired,
- boolean isMultiValued, boolean needsValue,
- LocalizableMessage valuePlaceholder, String defaultValue,
- String propertyName, HashSet<String> allowedValues,
- boolean caseSensitive,
- LocalizableMessage description)
- throws ArgumentException
- {
- super(name, shortIdentifier, longIdentifier, isRequired, isMultiValued,
- needsValue, valuePlaceholder, defaultValue, propertyName,
- description);
-
- this.allowedValues = allowedValues;
- this.caseSensitive = caseSensitive;
- }
-
-
-
- /**
- * Retrieves the set of allowed values for this argument. The contents of
- * this set must not be altered by the caller.
- *
- * @return The set of allowed values for this argument.
- */
- public HashSet<String> getAllowedValues()
- {
- return allowedValues;
- }
-
-
-
- /**
- * Indicates whether the set of allowed values for this argument should be
- * treated in a case-sensitive manner.
- *
- * @return <CODE>true</CODE> if the values are to be treated in a
- * case-sensitive manner, or <CODE>false</CODE> if not.
- */
- public boolean isCaseSensitive()
- {
- return caseSensitive;
- }
-
-
-
- /**
- * Indicates whether the provided value is acceptable for use in this
- * argument.
- *
- * @param valueString The value for which to make the determination.
- * @param invalidReason A buffer into which the invalid reason may be
- * written if the value is not acceptable.
- *
- * @return <CODE>true</CODE> if the value is acceptable, or
- * <CODE>false</CODE> if it is not.
- */
- public boolean valueIsAcceptable(String valueString,
- LocalizableMessageBuilder invalidReason)
- {
- if (caseSensitive)
- {
- if (! allowedValues.contains(valueString))
- {
- invalidReason.append(ERR_MCARG_VALUE_NOT_ALLOWED.get(
- getName(), valueString));
-
- return false;
- }
- }
- else
- {
- if (! allowedValues.contains(toLowerCase(valueString)))
- {
- invalidReason.append(
- ERR_MCARG_VALUE_NOT_ALLOWED.get(getName(), valueString));
-
- return false;
- }
- }
-
-
- // If we've gotten here, then the value appears to be acceptable.
- return true;
- }
-}
-
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/args/StringArgument.java b/opendj3-server-dev/src/server/org/opends/server/util/args/StringArgument.java
deleted file mode 100644
index 962f708..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/args/StringArgument.java
+++ /dev/null
@@ -1,136 +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 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
- */
-package org.opends.server.util.args;
-import org.forgerock.i18n.LocalizableMessage;
-
-import org.forgerock.i18n.LocalizableMessageBuilder;
-
-
-/**
- * This class defines an argument type that will accept any string value.
- */
-public class StringArgument
- extends Argument
-{
- /**
- * Creates a new string argument with the provided information.
- *
- * @param name The generic name that should be used to refer to
- * this argument.
- * @param shortIdentifier The single-character identifier for this
- * argument, or <CODE>null</CODE> if there is none.
- * @param longIdentifier The long identifier for this argument, or
- * <CODE>null</CODE> if there is none.
- * @param isRequired Indicates whether this argument must be specified
- * on the command line.
- * @param needsValue Indicates whether this argument requires a value.
- * @param valuePlaceholder The placeholder for the argument value that will
- * be displayed in usage information, or
- * <CODE>null</CODE> if this argument does not
- * require a value.
- * @param description LocalizableMessage for the description of this
- * argument.
- *
- * @throws ArgumentException If there is a problem with any of the
- * parameters used to create this argument.
- */
- public StringArgument(String name, Character shortIdentifier,
- String longIdentifier, boolean isRequired,
- boolean needsValue, LocalizableMessage valuePlaceholder,
- LocalizableMessage description)
- throws ArgumentException
- {
- super(name, shortIdentifier, longIdentifier, isRequired, false, needsValue,
- valuePlaceholder, null, null, description);
- }
-
-
-
- /**
- * Creates a new string argument with the provided information.
- *
- * @param name The generic name that should be used to refer to
- * this argument.
- * @param shortIdentifier The single-character identifier for this
- * argument, or <CODE>null</CODE> if there is none.
- * @param longIdentifier The long identifier for this argument, or
- * <CODE>null</CODE> if there is none.
- * @param isRequired Indicates whether this argument must be specified
- * on the command line.
- * @param isMultiValued Indicates whether this argument may be specified
- * more than once to provide multiple values.
- * @param needsValue Indicates whether this argument requires a value.
- * @param valuePlaceholder The placeholder for the argument value that will
- * be displayed in usage information, or
- * <CODE>null</CODE> if this argument does not
- * require a value.
- * @param defaultValue The default value that should be used for this
- * argument if none is provided in a properties file
- * or on the command line. This may be
- * <CODE>null</CODE> if there is no generic default.
- * @param propertyName The name of the property in a property file that
- * may be used to override the default value but
- * will be overridden by a command-line argument.
- * @param description LocalizableMessage for the description of this
- * argument.
- *
- * @throws ArgumentException If there is a problem with any of the
- * parameters used to create this argument.
- */
- public StringArgument(String name, Character shortIdentifier,
- String longIdentifier, boolean isRequired,
- boolean isMultiValued, boolean needsValue,
- LocalizableMessage valuePlaceholder, String defaultValue,
- String propertyName, LocalizableMessage description)
- throws ArgumentException
- {
- super(name, shortIdentifier, longIdentifier, isRequired, isMultiValued,
- needsValue, valuePlaceholder, defaultValue, propertyName,
- description);
- }
-
-
-
- /**
- * Indicates whether the provided value is acceptable for use in this
- * argument.
- *
- * @param valueString The value for which to make the determination.
- * @param invalidReason A buffer into which the invalid reason may be
- * written if the value is not acceptable.
- *
- * @return <CODE>true</CODE> if the value is acceptable, or
- * <CODE>false</CODE> if it is not.
- */
- public boolean valueIsAcceptable(String valueString,
- LocalizableMessageBuilder invalidReason)
- {
- // All values will be acceptable for this argument.
- return true;
- }
-}
-
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/args/SubCommand.java b/opendj3-server-dev/src/server/org/opends/server/util/args/SubCommand.java
deleted file mode 100644
index 01659e8..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/args/SubCommand.java
+++ /dev/null
@@ -1,459 +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 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2014 ForgeRock AS
- */
-package org.opends.server.util.args;
-import org.forgerock.i18n.LocalizableMessage;
-
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedList;
-
-import static org.opends.messages.UtilityMessages.*;
-
-import static org.opends.server.util.StaticUtils.*;
-
-
-
-/**
- * This class defines a data structure for holding information about a
- * subcommand that may be used with the subcommand argument parser. The
- * subcommand has a name, a description, and a set of arguments.
- */
-public class SubCommand
-{
- // Indicates whether this subCommand should be hidden in the usage
- // information.
- private boolean isHidden;
-
- // The mapping between the short argument IDs and the arguments for this
- // subcommand.
- private HashMap<Character,Argument> shortIDMap;
-
- // The mapping between the long argument IDs and the arguments for this
- // subcommand.
- private HashMap<String,Argument> longIDMap;
-
- // The list of arguments associated with this subcommand.
- private LinkedList<Argument> arguments;
-
- // The description for this subcommand.
- private LocalizableMessage description;
-
- // The name of this subcommand.
- private String name;
-
- // The argument parser with which this subcommand is associated.
- private SubCommandArgumentParser parser;
-
- // Indicates whether this parser will allow additional unnamed
- // arguments at the end of the list.
- private boolean allowsTrailingArguments;
-
- // The maximum number of unnamed trailing arguments that may be
- // provided.
- private int maxTrailingArguments;
-
- // The minimum number of unnamed trailing arguments that may be
- // provided.
- private int minTrailingArguments;
-
- // The display name that will be used for the trailing arguments in
- // the usage information.
- private String trailingArgsDisplayName;
-
- /**
- * Creates a new subcommand with the provided information. The
- * subcommand will be automatically registered with the associated
- * parser.
- *
- * @param parser
- * The argument parser with which this subcommand is
- * associated.
- * @param name
- * The name of this subcommand.
- * @param description
- * The description of this subcommand.
- * @throws ArgumentException
- * If the associated argument parser already has a
- * subcommand with the same name.
- */
- public SubCommand(SubCommandArgumentParser parser, String name,
- LocalizableMessage description) throws ArgumentException
- {
- this(parser, name, false, 0, 0, null, description);
- }
-
-
-
- /**
- * Creates a new subcommand with the provided information. The
- * subcommand will be automatically registered with the associated
- * parser.
- *
- * @param parser
- * The argument parser with which this subcommand is
- * associated.
- * @param name
- * The name of this subcommand.
- * @param allowsTrailingArguments
- * Indicates whether this parser allows unnamed trailing
- * arguments to be provided.
- * @param minTrailingArguments
- * The minimum number of unnamed trailing arguments that
- * must be provided. A value less than or equal to zero
- * indicates that no minimum will be enforced.
- * @param maxTrailingArguments
- * The maximum number of unnamed trailing arguments that
- * may be provided. A value less than or equal to zero
- * indicates that no maximum will be enforced.
- * @param trailingArgsDisplayName
- * The display name that should be used as a placeholder
- * for unnamed trailing arguments in the generated usage
- * information.
- * @param description
- * The description of this subcommand.
- * @throws ArgumentException
- * If the associated argument parser already has a
- * subcommand with the same name.
- */
- public SubCommand(SubCommandArgumentParser parser, String name,
- boolean allowsTrailingArguments, int minTrailingArguments,
- int maxTrailingArguments, String trailingArgsDisplayName,
- LocalizableMessage description) throws ArgumentException
- {
- this.parser = parser;
- this.name = name;
- this.description = description;
- this.allowsTrailingArguments = allowsTrailingArguments;
- this.minTrailingArguments = minTrailingArguments;
- this.maxTrailingArguments = maxTrailingArguments;
- this.trailingArgsDisplayName = trailingArgsDisplayName;
- this.isHidden = false;
-
- String nameToCheck = name;
- if (parser.longArgumentsCaseSensitive())
- {
- nameToCheck = toLowerCase(name);
- }
-
- if (parser.hasSubCommand(nameToCheck))
- {
- LocalizableMessage message = ERR_ARG_SUBCOMMAND_DUPLICATE_SUBCOMMAND.get(name);
- throw new ArgumentException(message);
- }
-
- parser.addSubCommand(this);
- shortIDMap = new HashMap<Character,Argument>();
- longIDMap = new HashMap<String,Argument>();
- arguments = new LinkedList<Argument>();
- }
-
-
-
- /**
- * Retrieves the name of this subcommand.
- *
- * @return The name of this subcommand.
- */
- public String getName()
- {
- return name;
- }
-
-
- /**
- * Retrieves the description for this subcommand.
- *
- * @return The description for this subcommand.
- */
- public LocalizableMessage getDescription()
- {
- return description;
- }
-
-
-
- /**
- * Retrieves the set of arguments for this subcommand.
- *
- * @return The set of arguments for this subcommand.
- */
- public LinkedList<Argument> getArguments()
- {
- return arguments;
- }
-
-
-
- /**
- * Retrieves the subcommand argument with the specified short identifier.
- *
- * @param shortID The short identifier of the argument to retrieve.
- *
- * @return The subcommand argument with the specified short identifier, or
- * <CODE>null</CODE> if there is none.
- */
- public Argument getArgument(Character shortID)
- {
- return shortIDMap.get(shortID);
- }
-
-
-
- /**
- * Retrieves the subcommand argument with the specified long identifier.
- *
- * @param longID The long identifier of the argument to retrieve.
- *
- * @return The subcommand argument with the specified long identifier, or
- * <CODE>null</CODE> if there is none.
- */
- public Argument getArgument(String longID)
- {
- return longIDMap.get(longID);
- }
-
-
-
- /**
- * Retrieves the subcommand argument with the specified name.
- *
- * @param name The name of the argument to retrieve.
- *
- * @return The subcommand argument with the specified name, or
- * <CODE>null</CODE> if there is no such argument.
- */
- public Argument getArgumentForName(String name)
- {
- for (Argument a : arguments)
- {
- if (a.getName().equals(name))
- {
- return a;
- }
- }
-
- return null;
- }
-
-
-
- /**
- * Adds the provided argument for use with this subcommand.
- *
- * @param argument The argument to add for use with this subcommand.
- *
- * @throws ArgumentException If either the short ID or long ID for the
- * argument conflicts with that of another
- * argument already associated with this
- * subcommand.
- */
- public void addArgument(Argument argument)
- throws ArgumentException
- {
- String argumentName = argument.getName();
- for (Argument a : arguments)
- {
- if (argumentName.equals(a.getName()))
- {
- LocalizableMessage message =
- ERR_ARG_SUBCOMMAND_DUPLICATE_ARGUMENT_NAME.get(name, argumentName);
- throw new ArgumentException(message);
- }
- }
-
- if (parser.hasGlobalArgument(argumentName))
- {
- LocalizableMessage message =
- ERR_ARG_SUBCOMMAND_ARGUMENT_GLOBAL_CONFLICT.get(argumentName, name);
- throw new ArgumentException(message);
- }
-
-
- Character shortID = argument.getShortIdentifier();
- if (shortID != null)
- {
- if (shortIDMap.containsKey(shortID))
- {
- throw new ArgumentException(ERR_ARG_SUBCOMMAND_DUPLICATE_SHORT_ID.get(
- argumentName, name, shortID, shortIDMap.get(shortID).getName()));
- }
-
- Argument arg = parser.getGlobalArgumentForShortID(shortID);
- if (arg != null)
- {
- throw new ArgumentException(ERR_ARG_SUBCOMMAND_ARGUMENT_SHORT_ID_GLOBAL_CONFLICT.get(
- argumentName, name, shortID, arg.getName()));
- }
- }
-
-
- String longID = argument.getLongIdentifier();
- if (longID != null)
- {
- if (! parser.longArgumentsCaseSensitive())
- {
- longID = toLowerCase(longID);
- }
-
- if (longIDMap.containsKey(longID))
- {
- LocalizableMessage message = ERR_ARG_SUBCOMMAND_DUPLICATE_LONG_ID.get(
- argumentName, name, argument.getLongIdentifier(),
- longIDMap.get(longID).getName());
- throw new ArgumentException(message);
- }
-
- Argument arg = parser.getGlobalArgumentForLongID(longID);
- if (arg != null)
- {
- LocalizableMessage message = ERR_ARG_SUBCOMMAND_ARGUMENT_LONG_ID_GLOBAL_CONFLICT.
- get(argumentName, name, argument.getLongIdentifier(),
- arg.getName());
- throw new ArgumentException(message);
- }
- }
-
-
- arguments.add(argument);
-
- if (shortID != null)
- {
- shortIDMap.put(shortID, argument);
- }
-
- if (longID != null)
- {
- longIDMap.put(longID, argument);
- }
- }
-
-
-
- /**
- * Indicates whether this sub-command will allow unnamed trailing
- * arguments. These will be arguments at the end of the list that
- * are not preceded by either a long or short identifier and will
- * need to be manually parsed by the application using this parser.
- * Note that once an unnamed trailing argument has been identified,
- * all remaining arguments will be classified as such.
- *
- * @return <CODE>true</CODE> if this sub-command allows unnamed
- * trailing arguments, or <CODE>false</CODE> if it does
- * not.
- */
- public boolean allowsTrailingArguments()
- {
- return allowsTrailingArguments;
- }
-
-
-
- /**
- * Retrieves the minimum number of unnamed trailing arguments that
- * must be provided.
- *
- * @return The minimum number of unnamed trailing arguments that
- * must be provided, or a value less than or equal to zero
- * if no minimum will be enforced.
- */
- public int getMinTrailingArguments()
- {
- return minTrailingArguments;
- }
-
-
-
- /**
- * Retrieves the maximum number of unnamed trailing arguments that
- * may be provided.
- *
- * @return The maximum number of unnamed trailing arguments that may
- * be provided, or a value less than or equal to zero if no
- * maximum will be enforced.
- */
- public int getMaxTrailingArguments()
- {
- return maxTrailingArguments;
- }
-
-
-
- /**
- * Retrieves the trailing arguments display name.
- *
- * @return Returns the trailing arguments display name.
- */
- public String getTrailingArgumentsDisplayName()
- {
- return trailingArgsDisplayName;
- }
-
-
-
- /**
- * Retrieves the set of unnamed trailing arguments that were provided on the
- * command line.
- *
- * @return The set of unnamed trailing arguments that were provided on the
- * command line.
- */
- public ArrayList<String> getTrailingArguments()
- {
- return parser.getTrailingArguments();
- }
-
- /**
- * Indicates whether this subcommand should be hidden from the usage
- * information.
- *
- * @return <CODE>true</CODE> if this subcommand should be hidden
- * from the usage information, or <CODE>false</CODE> if
- * not.
- */
- public boolean isHidden()
- {
- return isHidden;
- }
-
-
-
- /**
- * Specifies whether this subcommand should be hidden from the usage
- * information.
- *
- * @param isHidden
- * Indicates whether this subcommand should be hidden from
- * the usage information.
- */
- public void setHidden(boolean isHidden)
- {
- this.isHidden = isHidden;
- }
-}
-
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/args/SubCommandArgumentParser.java b/opendj3-server-dev/src/server/org/opends/server/util/args/SubCommandArgumentParser.java
deleted file mode 100644
index 289af42..0000000
--- a/opendj3-server-dev/src/server/org/opends/server/util/args/SubCommandArgumentParser.java
+++ /dev/null
@@ -1,1880 +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 2006-2010 Sun Microsystems, Inc.
- * Portions Copyright 2011-2014 ForgeRock AS
- */
-package org.opends.server.util.args;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.*;
-
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-import org.opends.server.util.SetupUtils;
-
-import static org.opends.messages.UtilityMessages.*;
-import static org.opends.server.tools.ToolConstants.*;
-import static org.opends.server.util.ServerConstants.*;
-import static org.opends.server.util.StaticUtils.*;
-
-/**
- * This class defines a variant of the argument parser that can be used with
- * applications that use subcommands to customize their behavior and that have a
- * different set of options per subcommand (e.g, "cvs checkout" takes different
- * options than "cvs commit"). This parser also has the ability to use global
- * options that will always be applicable regardless of the subcommand in
- * addition to the subcommand-specific arguments. There must not be any
- * conflicts between the global options and the option for any subcommand, but
- * it is allowed to re-use subcommand-specific options for different purposes
- * between different subcommands.
- */
-public class SubCommandArgumentParser extends ArgumentParser
-{
- /**
- * The argument that will be used to trigger the display of usage information.
- */
- private Argument usageArgument;
-
- /**
- * The arguments that will be used to trigger the display of usage information
- * for groups of sub-commands.
- */
- private final Map<Argument, Collection<SubCommand>> usageGroupArguments;
-
- /**
- * The set of unnamed trailing arguments that were provided for this parser.
- */
- private ArrayList<String> trailingArguments;
-
- /**
- * Indicates whether subcommand and long argument names should be treated in a
- * case-sensitive manner.
- */
- private final boolean longArgumentsCaseSensitive;
-
- /** Indicates whether the usage information has been displayed. */
- private boolean usageOrVersionDisplayed;
-
- /**
- * The set of global arguments defined for this parser, referenced by short
- * ID.
- */
- private final Map<Character, Argument> globalShortIDMap;
-
- /**
- * The set of global arguments defined for this parser, referenced by argument
- * name.
- */
- private final Map<String, Argument> globalArgumentMap;
-
- /**
- * The set of global arguments defined for this parser, referenced by long ID.
- */
- private final Map<String, Argument> globalLongIDMap;
-
- /**
- * The set of subcommands defined for this parser, referenced by subcommand
- * name.
- */
- private final SortedMap<String,SubCommand> subCommands;
-
- /** The total set of global arguments defined for this parser. */
- private final List<Argument> globalArgumentList;
-
- /** The output stream to which usage information should be printed. */
- private OutputStream usageOutputStream;
-
- /**
- * The fully-qualified name of the Java class that should be invoked to launch
- * the program with which this argument parser is associated.
- */
- private final String mainClassName;
-
- /**
- * A human-readable description for the tool, which will be included when
- * displaying usage information.
- */
- private final LocalizableMessage toolDescription;
-
- /** The raw set of command-line arguments that were provided. */
- private String[] rawArguments;
-
- /**
- * The subcommand requested by the user as part of the command-line arguments.
- */
- private SubCommand subCommand;
-
- /**Indicates whether the version argument was provided. */
- private boolean versionPresent;
-
- private static final String INDENT = " ";
- private static final int MAX_LENGTH = SetupUtils.isWindows() ? 79 : 80;
-
-
- /**
- * Creates a new instance of this subcommand argument parser with no
- * arguments.
- *
- * @param mainClassName The fully-qualified name of the Java
- * class that should be invoked to launch
- * the program with which this argument
- * parser is associated.
- * @param toolDescription A human-readable description for the
- * tool, which will be included when
- * displaying usage information.
- * @param longArgumentsCaseSensitive Indicates whether subcommand and long
- * argument names should be treated in a
- * case-sensitive manner.
- */
- public SubCommandArgumentParser(String mainClassName, LocalizableMessage toolDescription,
- boolean longArgumentsCaseSensitive)
- {
- super(mainClassName, toolDescription, longArgumentsCaseSensitive);
- this.mainClassName = mainClassName;
- this.toolDescription = toolDescription;
- this.longArgumentsCaseSensitive = longArgumentsCaseSensitive;
-
- trailingArguments = new ArrayList<String>();
- globalArgumentList = new LinkedList<Argument>();
- globalArgumentMap = new HashMap<String,Argument>();
- globalShortIDMap = new HashMap<Character,Argument>();
- globalLongIDMap = new HashMap<String,Argument>();
- usageGroupArguments = new HashMap<Argument, Collection<SubCommand>>();
- subCommands = new TreeMap<String,SubCommand>();
- usageOrVersionDisplayed = false;
- rawArguments = null;
- subCommand = null;
- usageArgument = null;
- usageOutputStream = null;
- }
-
-
-
- /**
- * Retrieves the fully-qualified name of the Java class that should be invoked
- * to launch the program with which this argument parser is associated.
- *
- * @return The fully-qualified name of the Java class that should be invoked
- * to launch the program with which this argument parser is
- * associated.
- */
- @Override
- public String getMainClassName()
- {
- return mainClassName;
- }
-
-
-
- /**
- * Retrieves a human-readable description for this tool, which should be
- * included at the top of the command-line usage information.
- *
- * @return A human-readable description for this tool, or {@code null} if
- * none is available.
- */
- @Override
- public LocalizableMessage getToolDescription()
- {
- return toolDescription;
- }
-
-
-
- /**
- * Indicates whether subcommand names and long argument strings should be
- * treated in a case-sensitive manner.
- *
- * @return <CODE>true</CODE> if subcommand names and long argument strings
- * should be treated in a case-sensitive manner, or
- * <CODE>false</CODE> if they should not.
- */
- public boolean longArgumentsCaseSensitive()
- {
- return longArgumentsCaseSensitive;
- }
-
-
-
- /**
- * Retrieves the list of all global arguments that have been defined for this
- * argument parser.
- *
- * @return The list of all global arguments that have been defined for this
- * argument parser.
- */
- public List<Argument> getGlobalArgumentList()
- {
- return globalArgumentList;
- }
-
-
-
- /**
- * Indicates whether this argument parser contains a global argument with the
- * specified name.
- *
- * @param argumentName The name for which to make the determination.
- *
- * @return <CODE>true</CODE> if a global argument exists with the specified
- * name, or <CODE>false</CODE> if not.
- */
- public boolean hasGlobalArgument(String argumentName)
- {
- return globalArgumentMap.containsKey(argumentName);
- }
-
-
-
- /**
- * Retrieves the global argument with the specified name.
- *
- * @param name The name of the global argument to retrieve.
- *
- * @return The global argument with the specified name, or <CODE>null</CODE>
- * if there is no such argument.
- */
- public Argument getGlobalArgument(String name)
- {
- return globalArgumentMap.get(name);
- }
-
-
-
- /**
- * Retrieves the set of global arguments mapped by the short identifier that
- * may be used to reference them. Note that arguments that do not have a
- * short identifier will not be present in this list.
- *
- * @return The set of global arguments mapped by the short identifier that
- * may be used to reference them.
- */
- public Map<Character, Argument> getGlobalArgumentsByShortID()
- {
- return globalShortIDMap;
- }
-
-
-
- /**
- * Indicates whether this argument parser has a global argument with the
- * specified short ID.
- *
- * @param shortID The short ID character for which to make the
- * determination.
- *
- * @return <CODE>true</CODE> if a global argument exists with the specified
- * short ID, or <CODE>false</CODE> if not.
- */
- public boolean hasGlobalArgumentWithShortID(Character shortID)
- {
- return globalShortIDMap.containsKey(shortID);
- }
-
-
-
- /**
- * Retrieves the global argument with the specified short identifier.
- *
- * @param shortID The short identifier for the global argument to retrieve.
- *
- * @return The global argument with the specified short identifier, or
- * <CODE>null</CODE> if there is no such argument.
- */
- public Argument getGlobalArgumentForShortID(Character shortID)
- {
- return globalShortIDMap.get(shortID);
- }
-
-
-
- /**
- * Retrieves the set of global arguments mapped by the long identifier that
- * may be used to reference them. Note that arguments that do not have a long
- * identifier will not be present in this list.
- *
- * @return The set of global arguments mapped by the long identifier that may
- * be used to reference them.
- */
- public Map<String, Argument> getGlobalArgumentsByLongID()
- {
- return globalLongIDMap;
- }
-
-
-
- /**
- * Indicates whether this argument parser has a global argument with the
- * specified long ID.
- *
- * @param longID The long ID string for which to make the determination.
- *
- * @return <CODE>true</CODE> if a global argument exists with the specified
- * long ID, or <CODE>false</CODE> if not.
- */
- public boolean hasGlobalArgumentWithLongID(String longID)
- {
- return globalLongIDMap.containsKey(longID);
- }
-
-
-
- /**
- * Retrieves the global argument with the specified long identifier.
- *
- * @param longID The long identifier for the global argument to retrieve.
- *
- * @return The global argument with the specified long identifier, or
- * <CODE>null</CODE> if there is no such argument.
- */
- public Argument getGlobalArgumentForLongID(String longID)
- {
- return globalLongIDMap.get(longID);
- }
-
-
-
- /**
- * Retrieves the set of subcommands defined for this argument parser,
- * referenced by subcommand name.
- *
- * @return The set of subcommands defined for this argument parser,
- * referenced by subcommand name.
- */
- public SortedMap<String,SubCommand> getSubCommands()
- {
- return subCommands;
- }
-
-
-
- /**
- * Indicates whether this argument parser has a subcommand with the specified
- * name.
- *
- * @param name The subcommand name for which to make the determination.
- *
- * @return <CODE>true</CODE> if this argument parser has a subcommand with
- * the specified name, or <CODE>false</CODE> if it does not.
- */
- public boolean hasSubCommand(String name)
- {
- return subCommands.containsKey(name);
- }
-
-
-
- /**
- * Retrieves the subcommand with the specified name.
- *
- * @param name The name of the subcommand to retrieve.
- *
- * @return The subcommand with the specified name, or <CODE>null</CODE> if no
- * such subcommand is defined.
- */
- public SubCommand getSubCommand(String name)
- {
- return subCommands.get(name);
- }
-
-
-
- /**
- * Retrieves the subcommand that was selected in the set of command-line
- * arguments.
- *
- * @return The subcommand that was selected in the set of command-line
- * arguments, or <CODE>null</CODE> if none was selected.
- */
- public SubCommand getSubCommand()
- {
- return subCommand;
- }
-
-
-
- /**
- * Retrieves the raw set of arguments that were provided.
- *
- * @return The raw set of arguments that were provided, or <CODE>null</CODE>
- * if the argument list has not yet been parsed.
- */
- @Override
- public String[] getRawArguments()
- {
- return rawArguments;
- }
-
-
-
- /**
- * Adds the provided argument to the set of global arguments handled by this
- * parser.
- *
- * @param argument The argument to be added.
- *
- * @throws ArgumentException If the provided argument conflicts with another
- * global or subcommand argument that has already
- * been defined.
- */
- public void addGlobalArgument(Argument argument)
- throws ArgumentException
- {
- addGlobalArgument(argument, null);
- }
-
-
- /**
- * Adds the provided argument to the set of global arguments handled by this
- * parser.
- *
- * @param argument The argument to be added.
- * @param group The argument group to which the argument belongs.
- * @throws ArgumentException If the provided argument conflicts with another
- * global or subcommand argument that has already
- * been defined.
- */
- public void addGlobalArgument(Argument argument, ArgumentGroup group)
- throws ArgumentException
- {
-
- String argumentName = argument.getName();
- if (globalArgumentMap.containsKey(argumentName))
- {
- LocalizableMessage message =
- ERR_SUBCMDPARSER_DUPLICATE_GLOBAL_ARG_NAME.get(argumentName);
- throw new ArgumentException(message);
- }
- for (SubCommand s : subCommands.values())
- {
- if (s.getArgumentForName(argumentName) != null)
- {
- LocalizableMessage message = ERR_SUBCMDPARSER_GLOBAL_ARG_NAME_SUBCMD_CONFLICT.get(
- argumentName, s.getName());
- throw new ArgumentException(message);
- }
- }
-
-
- Character shortID = argument.getShortIdentifier();
- if (shortID != null)
- {
- if (globalShortIDMap.containsKey(shortID))
- {
- String name = globalShortIDMap.get(shortID).getName();
- throw new ArgumentException(
- ERR_SUBCMDPARSER_DUPLICATE_GLOBAL_ARG_SHORT_ID.get(shortID, argumentName, name));
- }
-
- for (SubCommand s : subCommands.values())
- {
- if (s.getArgument(shortID) != null)
- {
- String cmdName = s.getName();
- String name = s.getArgument(shortID).getName();
-
- throw new ArgumentException(
- ERR_SUBCMDPARSER_GLOBAL_ARG_SHORT_ID_CONFLICT.get(shortID, argumentName, name, cmdName));
- }
- }
- }
-
-
- String longID = argument.getLongIdentifier();
- if (longID != null)
- {
- if (! longArgumentsCaseSensitive)
- {
- longID = toLowerCase(longID);
- }
-
- if (globalLongIDMap.containsKey(longID))
- {
- String name = globalLongIDMap.get(longID).getName();
-
- LocalizableMessage message = ERR_SUBCMDPARSER_DUPLICATE_GLOBAL_ARG_LONG_ID.get(
- argument.getLongIdentifier(), argumentName, name);
- throw new ArgumentException(message);
- }
-
- for (SubCommand s : subCommands.values())
- {
- if (s.getArgument(longID) != null)
- {
- String cmdName = s.getName();
- String name = s.getArgument(longID).getName();
-
- LocalizableMessage message = ERR_SUBCMDPARSER_GLOBAL_ARG_LONG_ID_CONFLICT.get(
- argument.getLongIdentifier(), argumentName, name, cmdName);
- throw new ArgumentException(message);
- }
- }
- }
-
-
- if (shortID != null)
- {
- globalShortIDMap.put(shortID, argument);
- }
-
- if (longID != null)
- {
- globalLongIDMap.put(longID, argument);
- }
-
- globalArgumentList.add(argument);
-
- if (group == null) {
- group = getStandardGroup(argument);
- }
- group.addArgument(argument);
- argumentGroups.add(group);
- }
-
- /**
- * Removes the provided argument from the set of global arguments handled by
- * this parser.
- *
- * @param argument The argument to be removed.
- */
- protected void removeGlobalArgument(Argument argument)
- {
- String argumentName = argument.getName();
- globalArgumentMap.remove(argumentName);
-
- Character shortID = argument.getShortIdentifier();
- if (shortID != null)
- {
- globalShortIDMap.remove(shortID);
- }
-
- String longID = argument.getLongIdentifier();
- if (longID != null)
- {
- if (! longArgumentsCaseSensitive)
- {
- longID = toLowerCase(longID);
- }
-
- globalLongIDMap.remove(longID);
- }
-
- globalArgumentList.remove(argument);
- }
-
-
- /**
- * Sets the provided argument as one which will automatically
- * trigger the output of full usage information if it is provided on
- * the command line and no further argument validation will be
- * performed.
- * <p>
- * If sub-command groups are defined using the
- * {@link #setUsageGroupArgument(Argument, Collection)} method, then
- * this usage argument, when specified, will result in usage
- * information being displayed which does not include information on
- * sub-commands.
- * <p>
- * Note that the caller will still need to add this argument to the
- * parser with the {@link #addGlobalArgument(Argument)} method, and
- * the argument should not be required and should not take a value.
- * Also, the caller will still need to check for the presence of the
- * usage argument after calling {@link #parseArguments(String[])} to
- * know that no further processing will be required.
- *
- * @param argument
- * The argument whose presence should automatically trigger
- * the display of full usage information.
- * @param outputStream
- * The output stream to which the usage information should
- * be written.
- */
- @Override
- public void setUsageArgument(Argument argument, OutputStream outputStream) {
- usageArgument = argument;
- usageOutputStream = outputStream;
-
- usageGroupArguments.put(argument, Collections.<SubCommand>emptySet());
- }
-
-
-
- /**
- * Sets the provided argument as one which will automatically
- * trigger the output of partial usage information if it is provided
- * on the command line and no further argument validation will be
- * performed.
- * <p>
- * Partial usage information will include a usage synopsis, a
- * summary of each of the sub-commands listed in the provided
- * sub-commands collection, and a summary of the global options.
- * <p>
- * Note that the caller will still need to add this argument to the
- * parser with the {@link #addGlobalArgument(Argument)} method, and
- * the argument should not be required and should not take a value.
- * Also, the caller will still need to check for the presence of the
- * usage argument after calling {@link #parseArguments(String[])} to
- * know that no further processing will be required.
- *
- * @param argument
- * The argument whose presence should automatically trigger
- * the display of partial usage information.
- * @param subCommands
- * The list of sub-commands which should have their usage
- * displayed.
- */
- public void setUsageGroupArgument(Argument argument,
- Collection<SubCommand> subCommands) {
- usageGroupArguments.put(argument, subCommands);
- }
-
-
- /**
- * Parses the provided set of arguments and updates the information associated
- * with this parser accordingly.
- *
- * @param rawArguments The raw set of arguments to parse.
- *
- * @throws ArgumentException If a problem was encountered while parsing the
- * provided arguments.
- */
- @Override
- public void parseArguments(String[] rawArguments)
- throws ArgumentException
- {
- parseArguments(rawArguments, null);
- }
-
- /**
- * Parses the provided set of arguments and updates the information associated
- * with this parser accordingly. Default values for unspecified arguments may
- * be read from the specified properties if any are provided.
- *
- * @param rawArguments The set of raw arguments to parse.
- * @param argumentProperties A set of properties that may be used to provide
- * default values for arguments not included in
- * the given raw arguments.
- *
- * @throws ArgumentException If a problem was encountered while parsing the
- * provided arguments.
- */
- @Override
- public void parseArguments(String[] rawArguments,
- Properties argumentProperties)
- throws ArgumentException
- {
- this.rawArguments = rawArguments;
- this.subCommand = null;
- this.trailingArguments = new ArrayList<String>();
- this.usageOrVersionDisplayed = false;
-
- boolean inTrailingArgs = false;
-
- int numArguments = rawArguments.length;
- for (int i=0; i < numArguments; i++)
- {
- final String arg = rawArguments[i];
-
- if (inTrailingArgs)
- {
- trailingArguments.add(arg);
-
- if (subCommand == null)
- {
- throw new ArgumentException(ERR_ARG_SUBCOMMAND_INVALID.get());
- }
-
- if (subCommand.getMaxTrailingArguments() > 0
- && trailingArguments.size() > subCommand.getMaxTrailingArguments())
- {
- LocalizableMessage message = ERR_ARGPARSER_TOO_MANY_TRAILING_ARGS.get(
- subCommand.getMaxTrailingArguments());
- throw new ArgumentException(message);
- }
-
- continue;
- }
-
- if (arg.equals("--"))
- {
- inTrailingArgs = true;
- }
- else if (arg.startsWith("--"))
- {
- // This indicates that we are using the long name to reference the
- // argument. It may be in any of the following forms:
- // --name
- // --name value
- // --name=value
-
- String argName = arg.substring(2);
- String argValue = null;
- int equalPos = argName.indexOf('=');
- if (equalPos < 0)
- {
- // This is fine. The value is not part of the argument name token.
- }
- else if (equalPos == 0)
- {
- // The argument starts with "--=", which is not acceptable.
- LocalizableMessage message = ERR_SUBCMDPARSER_LONG_ARG_WITHOUT_NAME.get(arg);
- throw new ArgumentException(message);
- }
- else
- {
- // The argument is in the form --name=value, so parse them both out.
- argValue = argName.substring(equalPos+1);
- argName = argName.substring(0, equalPos);
- }
-
- // If we're not case-sensitive, then convert the name to lowercase.
- String origArgName = argName;
- if (! longArgumentsCaseSensitive)
- {
- argName = toLowerCase(argName);
- }
-
- // See if the specified name references a global argument. If not, then
- // see if it references a subcommand argument.
- Argument a = globalLongIDMap.get(argName);
- if (a == null)
- {
- if (subCommand == null)
- {
- if (argName.equals(OPTION_LONG_HELP))
- {
- // "--help" will always be interpreted as requesting usage
- // information.
- getUsage(usageOutputStream);
- return;
- }
- else
- if (argName.equals(OPTION_LONG_PRODUCT_VERSION))
- {
- // "--version" will always be interpreted as requesting usage
- // information.
- versionPresent = true;
- usageOrVersionDisplayed = true ;
- printVersion();
- return;
- }
- else
- {
- // There is no such global argument.
- LocalizableMessage message =
- ERR_SUBCMDPARSER_NO_GLOBAL_ARGUMENT_FOR_LONG_ID.get(
- origArgName);
- throw new ArgumentException(message);
- }
- }
- else
- {
- a = subCommand.getArgument(argName);
- if (a == null)
- {
- if (argName.equals(OPTION_LONG_HELP))
- {
- // "--help" will always be interpreted as requesting usage
- // information.
- getUsage(usageOutputStream);
- return;
- }
- else
- if (argName.equals(OPTION_LONG_PRODUCT_VERSION))
- {
- // "--version" will always be interpreted as requesting usage
- // information.
- versionPresent = true;
- usageOrVersionDisplayed = true ;
- printVersion();
- return;
- }
- else
- {
- // There is no such global or subcommand argument.
- LocalizableMessage message =
- ERR_SUBCMDPARSER_NO_ARGUMENT_FOR_LONG_ID.get(origArgName);
- throw new ArgumentException(message);
- }
- }
- }
- }
-
- a.setPresent(true);
-
- // If this is a usage argument, then immediately stop and print
- // usage information.
- if (usageGroupArguments.containsKey(a))
- {
- getUsage(a, usageOutputStream);
- return;
- }
-
- // See if the argument takes a value. If so, then make sure one was
- // provided. If not, then make sure none was provided.
- if (a.needsValue())
- {
- if (argValue == null)
- {
- if ((i+1) == numArguments)
- {
- LocalizableMessage message =
- ERR_SUBCMDPARSER_NO_VALUE_FOR_ARGUMENT_WITH_LONG_ID.
- get(argName);
- throw new ArgumentException(message);
- }
-
- argValue = rawArguments[++i];
- }
-
- LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder();
- if (! a.valueIsAcceptable(argValue, invalidReason))
- {
- throw new ArgumentException(ERR_SUBCMDPARSER_VALUE_UNACCEPTABLE_FOR_LONG_ID
- .get(argValue, argName, invalidReason));
- }
-
- // If the argument already has a value, then make sure it is
- // acceptable to have more than one.
- if (a.hasValue() && !a.isMultiValued())
- {
- LocalizableMessage message =
- ERR_SUBCMDPARSER_NOT_MULTIVALUED_FOR_LONG_ID.get(origArgName);
- throw new ArgumentException(message);
- }
-
- a.addValue(argValue);
- }
- else
- {
- if (argValue != null)
- {
- LocalizableMessage message =
- ERR_SUBCMDPARSER_ARG_FOR_LONG_ID_DOESNT_TAKE_VALUE.get(
- origArgName);
- throw new ArgumentException(message);
- }
- }
- }
- else if (arg.startsWith("-"))
- {
- // This indicates that we are using the 1-character name to reference
- // the argument. It may be in any of the following forms:
- // -n
- // -nvalue
- // -n value
- if (arg.equals("-"))
- {
- LocalizableMessage message = ERR_SUBCMDPARSER_INVALID_DASH_AS_ARGUMENT.get();
- throw new ArgumentException(message);
- }
-
- char argCharacter = arg.charAt(1);
- String argValue;
- if (arg.length() > 2)
- {
- argValue = arg.substring(2);
- }
- else
- {
- argValue = null;
- }
-
-
- // Get the argument with the specified short ID. It may be either a
- // global argument or a subcommand-specific argument.
- Argument a = globalShortIDMap.get(argCharacter);
- if (a == null)
- {
- if (subCommand == null)
- {
- if (argCharacter == '?')
- {
- // "-?" will always be interpreted as requesting usage.
- getUsage(usageOutputStream);
- if (usageArgument != null)
- {
- usageArgument.setPresent(true);
- }
- return;
- }
- else
- if (argCharacter == OPTION_SHORT_PRODUCT_VERSION)
- {
- // "-V" will always be interpreted as requesting
- // version information except if it's already defined.
- if (dashVAccepted())
- {
- usageOrVersionDisplayed = true;
- versionPresent = true;
- printVersion();
- return;
- }
- else
- {
- // -V is defined in another subcommand, so we can
- // accepted it as the version information argument
- throw new ArgumentException(
- ERR_SUBCMDPARSER_NO_GLOBAL_ARGUMENT_FOR_SHORT_ID.get(argCharacter));
- }
- }
- else
- {
- // There is no such argument registered.
- throw new ArgumentException(
- ERR_SUBCMDPARSER_NO_GLOBAL_ARGUMENT_FOR_SHORT_ID.get(argCharacter));
- }
- }
- else
- {
- a = subCommand.getArgument(argCharacter);
- if (a == null)
- {
- if (argCharacter == '?')
- {
- // "-?" will always be interpreted as requesting usage.
- getUsage(usageOutputStream);
- return;
- }
- else
- if (argCharacter == OPTION_SHORT_PRODUCT_VERSION)
- {
- if (dashVAccepted())
- {
- usageOrVersionDisplayed = true;
- versionPresent = true;
- printVersion();
- return;
- }
- }
- else
- {
- // There is no such argument registered.
- throw new ArgumentException(
- ERR_SUBCMDPARSER_NO_ARGUMENT_FOR_SHORT_ID.get(argCharacter));
- }
- }
- }
- }
-
- a.setPresent(true);
-
- // If this is the usage argument, then immediately stop and print
- // usage information.
- if (usageGroupArguments.containsKey(a))
- {
- getUsage(a, usageOutputStream);
- return;
- }
-
- // See if the argument takes a value. If so, then make sure one was
- // provided. If not, then make sure none was provided.
- if (a.needsValue())
- {
- if (argValue == null)
- {
- if ((i+1) == numArguments)
- {
- throw new ArgumentException(
- ERR_SUBCMDPARSER_NO_VALUE_FOR_ARGUMENT_WITH_SHORT_ID.get(argCharacter));
- }
-
- argValue = rawArguments[++i];
- }
-
- LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder();
- if (! a.valueIsAcceptable(argValue, invalidReason))
- {
- throw new ArgumentException(ERR_SUBCMDPARSER_VALUE_UNACCEPTABLE_FOR_SHORT_ID.get(
- argValue, argCharacter, invalidReason));
- }
-
- // If the argument already has a value, then make sure it is
- // acceptable to have more than one.
- if (a.hasValue() && !a.isMultiValued())
- {
- throw new ArgumentException(ERR_SUBCMDPARSER_NOT_MULTIVALUED_FOR_SHORT_ID.get(argCharacter));
- }
-
- a.addValue(argValue);
- }
- else
- {
- if (argValue != null)
- {
- // If we've gotten here, then it means that we're in a scenario like
- // "-abc" where "a" is a valid argument that doesn't take a value.
- // However, this could still be valid if all remaining characters in
- // the value are also valid argument characters that don't take
- // values.
- int valueLength = argValue.length();
- for (int j=0; j < valueLength; j++)
- {
- char c = argValue.charAt(j);
- Argument b = globalShortIDMap.get(c);
- if (b == null)
- {
- if (subCommand == null)
- {
- throw new ArgumentException(
- ERR_SUBCMDPARSER_NO_GLOBAL_ARGUMENT_FOR_SHORT_ID.get(argCharacter));
- }
- else
- {
- b = subCommand.getArgument(c);
- if (b == null)
- {
- throw new ArgumentException(
- ERR_SUBCMDPARSER_NO_ARGUMENT_FOR_SHORT_ID.get(argCharacter));
- }
- }
- }
-
- if (b.needsValue())
- {
- // This means we're in a scenario like "-abc" where b is a
- // valid argument that takes a value. We don't support that.
- throw new ArgumentException(
- ERR_SUBCMDPARSER_CANT_MIX_ARGS_WITH_VALUES.get(argCharacter, argValue, c));
- }
- else
- {
- b.setPresent(true);
-
- // If this is the usage argument, then immediately stop and
- // print usage information.
- if (usageGroupArguments.containsKey(b))
- {
- getUsage(b, usageOutputStream);
- return;
- }
- }
- }
- }
- }
- }
- else if (subCommand != null)
- {
- // It's not a short or long identifier and the sub-command has
- // already been specified, so it must be the first trailing argument.
- if (subCommand.allowsTrailingArguments())
- {
- trailingArguments.add(arg);
- inTrailingArgs = true;
- }
- else
- {
- // Trailing arguments are not allowed for this sub-command.
- LocalizableMessage message = ERR_ARGPARSER_DISALLOWED_TRAILING_ARGUMENT.get(arg);
- throw new ArgumentException(message);
- }
- }
- else
- {
- // It must be the sub-command.
- String nameToCheck = arg;
- if (! longArgumentsCaseSensitive)
- {
- nameToCheck = toLowerCase(arg);
- }
-
- SubCommand sc = subCommands.get(nameToCheck);
- if (sc == null)
- {
- LocalizableMessage message = ERR_SUBCMDPARSER_INVALID_ARGUMENT.get(arg);
- throw new ArgumentException(message);
- }
- else
- {
- subCommand = sc;
- }
- }
- }
-
- // If we have a sub-command and it allows trailing arguments and
- // there is a minimum number, then make sure at least that many
- // were provided.
- if (subCommand != null)
- {
- int minTrailingArguments = subCommand.getMinTrailingArguments();
- if (subCommand.allowsTrailingArguments() && minTrailingArguments > 0
- && trailingArguments.size() < minTrailingArguments)
- {
- LocalizableMessage message =
- ERR_ARGPARSER_TOO_FEW_TRAILING_ARGUMENTS.get(minTrailingArguments);
- throw new ArgumentException(message);
- }
- }
-
- // If we don't have the argumentProperties, try to load a properties file.
- if (argumentProperties == null)
- {
- argumentProperties = checkExternalProperties();
- }
-
- // Iterate through all the global arguments
- normalizeArguments(argumentProperties, globalArgumentList);
-
- // Iterate through all the subcommand-specific arguments
- if (subCommand != null)
- {
- normalizeArguments(argumentProperties, subCommand.getArguments());
- }
- }
-
- private boolean dashVAccepted()
- {
- if (globalShortIDMap.containsKey(OPTION_SHORT_PRODUCT_VERSION))
- {
- return false;
- }
- for (SubCommand subCmd : subCommands.values())
- {
- if (subCmd.getArgument(OPTION_SHORT_PRODUCT_VERSION) != null)
- {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Appends usage information for the specified subcommand to the provided
- * buffer.
- *
- * @param buffer The buffer to which the usage information should be
- * appended.
- * @param subCommand The subcommand for which to display the usage
- * information.
- */
- public void getSubCommandUsage(LocalizableMessageBuilder buffer, SubCommand subCommand)
- {
- usageOrVersionDisplayed = true;
- String scriptName = System.getProperty(PROPERTY_SCRIPT_NAME);
- if (scriptName == null || scriptName.length() == 0)
- {
- scriptName = "java " + mainClassName;
- }
- buffer.append(INFO_ARGPARSER_USAGE.get());
- buffer.append(" ");
- buffer.append(scriptName);
-
- buffer.append(" ");
- buffer.append(subCommand.getName());
- buffer.append(" ").append(INFO_SUBCMDPARSER_OPTIONS.get());
- if (subCommand.allowsTrailingArguments()) {
- buffer.append(' ');
- buffer.append(subCommand.getTrailingArgumentsDisplayName());
- }
- buffer.append(EOL);
- buffer.append(subCommand.getDescription());
- buffer.append(EOL);
-
- if ( ! globalArgumentList.isEmpty())
- {
- buffer.append(EOL);
- buffer.append(INFO_GLOBAL_OPTIONS.get());
- buffer.append(EOL);
- buffer.append(" ");
- buffer.append(INFO_GLOBAL_OPTIONS_REFERENCE.get(scriptName));
- buffer.append(EOL);
- }
-
- if ( ! subCommand.getArguments().isEmpty() )
- {
- buffer.append(EOL);
- buffer.append(INFO_SUBCMD_OPTIONS.get());
- buffer.append(EOL);
- }
- for (Argument a : subCommand.getArguments())
- {
- // If this argument is hidden, then skip it.
- if (a.isHidden())
- {
- continue;
- }
-
-
- // Write a line with the short and/or long identifiers that may be used
- // for the argument.
- Character shortID = a.getShortIdentifier();
- String longID = a.getLongIdentifier();
- if (shortID != null)
- {
- int currentLength = buffer.length();
-
- if (a.equals(usageArgument))
- {
- buffer.append("-?, ");
- }
-
- buffer.append("-");
- buffer.append(shortID.charValue());
-
- if (a.needsValue() && longID == null)
- {
- buffer.append(" ");
- buffer.append(a.getValuePlaceholder());
- }
-
- if (longID != null)
- {
- StringBuilder newBuffer = new StringBuilder();
- newBuffer.append(", --");
- newBuffer.append(longID);
-
- if (a.needsValue())
- {
- newBuffer.append(" ");
- newBuffer.append(a.getValuePlaceholder());
- }
-
- int lineLength = (buffer.length() - currentLength) +
- newBuffer.length();
- if (lineLength > MAX_LENGTH)
- {
- buffer.append(EOL);
- }
- buffer.append(newBuffer.toString());
- }
-
- buffer.append(EOL);
- }
- else
- {
- if (longID != null)
- {
- if (a.equals(usageArgument))
- {
- buffer.append("-?, ");
- }
- buffer.append("--");
- buffer.append(longID);
-
- if (a.needsValue())
- {
- buffer.append(" ");
- buffer.append(a.getValuePlaceholder());
- }
-
- buffer.append(EOL);
- }
- }
-
-
- indentAndWrap2(INDENT, a.getDescription(), buffer);
- if (a.needsValue()
- && a.getDefaultValue() != null
- && a.getDefaultValue().length() > 0)
- {
- indentAndWrap2(INDENT, INFO_ARGPARSER_USAGE_DEFAULT_VALUE.get(a
- .getDefaultValue()), buffer);
- }
- }
- }
-
- /**
- * Write one or more lines with the description of the argument. We will
- * indent the description five characters and try our best to wrap at or
- * before column 79 so it will be friendly to 80-column displays.
- * <p>
- * FIXME Try to merge with #indentAndWrap(LocalizableMessage, LocalizableMessage, LocalizableMessageBuilder).
- */
- private void indentAndWrap2(String indent, LocalizableMessage text,
- LocalizableMessageBuilder buffer)
- {
- int actualSize = MAX_LENGTH - indent.length() - 1;
- if (text.length() <= actualSize)
- {
- buffer.append(indent);
- buffer.append(text);
- buffer.append(EOL);
- }
- else
- {
- String s = text.toString();
- while (s.length() > actualSize)
- {
- int spacePos = s.lastIndexOf(' ', actualSize);
- if (spacePos > 0)
- {
- buffer.append(indent);
- buffer.append(s.substring(0, spacePos).trim());
- s = s.substring(spacePos + 1).trim();
- buffer.append(EOL);
- }
- else
- {
- // There are no spaces in the first 74 columns.
- // See if there is one after that point.
- // If so, then break there. If not, then don't break at all.
- spacePos = s.indexOf(' ');
- if (spacePos > 0)
- {
- buffer.append(indent);
- buffer.append(s.substring(0, spacePos).trim());
- s = s.substring(spacePos + 1).trim();
- buffer.append(EOL);
- }
- else
- {
- buffer.append(indent);
- buffer.append(s);
- s = "";
- buffer.append(EOL);
- }
- }
- }
-
- if (s.length() > 0)
- {
- buffer.append(indent);
- buffer.append(s);
- buffer.append(EOL);
- }
- }
- }
-
- /**
- * Retrieves a string containing usage information based on the defined
- * arguments.
- *
- * @return A string containing usage information based on the defined
- * arguments.
- */
- @Override
- public String getUsage()
- {
- LocalizableMessageBuilder buffer = new LocalizableMessageBuilder();
-
- if (subCommand == null) {
- if (System.getProperty("org.forgerock.opendj.gendoc") != null) {
- // Generate reference documentation for dsconfig subcommands
- for (SubCommand s : subCommands.values()) {
- buffer.append(toRefSect2(s));
- }
- } else if (usageGroupArguments.size() > 1) {
- // We have sub-command groups, so don't display any
- // sub-commands by default.
- getFullUsage(Collections.<SubCommand> emptySet(), true, buffer);
- } else {
- // No grouping, so display all sub-commands.
- getFullUsage(subCommands.values(), true, buffer);
- }
- } else {
- getSubCommandUsage(buffer, subCommand);
- }
-
- return buffer.toMessage().toString();
- }
-
-
-
- /**
- * Retrieves a string describing how the user can get more help.
- *
- * @return A string describing how the user can get more help.
- */
- public LocalizableMessage getHelpUsageReference()
- {
- usageOrVersionDisplayed = true;
- String scriptName = System.getProperty(PROPERTY_SCRIPT_NAME);
- if (scriptName == null || scriptName.length() == 0)
- {
- scriptName = "java " + mainClassName;
- }
-
- LocalizableMessageBuilder buffer = new LocalizableMessageBuilder();
- buffer.append(INFO_GLOBAL_HELP_REFERENCE.get(scriptName));
- buffer.append(EOL);
- return buffer.toMessage();
- }
-
-
-
- /**
- * Retrieves the set of unnamed trailing arguments that were
- * provided on the command line.
- *
- * @return The set of unnamed trailing arguments that were provided
- * on the command line.
- */
- @Override
- public ArrayList<String> getTrailingArguments()
- {
- return trailingArguments;
- }
-
-
-
- /**
- * Indicates whether the usage information has been displayed to the end user
- * either by an explicit argument like "-H" or "--help", or by a built-in
- * argument like "-?".
- *
- * @return {@code true} if the usage information has been displayed, or
- * {@code false} if not.
- */
- @Override
- public boolean usageOrVersionDisplayed()
- {
- return usageOrVersionDisplayed;
- }
-
-
-
- /**
- * Adds the provided subcommand to this argument parser. This is only
- * intended for use by the <CODE>SubCommand</CODE> constructor and does not
- * do any validation of its own to ensure that there are no conflicts with the
- * subcommand or any of its arguments.
- *
- * @param subCommand The subcommand to add to this argument parser.
- */
- void addSubCommand(SubCommand subCommand)
- {
- subCommands.put(toLowerCase(subCommand.getName()), subCommand);
- }
-
-
-
- /** Get usage for a specific usage argument. */
- private void getUsage(Argument a, OutputStream outputStream) {
- LocalizableMessageBuilder buffer = new LocalizableMessageBuilder();
-
- if (a.equals(usageArgument) && subCommand != null) {
- getSubCommandUsage(buffer, subCommand);
- } else if (a.equals(usageArgument) && usageGroupArguments.size() <= 1) {
- // No groups - so display all sub-commands.
- getFullUsage(subCommands.values(), true, buffer);
- } else if (a.equals(usageArgument)) {
- // Using groups - so display all sub-commands group help.
- getFullUsage(Collections.<SubCommand> emptySet(), true, buffer);
- } else {
- // Requested help on specific group - don't display global
- // options.
- getFullUsage(usageGroupArguments.get(a), false, buffer);
- }
-
- try
- {
- outputStream.write(buffer.toString().getBytes());
- } catch (Exception e) {}
- }
-
-
- /** {@inheritDoc} */
- @Override
- public void getUsage(OutputStream outputStream)
- {
- try
- {
- outputStream.write(getUsage().getBytes());
- }
- catch (IOException e) {}
- }
-
-
-
- /**
- * Appends complete usage information for the specified set of sub-commands.
- */
- private void getFullUsage(Collection<SubCommand> c,
- boolean showGlobalOptions, LocalizableMessageBuilder buffer) {
- usageOrVersionDisplayed = true;
- if (toolDescription != null && toolDescription.length() > 0)
- {
- buffer.append(wrapText(toolDescription, MAX_LENGTH - 1));
- buffer.append(EOL);
- buffer.append(EOL);
- }
-
- String scriptName = System.getProperty(PROPERTY_SCRIPT_NAME);
- if (scriptName == null || scriptName.length() == 0)
- {
- scriptName = "java " + mainClassName;
- }
- buffer.append(INFO_ARGPARSER_USAGE.get());
- buffer.append(" ");
- buffer.append(scriptName);
-
- if (subCommands.isEmpty())
- {
- buffer.append(" ").append(INFO_SUBCMDPARSER_OPTIONS.get());
- }
- else
- {
- buffer.append(" ").append(INFO_SUBCMDPARSER_SUBCMD_AND_OPTIONS.get());
- }
-
- if (!subCommands.isEmpty())
- {
- buffer.append(EOL);
- buffer.append(EOL);
- if (c.isEmpty())
- {
- buffer.append(INFO_SUBCMDPARSER_SUBCMD_HELP_HEADING.get());
- }
- else
- {
- buffer.append(INFO_SUBCMDPARSER_SUBCMD_HEADING.get());
- }
- buffer.append(EOL);
- }
-
- if (c.isEmpty()) {
- // Display usage arguments (except the default one).
- for (Argument a : globalArgumentList) {
- if (a.isHidden()) {
- continue;
- }
-
- if (usageGroupArguments.containsKey(a)
- && !a.equals(usageArgument)) {
- printArgumentUsage(a, buffer);
- }
- }
- } else {
- boolean isFirst = true;
- for (SubCommand sc : c) {
- if (sc.isHidden()) {
- continue;
- }
- if (isFirst)
- {
- buffer.append(EOL);
- }
- buffer.append(sc.getName());
- buffer.append(EOL);
- indentAndWrap(LocalizableMessage.raw(INDENT), sc.getDescription(), buffer);
- buffer.append(EOL);
- isFirst = false;
- }
- }
-
- buffer.append(EOL);
-
- if (showGlobalOptions) {
- if (subCommands.isEmpty())
- {
- buffer.append(INFO_SUBCMDPARSER_WHERE_OPTIONS_INCLUDE.get());
- }
- else
- {
- buffer.append(INFO_SUBCMDPARSER_GLOBAL_HEADING.get());
- }
- buffer.append(EOL);
- buffer.append(EOL);
-
- boolean printGroupHeaders = printUsageGroupHeaders();
-
- // Display non-usage arguments.
- for (ArgumentGroup argGroup : argumentGroups)
- {
- if (argGroup.containsArguments() && printGroupHeaders)
- {
- // Print the groups description if any
- LocalizableMessage groupDesc = argGroup.getDescription();
- if (groupDesc != null && !LocalizableMessage.EMPTY.equals(groupDesc)) {
- buffer.append(EOL);
- buffer.append(wrapText(groupDesc.toString(), MAX_LENGTH - 1));
- buffer.append(EOL);
- buffer.append(EOL);
- }
- }
-
- for (Argument a : argGroup.getArguments()) {
- if (a.isHidden()) {
- continue;
- }
-
- if (!usageGroupArguments.containsKey(a)) {
- printArgumentUsage(a, buffer);
- }
- }
- }
-
- // Finally print default usage argument.
- if (usageArgument != null) {
- printArgumentUsage(usageArgument, buffer);
- } else {
- buffer.append("-?");
- }
- buffer.append(EOL);
- }
- }
-
-
-
- /**
- * Appends argument usage information to the provided buffer.
- *
- * @param a
- * The argument to handle.
- * @param buffer
- * The buffer to which the usage information should be
- * appended.
- */
- private void printArgumentUsage(Argument a, LocalizableMessageBuilder buffer) {
- String value;
- if (a.needsValue())
- {
- LocalizableMessage pHolder = a.getValuePlaceholder();
- if (pHolder == null)
- {
- value = " {value}";
- }
- else
- {
- value = " " + pHolder;
- }
- }
- else
- {
- value = "";
- }
-
- Character shortIDChar = a.getShortIdentifier();
- if (shortIDChar != null)
- {
- if (a.equals(usageArgument))
- {
- buffer.append("-?, ");
- }
- buffer.append("-");
- buffer.append(shortIDChar);
-
- String longIDString = a.getLongIdentifier();
- if (longIDString != null)
- {
- buffer.append(", --");
- buffer.append(longIDString);
- }
- buffer.append(value);
- }
- else
- {
- String longIDString = a.getLongIdentifier();
- if (longIDString != null)
- {
- if (a.equals(usageArgument))
- {
- buffer.append("-?, ");
- }
- buffer.append("--");
- buffer.append(longIDString);
- buffer.append(value);
- }
- }
-
- buffer.append(EOL);
-
- indentAndWrap(LocalizableMessage.raw(INDENT), a.getDescription(), buffer);
- if (a.needsValue()
- && a.getDefaultValue() != null
- && a.getDefaultValue().length() > 0)
- {
- indentAndWrap(LocalizableMessage.raw(INDENT),
- INFO_ARGPARSER_USAGE_DEFAULT_VALUE.get(a.getDefaultValue()),
- buffer);
- }
- }
-
-
-
- /**
- * Write one or more lines with the description of the argument. We will
- * indent the description five characters and try our best to wrap at or
- * before column 79 so it will be friendly to 80-column displays.
- */
- private void indentAndWrap(LocalizableMessage indent, LocalizableMessage text,
- LocalizableMessageBuilder buffer)
- {
- int actualSize = MAX_LENGTH - indent.length();
- if (text.length() <= actualSize)
- {
- buffer.append(indent);
- buffer.append(text);
- buffer.append(EOL);
- }
- else
- {
- String s = text.toString();
- while (s.length() > actualSize)
- {
- int spacePos = s.lastIndexOf(' ', actualSize);
- if (spacePos > 0)
- {
- buffer.append(indent);
- buffer.append(s.substring(0, spacePos).trim());
- s = s.substring(spacePos + 1).trim();
- buffer.append(EOL);
- }
- else
- {
- // There are no spaces in the first actualSize -1 columns.
- // See if there is one after that point.
- // If so, then break there. If not, then don't break at all.
- spacePos = s.indexOf(' ');
- if (spacePos > 0)
- {
- buffer.append(indent);
- buffer.append(s.substring(0, spacePos).trim());
- s = s.substring(spacePos + 1).trim();
- buffer.append(EOL);
- }
- else
- {
- buffer.append(indent);
- buffer.append(s);
- s = "";
- buffer.append(EOL);
- }
- }
- }
-
- if (s.length() > 0)
- {
- buffer.append(indent);
- buffer.append(s);
- buffer.append(EOL);
- }
- }
- }
-
- /**
- * Returns whether the usage argument was provided or not. This method
- * should be called after a call to parseArguments.
- * @return <CODE>true</CODE> if the usage argument was provided and
- * <CODE>false</CODE> otherwise.
- */
- @Override
- public boolean isUsageArgumentPresent()
- {
- return usageArgument != null && usageArgument.isPresent();
- }
-
- /**
- * Returns whether the version argument was provided or not. This method
- * should be called after a call to parseArguments.
- * @return <CODE>true</CODE> if the version argument was provided and
- * <CODE>false</CODE> otherwise.
- */
- @Override
- public boolean isVersionArgumentPresent()
- {
- return super.isVersionArgumentPresent() && !versionPresent;
- }
-
- /**
- * Generate reference documentation for dsconfig subcommands in DocBook 5 XML
- * format. As the number of categories is large, the subcommand entries are
- * sorted here by name for inclusion in a <refsect1> covering all
- * dsconfig Subcommands as part of the <refentry> for dsconfig (in
- * man-dsconfig.xml).
- * <p>
- * Although it would be possible to categorize subcommands in the same way as
- * they are categorized in dsconfig interactive mode, this generator does not
- * use the categories.
- * <p>
- * It would also be possible to generate the sort of information provided by
- * the configuration reference, such that this reference would not stop at
- * simply listing an option like --set {PROP:VAL}, but instead would also
- * provide the list of PROPs and their possible VALs. A future improvement
- * could no doubt merge the configuration reference with this content, though
- * perhaps the problem calls for hypertext rather than the linear structure
- * of a <refentry>.
- * <p>
- * Each individual subcommand results in a <refsect2> element similar
- * to the following.
- * <pre>
- <refsect2 xml:id="dsconfig-create-local-db-index">
- <title>dsconfig create-local-db-index</title>
- <para>Creates Local DB Indexes</para>
- <variablelist>
- <varlistentry>
- <term><option>--backend-name {name}
- </option></term>
- <listitem>
- <para>The name of the Local DB Backend</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>--index-name {OID}</option></term>
- <listitem>
- <para>The name of the new Local DB Index which will also be used
- as the value of the "attribute" property: Specifies the name
- of the attribute for which the index is to be maintained.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>--set {PROP:VALUE}</option></term>
- <listitem>
- <para>Assigns a value to a property where PROP is the name of the
- property and VALUE is the single value to be assigned. Specify the same
- property multiple times in order to assign more than one value to
- it</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refsect2>
- * </pre>
- * @param sc The SubCommand containing reference information.
- * @return Refsect2 representation of the subcommand.
- */
- private String toRefSect2(SubCommand sc)
- {
- final StringBuilder options = new StringBuilder();
- if (!sc.getArguments().isEmpty())
- {
- options.append(" <variablelist>").append(EOL);
- for (Argument a : sc.getArguments())
- {
- options.append(" <varlistentry>").append(EOL);
- options.append(" <term><option>");
- Character shortID = a.getShortIdentifier();
- if (shortID != null) options.append("-").append(shortID.charValue());
- String longID = a.getLongIdentifier();
- if (shortID != null && longID != null) options.append(" | ");
- if (longID != null) options.append("--").append(longID);
- if (a.needsValue()) options.append(" ").append(a.getValuePlaceholder());
- options.append("</option></term>").append(EOL);
- options.append(" <listitem>").append(EOL);
- options.append(" <para>");
- options.append(a.getDescription());
- options.append("</para>").append(EOL);
- options.append(" </listitem>").append(EOL);
- options.append(" </varlistentry>").append(EOL);
- }
- options.append(" </variablelist>").append(EOL);
- }
-
- return "<refsect2 xml:id=\"dsconfig-" + sc.getName() + "\">" + EOL +
- " <title>dsconfig " + sc.getName() + "</title>" + EOL +
- " <para>" + sc.getDescription() + "</para>" + EOL +
- options +
- "</refsect2>" + EOL;
- }
-}
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/cli/CommandBuilder.java b/opendj3-server-dev/src/server/org/opends/server/util/cli/CommandBuilder.java
index 96157bb..33a1840 100644
--- a/opendj3-server-dev/src/server/org/opends/server/util/cli/CommandBuilder.java
+++ b/opendj3-server-dev/src/server/org/opends/server/util/cli/CommandBuilder.java
@@ -22,6 +22,7 @@
*
*
* Copyright 2008-2009 Sun Microsystems, Inc.
+ * Portions Copyright 2014 ForgeRock AS
*/
package org.opends.server.util.cli;
@@ -31,9 +32,9 @@
import java.util.List;
import org.opends.server.util.SetupUtils;
-import org.opends.server.util.args.Argument;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.FileBasedArgument;
+import com.forgerock.opendj.cli.Argument;
+import com.forgerock.opendj.cli.BooleanArgument;
+import com.forgerock.opendj.cli.FileBasedArgument;
/**
* Class used to be able to generate the non interactive mode.
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/cli/ConsoleApplication.java b/opendj3-server-dev/src/server/org/opends/server/util/cli/ConsoleApplication.java
index 54b4795..743c34f 100644
--- a/opendj3-server-dev/src/server/org/opends/server/util/cli/ConsoleApplication.java
+++ b/opendj3-server-dev/src/server/org/opends/server/util/cli/ConsoleApplication.java
@@ -67,6 +67,7 @@
import org.opends.server.util.PasswordReader;
import org.opends.server.util.SetupUtils;
import org.opends.server.util.StaticUtils;
+import com.forgerock.opendj.cli.CLIException;
/**
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java b/opendj3-server-dev/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java
index f39bc6c..86582ac 100644
--- a/opendj3-server-dev/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java
+++ b/opendj3-server-dev/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java
@@ -40,7 +40,8 @@
import org.opends.server.tools.SSLConnectionFactory;
import org.opends.server.tools.SSLConnectionException;
import org.opends.server.admin.client.cli.SecureConnectionCliArgs;
-import org.opends.server.util.args.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentException;
+import com.forgerock.opendj.cli.CLIException;
import org.opends.server.util.SelectableCertificateKeyManager;
import org.opends.admin.ads.ADSContext;
import org.opends.admin.ads.util.ApplicationTrustManager;
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/cli/Menu.java b/opendj3-server-dev/src/server/org/opends/server/util/cli/Menu.java
index 5873a63..53fb9fa 100644
--- a/opendj3-server-dev/src/server/org/opends/server/util/cli/Menu.java
+++ b/opendj3-server-dev/src/server/org/opends/server/util/cli/Menu.java
@@ -22,9 +22,12 @@
*
*
* Copyright 2008 Sun Microsystems, Inc.
+ * Portions Copyright 2014 ForgeRock AS
*/
package org.opends.server.util.cli;
+import com.forgerock.opendj.cli.CLIException;
+
/**
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/cli/MenuBuilder.java b/opendj3-server-dev/src/server/org/opends/server/util/cli/MenuBuilder.java
index d068291..4724bec 100644
--- a/opendj3-server-dev/src/server/org/opends/server/util/cli/MenuBuilder.java
+++ b/opendj3-server-dev/src/server/org/opends/server/util/cli/MenuBuilder.java
@@ -43,6 +43,7 @@
import org.opends.server.util.table.TableBuilder;
import org.opends.server.util.table.TablePrinter;
import org.opends.server.util.table.TextTablePrinter;
+import com.forgerock.opendj.cli.CLIException;
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/cli/MenuCallback.java b/opendj3-server-dev/src/server/org/opends/server/util/cli/MenuCallback.java
index 5494a73..3fe42c1 100644
--- a/opendj3-server-dev/src/server/org/opends/server/util/cli/MenuCallback.java
+++ b/opendj3-server-dev/src/server/org/opends/server/util/cli/MenuCallback.java
@@ -21,10 +21,12 @@
* CDDL HEADER END
*
*
- * Copyright 2008 Sun Microsystems, Inc.
+ * Copyright 2008 Sun Microsystems
+ * Portions Copyright 2014 ForgeRock AS
*/
package org.opends.server.util.cli;
+import com.forgerock.opendj.cli.CLIException;
/**
@@ -48,4 +50,4 @@
* If the menu call-back fails for some reason.
*/
MenuResult<T> invoke(ConsoleApplication app) throws CLIException;
-}
+}
\ No newline at end of file
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/cli/ValidationCallback.java b/opendj3-server-dev/src/server/org/opends/server/util/cli/ValidationCallback.java
index 7b1893c..90a4bb7 100644
--- a/opendj3-server-dev/src/server/org/opends/server/util/cli/ValidationCallback.java
+++ b/opendj3-server-dev/src/server/org/opends/server/util/cli/ValidationCallback.java
@@ -22,9 +22,11 @@
*
*
* Copyright 2008 Sun Microsystems, Inc.
+ * Portions Copyright 2014 ForgeRock AS
*/
package org.opends.server.util.cli;
+import com.forgerock.opendj.cli.CLIException;
/**
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/admin/client/cli/CliTest.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/admin/client/cli/CliTest.java
index d7d4089..9754fa4 100755
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/admin/client/cli/CliTest.java
+++ b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/admin/client/cli/CliTest.java
@@ -32,7 +32,7 @@
import org.testng.annotations.*;
import org.opends.admin.ads.ADSContext.ServerGroupProperty;
import org.opends.admin.ads.ADSContextException.ErrorType;
-import org.opends.server.util.args.ArgumentException;
+import com.forgerock.opendj.cli.ArgumentException;
import org.opends.server.DirectoryServerTestCase;
import static org.opends.messages.AdminMessages.*;
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/util/args/ArgsTestCase.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/util/args/ArgsTestCase.java
deleted file mode 100644
index 487db43..0000000
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/util/args/ArgsTestCase.java
+++ /dev/null
@@ -1,41 +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 2006-2008 Sun Microsystems, Inc.
- */
-package org.opends.server.util.args;
-
-
-
-import org.opends.server.DirectoryServerTestCase;
-import org.testng.annotations.Test;
-
-
-
-/**
- * An abstract class that all args unit tests should extend.
- */
-@Test(groups = { "precommit", "util" }, sequential = true)
-public abstract class ArgsTestCase extends DirectoryServerTestCase {
- // No implementation required.
-}
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/util/args/TestSubCommand.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/util/args/TestSubCommand.java
deleted file mode 100644
index 2efe651..0000000
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/util/args/TestSubCommand.java
+++ /dev/null
@@ -1,297 +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.args;
-
-
-
-import java.util.Arrays;
-
-import org.testng.Assert;
-import org.testng.annotations.Test;
-import org.forgerock.i18n.LocalizableMessage;
-
-
-/**
- * Unit tests for the SubCommand class.
- */
-public final class TestSubCommand extends ArgsTestCase {
-
- /**
- * Tests that allowsTrailingArguments works correctly.
- *
- * @throws Exception
- * If an unexpected problem occurred.
- */
- @Test
- public void testAllowsTrailingArgumentsFalse1() throws Exception {
- SubCommandArgumentParser parser = new SubCommandArgumentParser(this
- .getClass().getName(), LocalizableMessage.raw("test description"), true);
- SubCommand sc = new SubCommand(parser, "sub-command1", LocalizableMessage.raw("XXX"));
- Assert.assertFalse(sc.allowsTrailingArguments());
- }
-
-
-
- /**
- * Tests that allowsTrailingArguments works correctly.
- *
- * @throws Exception
- * If an unexpected problem occurred.
- */
- @Test
- public void testAllowsTrailingArgumentsFalse2() throws Exception {
- SubCommandArgumentParser parser = new SubCommandArgumentParser(this
- .getClass().getName(), LocalizableMessage.raw("test description"), true);
- SubCommand sc = new SubCommand(parser, "sub-command2", false, 0, 0, null,
- LocalizableMessage.raw("XXX"));
- Assert.assertFalse(sc.allowsTrailingArguments());
- }
-
-
-
- /**
- * Tests that allowsTrailingArguments works correctly.
- *
- * @throws Exception
- * If an unexpected problem occurred.
- */
- @Test
- public void testAllowsTrailingArgumentsTrue() throws Exception {
- SubCommandArgumentParser parser = new SubCommandArgumentParser(this
- .getClass().getName(), LocalizableMessage.raw("test description"), true);
- SubCommand sc = new SubCommand(parser, "sub-command2", true, 2, 4,
- "args1 arg2 [arg3 arg4]", LocalizableMessage.raw("XXX"));
- Assert.assertTrue(sc.allowsTrailingArguments());
- }
-
-
-
- /**
- * Tests that getMaxTrailingArguments works correctly.
- *
- * @throws Exception
- * If an unexpected problem occurred.
- */
- @Test
- public void testGetMaxTrailingArguments1() throws Exception {
- SubCommandArgumentParser parser = new SubCommandArgumentParser(this
- .getClass().getName(), LocalizableMessage.raw("test description"), true);
- SubCommand sc = new SubCommand(parser, "sub-command1", LocalizableMessage.raw("XXX"));
- Assert.assertEquals(sc.getMaxTrailingArguments(), 0);
- }
-
-
-
- /**
- * Tests that getMaxTrailingArguments works correctly.
- *
- * @throws Exception
- * If an unexpected problem occurred.
- */
- @Test
- public void testGetMaxTrailingArguments2() throws Exception {
- SubCommandArgumentParser parser = new SubCommandArgumentParser(this
- .getClass().getName(), LocalizableMessage.raw("test description"), true);
- SubCommand sc = new SubCommand(parser, "sub-command2", false, 0, 0, null,
- LocalizableMessage.raw("XXX"));
- Assert.assertEquals(sc.getMaxTrailingArguments(), 0);
- }
-
-
-
- /**
- * Tests that getMaxTrailingArguments works correctly.
- *
- * @throws Exception
- * If an unexpected problem occurred.
- */
- @Test
- public void testGetMaxTrailingArguments3() throws Exception {
- SubCommandArgumentParser parser = new SubCommandArgumentParser(this
- .getClass().getName(), LocalizableMessage.raw("test description"), true);
- SubCommand sc = new SubCommand(parser, "sub-command2", true, 2, 4,
- "args1 arg2 [arg3 arg4]", LocalizableMessage.raw("XXX"));
- Assert.assertEquals(sc.getMaxTrailingArguments(), 4);
- }
-
-
-
- /**
- * Tests that getMinTrailingArguments works correctly.
- *
- * @throws Exception
- * If an unexpected problem occurred.
- */
- @Test
- public void testGetMinTrailingArguments1() throws Exception {
- SubCommandArgumentParser parser = new SubCommandArgumentParser(this
- .getClass().getName(), LocalizableMessage.raw("test description"), true);
- SubCommand sc = new SubCommand(parser, "sub-command1", LocalizableMessage.raw("XXX"));
- Assert.assertEquals(sc.getMinTrailingArguments(), 0);
- }
-
-
-
- /**
- * Tests that getMinTrailingArguments works correctly.
- *
- * @throws Exception
- * If an unexpected problem occurred.
- */
- @Test
- public void testGetMinTrailingArguments2() throws Exception {
- SubCommandArgumentParser parser = new SubCommandArgumentParser(this
- .getClass().getName(), LocalizableMessage.raw("test description"), true);
- SubCommand sc = new SubCommand(parser, "sub-command2", false, 0, 0, null,
- LocalizableMessage.raw("XXX"));
- Assert.assertEquals(sc.getMinTrailingArguments(), 0);
- }
-
-
-
- /**
- * Tests that getMinTrailingArguments works correctly.
- *
- * @throws Exception
- * If an unexpected problem occurred.
- */
- @Test
- public void testGetMinTrailingArguments3() throws Exception {
- SubCommandArgumentParser parser = new SubCommandArgumentParser(this
- .getClass().getName(), LocalizableMessage.raw("test description"), true);
- SubCommand sc = new SubCommand(parser, "sub-command2", true, 2, 4,
- "args1 arg2 [arg3 arg4]", LocalizableMessage.raw("XXX"));
- Assert.assertEquals(sc.getMinTrailingArguments(), 2);
- }
-
-
-
- /**
- * Tests that getTrailingArgumentsDisplayName works correctly.
- *
- * @throws Exception
- * If an unexpected problem occurred.
- */
- @Test
- public void testGetTrailingArgumentsDisplayName1() throws Exception {
- SubCommandArgumentParser parser = new SubCommandArgumentParser(this
- .getClass().getName(), LocalizableMessage.raw("test description"), true);
- SubCommand sc = new SubCommand(parser, "sub-command1", LocalizableMessage.raw("XXX"));
- Assert.assertNull(sc.getTrailingArgumentsDisplayName());
- }
-
-
-
- /**
- * Tests that getTrailingArgumentsDisplayName works correctly.
- *
- * @throws Exception
- * If an unexpected problem occurred.
- */
- @Test
- public void testGetTrailingArgumentsDisplayName2() throws Exception {
- SubCommandArgumentParser parser = new SubCommandArgumentParser(this
- .getClass().getName(), LocalizableMessage.raw("test description"), true);
- SubCommand sc = new SubCommand(parser, "sub-command2", false, 0, 0, null,
- LocalizableMessage.raw("XXX"));
- Assert.assertNull(sc.getTrailingArgumentsDisplayName());
- }
-
-
-
- /**
- * Tests that getTrailingArgumentsDisplayName works correctly.
- *
- * @throws Exception
- * If an unexpected problem occurred.
- */
- @Test
- public void testGetTrailingArgumentsDisplayName3() throws Exception {
- SubCommandArgumentParser parser = new SubCommandArgumentParser(this
- .getClass().getName(), LocalizableMessage.raw("test description"), true);
- SubCommand sc = new SubCommand(parser, "sub-command2", true, 2, 4,
- "args1 arg2 [arg3 arg4]", LocalizableMessage.raw("XXX"));
- Assert.assertEquals(sc.getTrailingArgumentsDisplayName(),
- "args1 arg2 [arg3 arg4]");
- }
-
-
-
- /**
- * Tests that getTrailingArguments works correctly.
- *
- * @throws Exception
- * If an unexpected problem occurred.
- */
- @Test
- public void testGetTrailingArguments1() throws Exception {
- SubCommandArgumentParser parser = new SubCommandArgumentParser(this
- .getClass().getName(), LocalizableMessage.raw("test description"), true);
- SubCommand sc = new SubCommand(parser, "sub-command1", LocalizableMessage.raw("XXX"));
- parser.parseArguments(new String[] { "sub-command1" });
- Assert.assertTrue(sc.getTrailingArguments().isEmpty());
- }
-
-
-
- /**
- * Tests that getTrailingArguments works correctly.
- *
- * @throws Exception
- * If an unexpected problem occurred.
- */
- @Test
- public void testGetTrailingArguments2() throws Exception {
- SubCommandArgumentParser parser = new SubCommandArgumentParser(this
- .getClass().getName(), LocalizableMessage.raw("test description"), true);
- SubCommand sc = new SubCommand(parser, "sub-command2", false, 0, 0, null,
- LocalizableMessage.raw("XXX"));
- parser.parseArguments(new String[] { "sub-command2" });
- Assert.assertTrue(sc.getTrailingArguments().isEmpty());
- }
-
-
-
- /**
- * Tests that getTrailingArguments works correctly.
- *
- * @throws Exception
- * If an unexpected problem occurred.
- */
- @Test
- public void testGetTrailingArguments3() throws Exception {
- SubCommandArgumentParser parser = new SubCommandArgumentParser(this
- .getClass().getName(), LocalizableMessage.raw("test description"), true);
- SubCommand sc = new SubCommand(parser, "sub-command2", true, 2, 4,
- "args1 arg2 [arg3 arg4]", LocalizableMessage.raw("XXX"));
- parser
- .parseArguments(new String[] { "sub-command2", "arg1", "arg2", "arg3" });
- Assert.assertEquals(sc.getTrailingArguments(), Arrays.asList(new String[] {
- "arg1", "arg2", "arg3" }));
- }
-
-}
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/util/args/TestSubCommandArgumentParser.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/util/args/TestSubCommandArgumentParser.java
deleted file mode 100644
index fb4a1cd..0000000
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/util/args/TestSubCommandArgumentParser.java
+++ /dev/null
@@ -1,170 +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.args;
-
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-import static org.opends.messages.ToolMessages.*;
-import org.forgerock.i18n.LocalizableMessage;
-
-
-/**
- * Unit tests for the SubCommand class.
- */
-public final class TestSubCommandArgumentParser extends ArgsTestCase {
-
- // The sub-command parser.
- private SubCommandArgumentParser parser;
-
- // First sub-command.
- private SubCommand sc1;
-
- // Second sub-command.
- private SubCommand sc2;
-
-
-
- /**
- * Create the sub-commands and parser.
- *
- * @throws Exception
- * If something unexpected happened.
- */
- @BeforeClass
- public void setup() throws Exception {
- parser = new SubCommandArgumentParser(this.getClass().getName(),
- LocalizableMessage.raw("test description"), true);
-
- sc1 = new SubCommand(parser, "sub-command1", INFO_BACKUPDB_DESCRIPTION_BACKEND_ID.get());
- sc2 = new SubCommand(parser, "sub-command2", true, 2, 4,
- "args1 arg2 [arg3 arg4]", INFO_BACKUPDB_DESCRIPTION_BACKUP_ALL.get());
- }
-
-
-
- /**
- * Test the getSubCommand method.
- *
- * @throws Exception
- * If something unexpected happened.
- */
- @Test
- public void testGetSubCommand() throws Exception {
- Assert.assertSame(parser.getSubCommand("sub-command1"), sc1);
- Assert.assertSame(parser.getSubCommand("sub-command2"), sc2);
- Assert.assertNull(parser.getSubCommand("sub-command3"));
- }
-
-
-
- /**
- * Provide valid command line args.
- *
- * @return Array of valid command line args.
- */
- @DataProvider(name = "validCommandLineArgs")
- public Object[][] createValidCommandLineArgs() {
- return new Object[][] {
- { new String[] {}, null },
- { new String[] { "sub-command1" }, sc1 },
- { new String[] { "sub-command2", "one", "two" }, sc2 },
- { new String[] { "sub-command2", "one", "two", "three" }, sc2 },
- { new String[] { "sub-command2", "one", "two", "three", "four" }, sc2 }, };
- }
-
-
-
- /**
- * Test the parseArguments method with valid args.
- *
- * @param args
- * The command line args.
- * @param sc
- * The expected sub-command.
- * @throws Exception
- * If something unexpected happened.
- */
- @Test(dataProvider = "validCommandLineArgs")
- public void testParseArgumentsWithValidArgs(String[] args, SubCommand sc)
- throws Exception {
- parser.parseArguments(args);
-
- // Check the correct sub-command was parsed.
- Assert.assertEquals(parser.getSubCommand(), sc);
-
- // Check that the trailing arguments were retrieved correctly and
- // in the right order.
- if (args.length > 1) {
- List<String> scargs = new ArrayList<String>();
- for (int i = 1; i < args.length; i++) {
- scargs.add(args[i]);
- }
- Assert.assertEquals(parser.getTrailingArguments(), scargs);
- } else {
- Assert.assertTrue(parser.getTrailingArguments().isEmpty());
- }
- }
-
-
-
- /**
- * Provide invalid command line args.
- *
- * @return Array of invalid command line args.
- */
- @DataProvider(name = "invalidCommandLineArgs")
- public Object[][] createInvalidCommandLineArgs() {
- return new Object[][] {
- { new String[] { "sub-command1", "one" } },
- { new String[] { "sub-command1", "one", "two" } },
- { new String[] { "sub-command2" } },
- { new String[] { "sub-command2", "one" } },
- { new String[] { "sub-command2", "one", "two", "three", "four", "five" } }, };
- }
-
-
-
- /**
- * Test the parseArguments method with invalid args.
- *
- * @param args
- * The command line args.
- * @throws Exception
- * If something unexpected happened.
- */
- @Test(dataProvider = "invalidCommandLineArgs", expectedExceptions = ArgumentException.class)
- public void testParseArgumentsWithInvalidArgs(String[] args) throws Exception {
- parser.parseArguments(args);
- }
-}
--
Gitblit v1.10.0