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

jvergara
03.23.2008 2b830a7f0d13ebbea86725fe27acf2d4b39aa0e1
Fix for issue 2994 (Java exception when ctrl-D in intercative upgrade command)

Handle the exception and limit the number of tries to provide a zip file to 5.
2 files modified
38 ■■■■ changed files
opends/src/quicksetup/org/opends/quicksetup/upgrader/BuildExtractorCliHelper.java 32 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/util/cli/ConsoleApplication.java 6 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/upgrader/BuildExtractorCliHelper.java
@@ -28,6 +28,8 @@
package org.opends.quicksetup.upgrader;
import static org.opends.messages.QuickSetupMessages.*;
import static org.opends.messages.UtilityMessages.*;
import org.opends.messages.Message;
import org.opends.quicksetup.UserDataException;
@@ -112,16 +114,32 @@
        if (choice == UPGRADE) {
          uud.setOperation(UpgradeUserData.Operation.UPGRADE);
          int nTries = 0;
          while(true) {
            String fileName = readInput(
                    INFO_UPGRADE_FILE_PROMPT.get(), null, LOG);
            try {
              uud.setInstallPackage(validateInstallPackFile(fileName));
              LOG.log(Level.INFO, "file specified interactively: " +
                      fileName);
              break;
            } catch (UserDataException ude) {
              System.out.println(ude.getMessage());
            if (fileName != null)
            {
              try {
                uud.setInstallPackage(validateInstallPackFile(fileName));
                LOG.log(Level.INFO, "file specified interactively: " +
                    fileName);
                break;
              } catch (UserDataException ude) {
                System.out.println(ude.getMessage());
              }
            }
            else
            {
              // There was an error reading the input: add a line return
              System.out.println();
            }
            nTries++;
            if (nTries >= CONFIRMATION_MAX_TRIES)
            {
              throw new UserDataException(null,
                  ERR_CONFIRMATION_TRIES_LIMIT_REACHED.get(
                      CONFIRMATION_MAX_TRIES));
            }
          }
        } else {
opends/src/server/org/opends/server/util/cli/ConsoleApplication.java
@@ -102,8 +102,10 @@
  // The output stream which this application should use.
  private final PrintStream out;
  // The maximum number of times we try to confirm.
  private final static int CONFIRMATION_MAX_TRIES = 5;
  /**
   *  The maximum number of times we try to confirm.
   */
  protected final static int CONFIRMATION_MAX_TRIES = 5;
  /**
   * Creates a new console application instance.