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

jvergara
11.07.2008 e1f1199702abbd0e8c953b872872090a7daad0a0
Fix for issue 3144 (Uninstall's exit status 0 (success) despite user error and Input tries limit reached (5)) and 3127 ( "uninstall --help" unclear message).

Do not use brackets to refer to command-line arguments.

Create a new error code for the CLI that specifies the case where the user provides invalid input.
8 files modified
130 ■■■■ changed files
opendj-sdk/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliArgumentParser.java 8 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliMain.java 2 ●●● patch | view | raw | blame | history
opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java 56 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallerArgumentParser.java 5 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/messages/messages/admin_tool.properties 40 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Launcher.java 4 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/QuickSetupCli.java 10 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ReturnCode.java 5 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliArgumentParser.java
@@ -354,8 +354,8 @@
      if (getBindPasswordAdmin() == null)
      {
        errors.add(ERR_REPLICATION_NO_ADMINISTRATOR_PASSWORD_PROVIDED.get(
            secureArgsList.bindPasswordArg.getLongIdentifier(),
                secureArgsList.bindPasswordFileArg.getLongIdentifier()));
            "--"+secureArgsList.bindPasswordArg.getLongIdentifier(),
            "--"+secureArgsList.bindPasswordFileArg.getLongIdentifier()));
      }
    }
@@ -591,7 +591,7 @@
    useSecondServerAsSchemaSourceArg = new BooleanArgument(
        "usesecondserverasschemasource", null, "useSecondServerAsSchemaSource",
        INFO_DESCRIPTION_ENABLE_REPLICATION_USE_SECOND_AS_SCHEMA_SOURCE.get(
            noSchemaReplicationArg.getLongIdentifier()));
            "--"+noSchemaReplicationArg.getLongIdentifier()));
    enableReplicationSubCmd = new SubCommand(this,
        ENABLE_REPLICATION_SUBCMD_NAME,
@@ -2152,7 +2152,7 @@
    if (quietArg.isPresent())
    {
      Message message = ERR_REPLICATION_STATUS_QUIET.get(
          STATUS_REPLICATION_SUBCMD_NAME, quietArg.getLongIdentifier());
          STATUS_REPLICATION_SUBCMD_NAME, "--"+quietArg.getLongIdentifier());
      addMessage(buf, message);
    }
  }
opendj-sdk/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliMain.java
@@ -481,7 +481,7 @@
          else
          {
            println(ERR_REPLICATION_VALID_SUBCOMMAND_NOT_FOUND.get(
                ToolConstants.OPTION_LONG_NO_PROMPT));
                "--"+ToolConstants.OPTION_LONG_NO_PROMPT));
            println(Message.raw(argParser.getUsage()));
            returnValue = ERROR_USER_DATA;
            subcommandLaunched = false;
opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
@@ -274,7 +274,7 @@
   * otherwise.
   */
  private boolean askWhatToDelete(UninstallUserData userData,
      Set<String> outsideDbs, Set<String> outsideLogs)
      Set<String> outsideDbs, Set<String> outsideLogs) throws UserDataException
  {
    boolean cancelled = false;
    final int REMOVE_ALL = 1;
@@ -322,13 +322,8 @@
    }
    catch (CLIException ce)
    {
      choice = REMOVE_ALL;
      cancelled = true;
      LOG.log(Level.WARNING, "Error reading input: "+ce, ce);
      if (ce.getMessageObject().getDescriptor().equals(ERR_TRIES_LIMIT_REACHED))
      {
        println(ce.getMessageObject());
      }
      throw new UserDataException(null, ce.getMessageObject(), ce);
    }
    if (cancelled)
@@ -389,9 +384,7 @@
        }
        catch (CLIException ce)
        {
          println(ce.getMessageObject());
          println();
          cancelled = true;
          throw new UserDataException(null, ce.getMessageObject(), ce);
        }
        if (!cancelled)
@@ -529,9 +522,7 @@
          }
          catch (CLIException ce)
          {
            println(ce.getMessageObject());
            println();
            cancelled = true;
            throw new UserDataException(null, ce.getMessageObject(), ce);
          }
        }
        else
@@ -589,9 +580,7 @@
          }
          catch (CLIException ce)
          {
            println(ce.getMessageObject());
            println();
            cancelled = true;
            throw new UserDataException(null, ce.getMessageObject(), ce);
          }
        }
        else
@@ -640,9 +629,7 @@
        }
        catch (CLIException ce)
        {
          println(ce.getMessageObject());
          println();
          cancelled = true;
          throw new UserDataException(null, ce.getMessageObject(), ce);
        }
      }
      else
@@ -658,9 +645,7 @@
          }
          catch (CLIException ce)
          {
            println(ce.getMessageObject());
            println();
            cancelled = true;
            throw new UserDataException(null, ce.getMessageObject(), ce);
          }
        }
      }
@@ -733,8 +718,11 @@
   *  to update the remote servers.
   *  @return <CODE>true</CODE> if the user wants to continue and update the
   *  remote servers.  <CODE>false</CODE> otherwise.
   *  @throws UserDataException if there is a problem with the information
   *  provided by the user.
   */
  private boolean askForAuthenticationIfNeeded(UninstallUserData userData)
  throws UserDataException
  {
    boolean accepted = true;
    String uid = userData.getAdminUID();
@@ -903,9 +891,7 @@
        }
        catch (CLIException ce)
        {
          println(ce.getMessageObject());
          println();
          accepted = false;
          throw new UserDataException(null, ce.getMessageObject(), ce);
        }
      }
    }
@@ -1170,18 +1156,19 @@
        if (forceOnError)
        {
          println(ERR_UNINSTALL_ERROR_UPDATING_REMOTE_FORCE.get(
              parser.getSecureArgsList().adminUidArg.getLongIdentifier(),
              ToolConstants.OPTION_LONG_BINDPWD,
              ToolConstants.OPTION_LONG_BINDPWD_FILE));
              "--"+parser.getSecureArgsList().adminUidArg.getLongIdentifier(),
              "--"+ToolConstants.OPTION_LONG_BINDPWD,
              "--"+ToolConstants.OPTION_LONG_BINDPWD_FILE));
        }
        else
        {
          throw new UserDataException(null,
              ERR_UNINSTALL_ERROR_UPDATING_REMOTE_NO_FORCE.get(
                  "--"+
                  parser.getSecureArgsList().adminUidArg.getLongIdentifier(),
                  ToolConstants.OPTION_LONG_BINDPWD,
                  ToolConstants.OPTION_LONG_BINDPWD_FILE,
                  parser.forceOnErrorArg.getLongIdentifier()));
                  "--"+ToolConstants.OPTION_LONG_BINDPWD,
                  "--"+ToolConstants.OPTION_LONG_BINDPWD_FILE,
                  "--"+parser.forceOnErrorArg.getLongIdentifier()));
        }
      }
      else
@@ -1194,8 +1181,7 @@
        }
        catch (CLIException ce)
        {
          println(ce.getMessageObject());
          accepted = false;
          throw new UserDataException(null, ce.getMessageObject(), ce);
        }
      }
    }
@@ -1303,9 +1289,7 @@
        }
        catch (CLIException ce)
        {
          println(ce.getMessageObject());
          println();
          returnValue = false;
          throw new UserDataException(null, ce.getMessageObject(), ce);
        }
      }
      else if (reloadTopologyCache)
opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallerArgumentParser.java
@@ -166,7 +166,7 @@
        'f',
        "forceOnError",
        INFO_UNINSTALLDS_DESCRIPTION_FORCE.get(
            noPromptArg.getLongIdentifier()));
            "--"+noPromptArg.getLongIdentifier()));
    args.add(forceOnErrorArg);
    quietArg = new BooleanArgument(
        OPTION_LONG_QUIET,
@@ -377,7 +377,8 @@
    if (!noPromptArg.isPresent() && forceOnErrorArg.isPresent())
    {
      Message message = ERR_UNINSTALL_FORCE_REQUIRES_NO_PROMPT.get(
          forceOnErrorArg.getLongIdentifier(), noPromptArg.getLongIdentifier());
          "--"+forceOnErrorArg.getLongIdentifier(),
          "--"+noPromptArg.getLongIdentifier());
      if (buf.length() > 0)
      {
        buf.append(EOL);
opendj-sdk/opends/src/messages/messages/admin_tool.properties
@@ -166,15 +166,15 @@
 to replicate some of its Base DNs.  There was an error retrieving the \
 references to it in the replicated servers.  Note that to be able to remove \
 remote references you must provide Global Administrator credentials using the \
 {%s} and {%s} (or {%s}) options.%nContinuing uninstall as we are \
 %s and %s (or %s) options.%nContinuing uninstall as we are \
 on force on error mode.
SEVERE_ERR_UNINSTALL_ERROR_UPDATING_REMOTE_NO_FORCE=This server is configured \
 to replicate some of its Base DNs.  There was an error retrieving the \
 references to it in the replicated servers.  Note that to be able to remove \
 remote references you must provide Global Administrator credentials using the \
 {%s} and {%s} (or {%s}) options.%nCheck that the connection parameters you \
 %s and %s (or %s) options.%nCheck that the connection parameters you \
 provided are correct.%nIf you want to uninstall the server even when remote \
 references cannot be removed, you can use the {%s} option.
 references cannot be removed, you can use the %s option.
MILD_ERR_UNINSTALL_NOT_UPDATE_REMOTE_PROMPT=This server is configured \
 to replicate some of its Base DNs.  There was an error retrieving the \
 references to it in the replicated servers.%nDo you want to continue?
@@ -366,7 +366,7 @@
INFO_UNKNOWN_LABEL=--
INFO_UNINSTALLDS_DESCRIPTION_FORCE=Specifies whether the uninstall should \
 continue if there is an error updating references to this server in remote \
 OpenDS instances or not.  This argument can only be used with the {%s} no \
 OpenDS instances or not.  This argument can only be used with the %s no \
 prompt argument.
INFO_DESCRIPTION_REFERENCED_HOST=The name of this host (or IP address) as \
 it is referenced in remote servers for replication
@@ -428,7 +428,7 @@
 schema between the servers
INFO_DESCRIPTION_ENABLE_REPLICATION_USE_SECOND_AS_SCHEMA_SOURCE=Use the second \
 server to initialize the schema of the first server.  If this option nor \
 option {%s} are specified the schema of the first server will be used to \
 option %s are specified the schema of the first server will be used to \
 initialize the schema of the second server
INFO_DESCRIPTION_ENABLE_REPLICATION_BINDPASSWORD2=Password \
 to use to bind to the second server whose contents will be replicated.  If no \
@@ -455,7 +455,7 @@
 replication.  Multiple base DNs can be provided by using this option multiple \
 times
INFO_DESCRIPTION_REPLICATION_ADMIN_UID=User ID of the \
 Global Administrator to use to bind to the server.  For the {%s} subcommand \
 Global Administrator to use to bind to the server.  For the '%s' subcommand \
 if no Global Administrator was defined previously for none of the server one \
 will be created using the provided data.
INFO_DESCRIPTION_REPLICATION_ADMIN_BINDPASSWORD=The global \
@@ -487,8 +487,8 @@
INFO_REPLICATION_TOOL_DESCRIPTION=This utility can be used to configure \
 replication between servers so that the data of the servers is synchronized.\
 For replication to work you must first to enable replication using the \
 {%s} subcommand and then initialize the contents of one of \
 the servers with the contents of the other using the {%s} subcommand.
 '%s' subcommand and then initialize the contents of one of \
 the servers with the contents of the other using the '%s' subcommand.
INFO_REPLICATION_DESCRIPTION_QUIET=Perform a quiet operation (no \
 progress information is written to the standard output)
INFO_DESCRIPTION_DISABLE_REPLICATION_BINDDN=DN to use to \
@@ -500,11 +500,11 @@
INFO_DESCRIPTION_SUBCMD_INITIALIZE_REPLICATION=Initialize the contents of the \
 data under the specified Base DN on the destination server with the contents \
 on the source server.  This operation is required after enabling replication \
 in order replication to work ({%s} can also be used for this purpose).
 in order replication to work ('%s' can also be used for this purpose).
INFO_DESCRIPTION_SUBCMD_INITIALIZE_ALL_REPLICATION=Initialize the contents of \
 the data under the specified Base DN on all the servers whose contents are \
 being replicated with the contents on the specified server.  This operation \
 is required after enabling replication in order replication to work ({%s} \
 is required after enabling replication in order replication to work ('%s' \
 applied to each server can also be used for this purpose).
INFO_DESCRIPTION_SUBCMD_PRE_EXTERNAL_INITIALIZATION=This subcommand must be \
 called before initializing the contents of all the replicated servers using \
@@ -512,13 +512,13 @@
 Base DNs that will be initialized and you must \
 provide the credentials of any of the servers that are being replicated.  \
 After calling this subcommand, initialize the contents of all the servers in \
 the topology, then call the subcommand {%s}.
 the topology, then call the subcommand '%s'.
INFO_DESCRIPTION_SUBCMD_POST_EXTERNAL_INITIALIZATION=This subcommand must be \
 called after initializing the contents of all the replicated servers using \
 the tool import-ldif or the binary copy method.  You \
 must specify the list of Base DNs that have been initialized and you must \
 provide the credentials of any of the servers that are being replicated.  See \
 the usage of the subcommand {%s} for more information.
 the usage of the subcommand '%s' for more information.
INFO_DESCRIPTION_SUBCMD_ENABLE_REPLICATION=Updates the configuration of the \
 servers to replicate the data under the specified Base DN.  If one of the \
 specified servers is already replicating the data under the Base DN with \
@@ -536,7 +536,7 @@
 DN in no interactive mode.
SEVERE_ERR_REPLICATION_NO_ADMINISTRATOR_PASSWORD_PROVIDED=You must provide the \
 password of the global administrator in non interactive mode.  You can \
 provide it using the {%s} or the {%s} options.
 provide it using the %s or the %s options.
SEVERE_ERR_REPLICATION_NOT_A_VALID_BASEDN=The provided value %s is not a valid \
 base DN.
SEVERE_ERR_REPLICATION_ENABLE_SAME_SERVER_PORT=You have to provide two \
@@ -551,16 +551,16 @@
SEVERE_ERR_REPLICATION_SAME_REPLICATION_PORT=You have provided the same \
 replication port (%s) for two servers located on the same machine (%s).
SEVERE_ERR_REPLICATION_VALID_SUBCOMMAND_NOT_FOUND=Could not find a valid \
 subcommand.  You must specify a subcommand when using the option {%s}.
SEVERE_ERR_REPLICATION_STATUS_QUIET=The {%s} subcommand is not compatible with \
 the {%s} argument.
 subcommand.  You must specify a subcommand when using the option %s.
SEVERE_ERR_REPLICATION_STATUS_QUIET=The '%s' subcommand is not compatible with \
 the %s argument.
INFO_REPLICATION_SUCCESSFUL=The operation has been successfully completed
INFO_REPLICATION_SUCCESSFUL_NOP=The operation has been successfully completed, \
 but no action was required
MILD_ERR_REPLICATION_USER_CANCELLED=User cancelled the operation
SEVERE_ERR_REPLICATION_NO_MESSAGE=
SEVERE_ERR_UNINSTALL_FORCE_REQUIRES_NO_PROMPT=The {%s} argument only can be \
 used when {%s} has been specified
SEVERE_ERR_UNINSTALL_FORCE_REQUIRES_NO_PROMPT=The %s argument only can be \
 used when %s has been specified
INFO_REPLICATION_ENABLE_ADMINISTRATOR_MUST_BE_CREATED=You must provide the \
credentials of the Global Administrator that will be used to manage the OpenDS \
instances that are being replicated.
@@ -771,13 +771,13 @@
INFO_PROGRESS_PRE_INITIALIZATION_LOCAL_FINISHED_PROCEDURE=Now you can proceed \
 to the initialization of the contents of the base DNs on server %s.  You can \
 use the command import-ldif or the binary copy to do so.%n%nWhen the \
 initialization is completed you must use the subcommand {%s} for replication \
 initialization is completed you must use the subcommand '%s' for replication \
 to work with the new base DNs.
INFO_PROGRESS_PRE_INITIALIZATION_FINISHED_PROCEDURE=Now you can proceed \
 to the initialization of the contents of the base DNs on all the replicated \
 servers.  You can use the command import-ldif or the binary copy to do \
 so.%n%nWhen the initialization is completed you must use the subcommand \
 {%s} for replication to work with the new base DNs contents.
 '%s' for replication to work with the new base DNs contents.
INFO_PROGRESS_POST_INITIALIZATION_FINISHED_PROCEDURE=Post initialization \
 procedure completed successfully.
SEVERE_ERR_POOLING_PRE_EXTERNAL_INITIALIZATION=Error reading the progress of \
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Launcher.java
@@ -300,6 +300,10 @@
    {
      System.exit(ReturnCode.CANCELLED.getReturnCode());
    }
    else if (returnValue.equals(ReturnCode.USER_INPUT_ERROR))
    {
      System.exit(ReturnCode.USER_INPUT_ERROR.getReturnCode());
    }
    return returnValue.getReturnCode();
  }
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/QuickSetupCli.java
@@ -33,6 +33,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 org.opends.messages.Message;
/**
@@ -134,7 +135,14 @@
      System.err.println(StaticUtils.wrapText(uude.getLocalizedMessage(),
              Utils.getCommandLineMaxLineWidth()));
      System.err.println();
      returnValue = ReturnCode.USER_DATA_ERROR;
      if (uude.getCause() instanceof CLIException)
      {
        returnValue = ReturnCode.USER_INPUT_ERROR;
      }
      else
      {
        returnValue = ReturnCode.USER_DATA_ERROR;
      }
    }
    return returnValue;
  }
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ReturnCode.java
@@ -106,6 +106,11 @@
  public static final ReturnCode JAVA_VERSION_INCOMPATIBLE = new ReturnCode(13);
  /**
   * Return code: user provided invalid input.
   */
  public static final ReturnCode USER_INPUT_ERROR = new ReturnCode(14);
  /**
   * Return code: Print Version.
   */
  public static final ReturnCode PRINT_VERSION = new ReturnCode(50);