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

kenneth_suter
26.51.2007 694ba2715a3d8c483b442eeb16b0d5fe40e0e28e
fixed serveral message formatting problems in the CLI and GUI
3 files modified
144 ■■■■ changed files
opends/src/quicksetup/org/opends/quicksetup/Launcher.java 3 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties 5 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java 136 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/Launcher.java
@@ -239,7 +239,8 @@
    if (shouldPrintUsage()) {
      printUsage();
    } else if (isCli()) {
      System.exit(launchCli(args, createCliApplication()));
      int exitCode = launchCli(args, createCliApplication());
      System.exit(exitCode);
    } else {
      willLaunchGui();
      int exitCode = launchGui(args);
opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
@@ -700,7 +700,7 @@
summary-upgrade-upgrading-components=Upgrading Components...
summary-upgrade-applying-schema-customization=Applying Schema \
  Customizations...
summary-upgrade-applying-config-customization=Applying Configuration\
summary-upgrade-applying-config-customization=Applying Configuration \
  Customizations...
summary-upgrade-verifying=Verifying Upgrade...
summary-upgrade-history=Recording Upgrade History...
@@ -709,6 +709,9 @@
summary-upgrade-finished-successfully=<b>OpenDS QuickSetup Completed \
  Successfully.</b><br>The OpenDS installation at {0} has now been upgraded \
  to version {1}.
summary-upgrade-finished-successfully-cli=OpenDS QuickSetup Completed \
  Successfully.  The OpenDS installation at {0} has now been upgraded \
  to version {1}.
summary-upgrade-finished-with-errors=Upgrade Finished with Errors
#
opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
@@ -93,10 +93,6 @@
    INITIALIZING("summary-upgrade-initializing"),
    STARTING_SERVER("summary-starting"),
    STOPPING_SERVER("summary-stopping"),
    CALCULATING_SCHEMA_CUSTOMIZATIONS(
            "summary-upgrade-calculating-schema-customization"),
@@ -300,7 +296,7 @@
   * {@inheritDoc}
   */
  public Integer getRatio(ProgressStep step) {
    return 100 * ((UpgradeProgressStep) step).ordinal() /
    return ((UpgradeProgressStep) step).ordinal() /
            EnumSet.allOf(UpgradeWizardStep.class).size();
  }
@@ -310,23 +306,12 @@
  public String getSummary(ProgressStep step) {
    String txt = null;
    if (step == UpgradeProgressStep.FINISHED) {
//    String installPath = Utils.getPath(getInstallation().getRootDirectory());
//    String newVersion = null;
//    try {
//      newVersion = getInstallation().getBuildId();
//    } catch (QuickSetupException e) {
//      newVersion = getMsg("upgrade-build-id-unknown");
//    }
//    String[] args = {
//            formatter.getFormattedText(installPath),
//            newVersion };
//    txt = getFormattedSuccess(
//            getMsg("summary-upgrade-finished-successfully",
//            args));
      txt = "Upgrade completed successfully"; // TODO BETTER MESSAGE
      txt = getFinalSuccessMessage();
    } else if (step == UpgradeProgressStep.FINISHED_WITH_ERRORS) {
      txt = getFormattedError(
              getMsg("summary-upgrade-finished-with-errors"));
      txt = getMsg(((UpgradeProgressStep) step).getSummaryMesssageKey());
      if (!Utils.isCli()) {
        txt = formatter.getFormattedError(txt, true);
      }
    } else {
      txt = getMsg(((UpgradeProgressStep) step).getSummaryMesssageKey());
    }
@@ -591,7 +576,8 @@
            }
          }
          getRemoteBuildManager().download(buildToDownload, buildZip);
          notifyListeners(formatter.getFormattedDone());
          notifyListeners(formatter.getFormattedDone() +
                  formatter.getLineBreak());
        } catch (ApplicationException e) {
          LOG.log(Level.INFO, "Error downloading build file", e);
          throw e;
@@ -621,17 +607,11 @@
        throw e;
      }
      try {
        setCurrentProgressStep(UpgradeProgressStep.INITIALIZING);
        initialize();
      } catch (ApplicationException e) {
        LOG.log(Level.INFO, "Error initializing upgrader", e);
        throw e;
      }
      // If the server has never been started and schema changes
      // have been made, the server will have never had the chance
      // to write schema.current.
      if (!getInstallation().getStatus().isServerRunning()) {
        try {
          setCurrentProgressStep(UpgradeProgressStep.STARTING_SERVER);
          startServerWithoutConnectionHandlers();
          getServerController().stopServerInProcess();
        } catch (ApplicationException e) {
@@ -643,7 +623,6 @@
      if (getInstallation().getStatus().isServerRunning()) {
        try {
          setCurrentProgressStep(UpgradeProgressStep.STOPPING_SERVER);
          new ServerController(this).stopServer();
        } catch (ApplicationException e) {
          LOG.log(Level.INFO, "Error stopping server", e);
@@ -690,12 +669,27 @@
        setCurrentProgressStep(
                UpgradeProgressStep.UPGRADING_COMPONENTS);
        upgradeComponents();
        notifyListeners(formatter.getFormattedDone() +
                formatter.getLineBreak());
      } catch (ApplicationException e) {
        LOG.log(Level.INFO,
                "Error upgrading components", e);
        throw e;
      }
      //********************************************
      //*  The two steps following this step require
      //*  the server to be started 'in process'.
      // *******************************************
      try {
        startServerWithoutConnectionHandlers();
      } catch (ApplicationException e) {
        LOG.log(Level.INFO,
                "Error starting server in process in order to apply custom" +
                        "schema and/or configuration", e);
        throw e;
      }
      try {
        setCurrentProgressStep(
                UpgradeProgressStep.APPLYING_SCHEMA_CUSTOMIZATIONS);
@@ -716,12 +710,21 @@
        throw e;
      }
      try {
        getServerController().stopServerInProcess();
      } catch (Throwable t) {
        LOG.log(Level.INFO,
                "Error applying configuration customizations", t);
        throw new ApplicationException(ApplicationException.Type.BUG,
                "Error stopping server in process", t);
      }
      // This allows you to test whether or not he upgrader can successfully
      // abort an upgrade once changes have been made to the installation
      // path's filesystem.
      if ("true".equals(
              System.getProperty(
                      "org.opends.upgrader.Upgrader.CreateError.CreateError")))
                      "org.opends.upgrader.Upgrader.CreateError")))
      {
        throw new ApplicationException(
                null, "ARTIFICIAL ERROR FOR TESTING ABORT PROCESS", null);
@@ -772,7 +775,6 @@
                getStagedVersion(),
                status,
                note);
      } catch (ApplicationException e) {
        System.err.print("Error cleaning up after upgrade: " +
                e.getLocalizedMessage());
@@ -780,11 +782,36 @@
    }
    // Decide final status based on presense of error
    // It would be nice if this were simpler.
    if (runException == null) {
      setCurrentProgressStep(UpgradeProgressStep.FINISHED);
      if (!Utils.isCli()) {
        // This seems to be the preferred way to print
        // a message to the top of the progress panel without
        // having it show up in the Details section which we
        // don't want since it is in HTML
        this.currentProgressStep = UpgradeProgressStep.FINISHED;
        notifyListeners(null);
      } else {
        notifyListeners(getFinalSuccessMessage());
        // Don't do this until we've printed out last message
        // as doing so tells the CLI that it is finished and
        // System.exit gets called in QuickSetupCli
        this.currentProgressStep = UpgradeProgressStep.FINISHED;
      }
    } else {
      setCurrentProgressStep(UpgradeProgressStep.FINISHED_WITH_ERRORS);
      notifyListeners(formatter.getFormattedError(runException, true));
      if (!Utils.isCli()) {
        notifyListeners(formatter.getFormattedError(runException, true));
        setCurrentProgressStep(UpgradeProgressStep.FINISHED_WITH_ERRORS);
      } else {
        runException.printStackTrace();
        this.currentProgressStep = UpgradeProgressStep.FINISHED_WITH_ERRORS;
      }
    }
  }
@@ -916,12 +943,19 @@
    }
  }
  /**
   * Applies configuration or schema customizations.
   * NOTE: Assumes that the server is running in process.
   * @param ldifFile LDIF file to apply
   * @throws IOException
   * @throws org.opends.server.util.LDIFException
   * @throws ApplicationException
   */
  private void applyCustomizationLdifFile(File ldifFile)
          throws IOException, org.opends.server.util.LDIFException,
          ApplicationException
  {
    try {
      startServerWithoutConnectionHandlers();
      org.opends.server.protocols.internal.InternalClientConnection cc =
              org.opends.server.protocols.internal.
                      InternalClientConnection.getRootConnection();
@@ -992,8 +1026,6 @@
    } catch (Throwable t) {
      throw new ApplicationException(ApplicationException.Type.BUG,
              t.getMessage(), t);
    } finally {
      getServerController().stopServerInProcess();
    }
  }
@@ -1324,7 +1356,7 @@
  private void setCurrentProgressStep(UpgradeProgressStep step) {
    this.currentProgressStep = step;
    String msg = getMsg(step.getSummaryMesssageKey());
    String msg = getSummary(step);
    notifyListeners(getFormattedProgress(msg) + getLineBreak());
  }
@@ -1335,6 +1367,28 @@
    return cliHelper;
  }
  private String getFinalSuccessMessage() {
    String txt;
    String installPath = Utils.getPath(getInstallation().getRootDirectory());
    String newVersion = null;
    try {
      newVersion = getInstallation().getBuildId();
    } catch (QuickSetupException e) {
      newVersion = getMsg("upgrade-build-id-unknown");
    }
    String[] args = {
            formatter.getFormattedText(installPath),
            newVersion};
    if (Utils.isCli()) {
      txt = getMsg("summary-upgrade-finished-successfully-cli", args);
    } else {
      txt = getFormattedSuccess(
              getMsg("summary-upgrade-finished-successfully",
                      args));
    }
    return txt;
  }
  private File getStageDirectory()
          throws ApplicationException, IOException {
    return getInstallation().getTemporaryUpgradeDirectory();