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

kenneth_suter
10.55.2007 12499600a8095e85f4e6afbfff3347b74d7e6d1e
This chunk of code:

- Leaves the server in the state requested by the user in the review panel for the GUI upgrader.

- Includes a change to QuickSetup: Previously finishClicked() did not tell the application to update the user data as nextClicked() does. The Installer and Uninstaller had their own logic for performing the validation and launching. I've updated finishClicked() to return a boolean where a true value indicates that QuickSetup should treat clicking the Finish button as clicking the Next button by telling the application to update the user data as well as launch the application's process if the next step is the progress step. A false value (which the Uninstaller and Installer return) means that the application will manage its own updating of the final panel and launching of the application process.
9 files modified
207 ■■■■ changed files
opends/src/quicksetup/org/opends/quicksetup/Step.java 9 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/WizardStep.java 8 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java 4 ●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties 8 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/ui/GuiApplication.java 6 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java 13 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java 4 ●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java 140 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/UpgraderReviewPanel.java 15 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/Step.java
@@ -96,4 +96,13 @@
  public String getMessageKey() {
    return msgKey;
  }
  /**
   * {@inheritDoc}
   */
  public boolean isProgressStep() {
    return this == PROGRESS;
  }
}
opends/src/quicksetup/org/opends/quicksetup/WizardStep.java
@@ -39,4 +39,12 @@
   */
  String getMessageKey();
  /**
   * Indicates that when this step is displayed the application will
   * be asked to launch itself.
   * @return true indicating that this is the progress step for the
   * application
   */
  boolean isProgressStep();
}
opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
@@ -267,7 +267,7 @@
  /**
   * {@inheritDoc}
   */
  public void finishClicked(final WizardStep cStep, final QuickSetup qs) {
  public boolean finishClicked(final WizardStep cStep, final QuickSetup qs) {
    if (cStep == Step.REVIEW) {
        updateUserDataForReviewPanel(qs);
        qs.launch();
@@ -276,6 +276,8 @@
        throw new IllegalStateException(
                "Cannot click on finish when we are not in the Review window");
    }
    // Installer responsible for updating the user data and launching
    return false;
  }
  /**
opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
@@ -827,6 +827,14 @@
  The upgrade operation could not complete successfully due to errors and \
  the installation has been restored to the state it was in before the upgrade \
  operation.  See the logs for details on why the upgrade operation failed.
summary-upgrade-finished-with-warnings=<b>OpenDS QuickUpgrade Succeeded With \
  Warnings</b><br>The upgrade operation completed successfully but the upgrader \
  had problems that require attention. See the 'Details' text for more \
  information on the problems.
summary-upgrade-finished-with-warnings-cli=OpenDS QuickUpgrade Succeeded With \
  Warnings. The upgrade operation completed successfully but the upgrader \
  had problems that require attention. See the logs for details on the \
  problems.
#
# Progress messages
opends/src/quicksetup/org/opends/quicksetup/ui/GuiApplication.java
@@ -307,8 +307,12 @@
   * Called when the user has clicked the 'finish' button.
   * @param cStep WizardStep at which the user clicked the previous button
   * @param qs QuickSetup controller
   * @return boolean that the application uses to indicate the the
   * application should be launched.  If false, the application is
   * responsible for updating the user data for the final screen and
   * launching the application if this is the desired behavior.
   */
  public abstract void finishClicked(final WizardStep cStep,
  public abstract boolean finishClicked(final WizardStep cStep,
                                     final QuickSetup qs);
  /**
opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java
@@ -258,6 +258,10 @@
  {
    final WizardStep cStep = getCurrentStep();
    application.nextClicked(cStep, this);
    updateUserData(cStep);
  }
  private void updateUserData(final WizardStep cStep) {
    BackgroundTask worker = new BackgroundTask() {
      public Object processBackgroundTask() throws UserDataException {
        try {
@@ -294,6 +298,9 @@
        } else {
          setCurrentStep(application.getNextWizardStep(cStep));
        }
        if (currentStep.isProgressStep()) {
          launch();
        }
      }
    };
    getDialog().workerStarted();
@@ -307,7 +314,9 @@
  private void finishClicked()
  {
    final WizardStep cStep = getCurrentStep();
    application.finishClicked(cStep, this);
    if (application.finishClicked(cStep, this)) {
      updateUserData(cStep);
    }
  }
  /**
@@ -445,7 +454,7 @@
  public void launch()
  {
    application.addProgressUpdateListener(this);
    new Thread(application).start();
    new Thread(application, "Application Thread").start();
    Thread t = new Thread(new Runnable()
    {
      public void run()
opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java
@@ -284,7 +284,7 @@
  /**
   * {@inheritDoc}
   */
  public void finishClicked(final WizardStep cStep, final QuickSetup qs) {
  public boolean finishClicked(final WizardStep cStep, final QuickSetup qs) {
    if (cStep == Step.CONFIRM_UNINSTALL) {
      BackgroundTask worker = new BackgroundTask() {
        public Object processBackgroundTask() throws UserDataException {
@@ -333,6 +333,8 @@
      qs.getDialog().workerStarted();
      worker.startBackgroundTask();
    }
    // Uninstaller is responsible for updating user data and launching
    return false;
  }
  /**
opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
@@ -28,7 +28,6 @@
package org.opends.quicksetup.upgrader;
import org.opends.quicksetup.*;
import static org.opends.quicksetup.Step.PROGRESS;
import org.opends.quicksetup.upgrader.ui.WelcomePanel;
import org.opends.quicksetup.upgrader.ui.ChooseVersionPanel;
import org.opends.quicksetup.upgrader.ui.UpgraderReviewPanel;
@@ -85,6 +84,14 @@
    public String getMessageKey() {
      return msgKey;
    }
    /**
     * {@inheritDoc}
     */
    public boolean isProgressStep() {
      return this == PROGRESS;
    }
  }
  /**
@@ -130,6 +137,8 @@
    FINISHED_WITH_ERRORS("summary-upgrade-finished-with-errors", 100),
    FINISHED_WITH_WARNINGS("summary-upgrade-finished-with-warnings", 100),
    FINISHED("summary-upgrade-finished-successfully", 100);
    private String summaryMsgKey;
@@ -162,7 +171,8 @@
     */
    public boolean isLast() {
      return this == FINISHED ||
              this == FINISHED_WITH_ERRORS;
              this == FINISHED_WITH_ERRORS ||
              this == FINISHED_WITH_WARNINGS;
    }
    /**
@@ -207,7 +217,13 @@
  /**
   * Assigned if an exception occurs during run().
   */
  private ApplicationException runException = null;
  private ApplicationException runError = null;
  /**
   * Assigned if a non-fatal error happened during the upgrade that the
   * user needs to be warned about during run().
   */
  private ApplicationException runWarning = null;
  /**
   * Helps with CLI specific tasks.
@@ -380,6 +396,8 @@
      txt = getFinalSuccessMessage();
    } else if (step == UpgradeProgressStep.FINISHED_WITH_ERRORS) {
      txt = getFinalErrorMessage();
    } else if (step == UpgradeProgressStep.FINISHED_WITH_WARNINGS) {
      txt = getFinalWarningMessage();
    }
    else {
      txt = getMsg(((UpgradeProgressStep) step).getSummaryMesssageKey());
@@ -525,7 +543,9 @@
    return getCurrentProgressStep() ==
            UpgradeProgressStep.FINISHED
    || getCurrentProgressStep() ==
            UpgradeProgressStep.FINISHED_WITH_ERRORS;
            UpgradeProgressStep.FINISHED_WITH_ERRORS
            || getCurrentProgressStep() ==
            UpgradeProgressStep.FINISHED_WITH_WARNINGS;
  }
  /**
@@ -618,6 +638,10 @@
      }
      uud.setBuildToDownload(buildToDownload);
      uud.setInstallPackage(buildFile);
    } else if (cStep == UpgradeWizardStep.REVIEW) {
      Boolean startServer =
              (Boolean) qs.getFieldValue(FieldName.SERVER_START);
      uud.setStartServer(startServer);
    }
    if (errorMsgs.size() > 0) {
@@ -636,9 +660,8 @@
  /**
   * {@inheritDoc}
   */
  public void finishClicked(final WizardStep cStep, final QuickSetup qs) {
    qs.launch();
    qs.setCurrentStep(UpgradeWizardStep.PROGRESS);
  public boolean finishClicked(final WizardStep cStep, final QuickSetup qs) {
    return true;
  }
  /**
@@ -668,7 +691,7 @@
  public void run() {
    // Reset exception just in case this application is rerun
    // for some reason
    runException = null;
    runError = null;
    try {
@@ -943,10 +966,42 @@
        throw e;
      }
      // Leave the server in the state requested by the user via the
      // checkbox on the review panel.  The upgrade has already been
      // verified at this point to in the unlikely event of an error,
      // we call this a warning instead of an error.
      try {
        ServerController control = getServerController();
        boolean serverRunning = getInstallation().getStatus().isServerRunning();
        boolean userRequestsStart = getUserData().getStartServer();
        if (userRequestsStart && !serverRunning) {
          try {
            LOG.log(Level.INFO, "starting server");
            control.startServer();
          } catch (ApplicationException e) {
            LOG.log(Level.INFO, "error starting server");
            this.runWarning = e;
          }
        } else if (!userRequestsStart && serverRunning) {
          try {
            LOG.log(Level.INFO, "stopping server");
            control.stopServer();
          } catch (ApplicationException e) {
            LOG.log(Level.INFO, "error stopping server");
            this.runWarning = e;
          }
        }
      } catch (IOException ioe) {
        LOG.log(Level.INFO, "error determining if server running");
        this.runWarning = new ApplicationException(
                ApplicationException.Type.TOOL_ERROR,
                "Error determining whether or not server running", ioe);
      }
    } catch (ApplicationException ae) {
      this.runException = ae;
      this.runError = ae;
    } catch (Throwable t) {
      this.runException =
      this.runError =
              new ApplicationException(ApplicationException.Type.BUG,
                      "Unexpected error: " + t.getLocalizedMessage(),
                      t);
@@ -954,11 +1009,11 @@
      try {
        HistoricalRecord.Status status;
        String note = null;
        if (runException == null) {
        if (runError == null) {
          status = HistoricalRecord.Status.SUCCESS;
        } else {
          status = HistoricalRecord.Status.FAILURE;
          note = runException.getLocalizedMessage();
          note = runError.getLocalizedMessage();
          // Abort the upgrade and put things back like we found it
          LOG.log(Level.INFO, "canceling upgrade");
@@ -1007,7 +1062,34 @@
      // skipped because the process has already exited by the time
      // processing messages has finished.  Need to resolve these
      // issues.
      if (runException == null) {
      if (runError != null) {
        LOG.log(Level.INFO, "upgrade completed with errors", runError);
        if (!Utils.isCli()) {
          notifyListenersOfLog();
          this.currentProgressStep = UpgradeProgressStep.FINISHED_WITH_ERRORS;
          notifyListeners(formatter.getFormattedError(runError, true));
        } else {
          notifyListeners(formatter.getFormattedError(runError, true) +
                          formatter.getLineBreak());
          notifyListeners(formatter.getLineBreak());
          setCurrentProgressStep(UpgradeProgressStep.FINISHED_WITH_ERRORS);
          notifyListeners(formatter.getLineBreak());
        }
      } else if (runWarning != null) {
        LOG.log(Level.INFO, "upgrade completed with warnings");
        String warningText = runWarning.getLocalizedMessage();
        if (!Utils.isCli()) {
          notifyListenersOfLog();
          this.currentProgressStep = UpgradeProgressStep.FINISHED_WITH_WARNINGS;
          notifyListeners(formatter.getFormattedWarning(warningText, true));
        } else {
          notifyListeners(formatter.getFormattedWarning(warningText, true) +
                          formatter.getLineBreak());
          notifyListeners(formatter.getLineBreak());
          setCurrentProgressStep(UpgradeProgressStep.FINISHED_WITH_WARNINGS);
          notifyListeners(formatter.getLineBreak());
        }
      } else {
        LOG.log(Level.INFO, "upgrade completed successfully");
        if (!Utils.isCli()) {
          notifyListenersOfLog();
@@ -1017,19 +1099,6 @@
          notifyListeners(null);
          this.currentProgressStep = UpgradeProgressStep.FINISHED;
        }
      } else {
        LOG.log(Level.INFO, "upgrade completed with errors", runException);
        if (!Utils.isCli()) {
          notifyListenersOfLog();
          this.currentProgressStep = UpgradeProgressStep.FINISHED_WITH_ERRORS;
          notifyListeners(formatter.getFormattedError(runException, true));
        } else {
          notifyListeners(formatter.getFormattedError(runException, true) +
                          formatter.getLineBreak());
          notifyListeners(formatter.getLineBreak());
          setCurrentProgressStep(UpgradeProgressStep.FINISHED_WITH_ERRORS);
          notifyListeners(formatter.getLineBreak());
        }
      }
    }
@@ -1066,9 +1135,9 @@
      control.stopServer();
    } catch (Exception e) {
      throw new ApplicationException(ApplicationException.Type.APPLICATION,
              "Server health check failed.  Make sure the server is capable " +
                      "of starting without errors before running the upgrade " +
                      "tool.", e);
              "Server health check failed.  Please resolve the following " +
                      "before running the upgrade " +
                      "tool: " + e.getLocalizedMessage(), e);
    }
  }
@@ -1591,7 +1660,7 @@
   * {@inheritDoc}
   */
  public ApplicationException getException() {
    return runException;
    return runError;
  }
  private void setCurrentProgressStep(UpgradeProgressStep step) {
@@ -1646,6 +1715,17 @@
    return txt;
  }
  private String getFinalWarningMessage() {
    String txt;
    if (Utils.isCli()) {
      txt = getMsg("summary-upgrade-finished-with-warnings-cli");
    } else {
      txt = getFormattedWarning(
              getMsg("summary-upgrade-finished-with-warnings"));
    }
    return txt;
  }
  private File getStageDirectory()
          throws ApplicationException, IOException {
    return getInstallation().getTemporaryUpgradeDirectory();
opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/UpgraderReviewPanel.java
@@ -30,6 +30,7 @@
import org.opends.quicksetup.ui.ReviewPanel;
import org.opends.quicksetup.ui.UIFactory;
import org.opends.quicksetup.ui.LabelFieldDescriptor;
import org.opends.quicksetup.ui.FieldName;
import org.opends.quicksetup.upgrader.Upgrader;
import org.opends.quicksetup.upgrader.UpgradeUserData;
import org.opends.quicksetup.upgrader.Build;
@@ -85,8 +86,18 @@
  /**
   * {@inheritDoc}
   */
  public boolean blockingBeginDisplay()
  {
  public Object getFieldValue(FieldName fieldName) {
    Object value = null;
    if (fieldName == FieldName.SERVER_START) {
      value = getCheckBox().isSelected();
    }
    return value;
  }
  /**
   * {@inheritDoc}
   */
  public boolean blockingBeginDisplay() {
    return true;
  }