From 5e7c2e08044de85ed9a8da34b2ed8634201e2db7 Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Tue, 15 May 2007 20:32:42 +0000
Subject: [PATCH] This commit removes the Web Start version of the upgrader's ability to download arbitrary builds to be used for upgrading.  Instead, the Web Start version of upgrade will be tied to the  build version of upgrader.  This is necessary after discovering that attemping to perform internal communication with the directory server when the DS bit and the upgraders bits are of different versions is problematic.

---
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java               |  176 ++++------------
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ServerHealthChecker.java        |    8 
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/webstart/WebStartDownloader.java     |   13 +
 opendj-sdk/opends/build.xml                                                                 |    9 
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java                |   79 +++++++
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/InProcessServerController.java  |   31 ++
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgraderCliHelper.java      |    3 
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/OperationOutput.java            |   36 +++
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgradeLauncher.java        |    3 
 opendj-sdk/opends/resource/upgrade                                                          |   73 ++----
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/UpgraderReviewPanel.java |   28 +-
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties       |   13 
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Installation.java                    |   44 ++++
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java           |   75 +++++++
 opendj-sdk/opends/resource/upgrade.bat                                                      |    9 
 15 files changed, 385 insertions(+), 215 deletions(-)

diff --git a/opendj-sdk/opends/build.xml b/opendj-sdk/opends/build.xml
index e5d28de..86d04e6 100644
--- a/opendj-sdk/opends/build.xml
+++ b/opendj-sdk/opends/build.xml
@@ -761,13 +761,14 @@
       <fileset file="${resource.dir}/README" />
     </copy>
 
-    <fixcrlf srcDir="${resource.dir}" destDir="${pdir}" includes="setup,uninstall"
+    <fixcrlf srcDir="${resource.dir}" destDir="${pdir}" includes="setup,uninstall,upgrade"
          eol="lf" />
-    <fixcrlf srcDir="${resource.dir}" destDir="${pdir}" includes="setup.bat,uninstall.bat"
+    <fixcrlf srcDir="${resource.dir}" destDir="${pdir}" includes="setup.bat,uninstall.bat,upgrade.bat"
          eol="crlf" />
 
     <chmod file="${pdir}/setup" perm="755" />
     <chmod file="${pdir}/uninstall" perm="755" />
+    <chmod file="${pdir}/upgrade" perm="755" />
     <chmod perm="755">
       <fileset dir="${pdir}/bin">
       </fileset>
@@ -784,7 +785,7 @@
        description="Package the Directory Server for distribution.">
     <zip destfile="${package.dir}/OpenDS-${VERSION_NUMBER_STRING}.zip">
       <zipfileset dir="${package.dir}" includes="OpenDS-${VERSION_NUMBER_STRING}/**/*"
-           excludes="OpenDS-${VERSION_NUMBER_STRING}/bin/*,OpenDS-${VERSION_NUMBER_STRING}/lib/_client-script.sh,OpenDS-${VERSION_NUMBER_STRING}/lib/_server-script.sh,OpenDS-${VERSION_NUMBER_STRING}/setup,OpenDS-${VERSION_NUMBER_STRING}/uninstall"
+           excludes="OpenDS-${VERSION_NUMBER_STRING}/bin/*,OpenDS-${VERSION_NUMBER_STRING}/lib/_client-script.sh,OpenDS-${VERSION_NUMBER_STRING}/lib/_server-script.sh,OpenDS-${VERSION_NUMBER_STRING}/setup,OpenDS-${VERSION_NUMBER_STRING}/uninstall,OpenDS-${VERSION_NUMBER_STRING}/upgrade"
            filemode="644" dirmode="755" />
       <zipfileset dir="${package.dir}"
            includes="OpenDS-${VERSION_NUMBER_STRING}/lib/_client-script.sh,OpenDS-${VERSION_NUMBER_STRING}/lib/_server-script.sh"
@@ -794,7 +795,7 @@
            filemode="755" dirmode="755" />
       <zipfileset dir="${package.dir}" includes="OpenDS-${VERSION_NUMBER_STRING}/bin/README_WINDOWS.txt"
            filemode="644" dirmode="755" />
-      <zipfileset dir="${package.dir}" includes="OpenDS-${VERSION_NUMBER_STRING}/setup,OpenDS-${VERSION_NUMBER_STRING}/uninstall"
+      <zipfileset dir="${package.dir}" includes="OpenDS-${VERSION_NUMBER_STRING}/setup,OpenDS-${VERSION_NUMBER_STRING}/uninstall,OpenDS-${VERSION_NUMBER_STRING}/upgrade"
            filemode="755" dirmode="755" />
     </zip>
   </target>
diff --git a/opendj-sdk/opends/resource/upgrade b/opendj-sdk/opends/resource/upgrade
index f3631e4..09a5a4d 100644
--- a/opendj-sdk/opends/resource/upgrade
+++ b/opendj-sdk/opends/resource/upgrade
@@ -36,16 +36,12 @@
     then
       . "${INSTANCE_ROOT}/lib/set-java-home"
       JAVA_BIN="${JAVA_HOME}/bin/java"
-      JAVAWS_BIN="${JAVA_HOME}/bin/javaws"
       export JAVA_BIN
-      export JAVAWS_BIN
     else
       JAVA_BIN=`which java 2> /dev/null`
-      JAVAWS_BIN=`which javaws 2> /dev/null`
       if test ${?} -eq 0
       then
         export JAVA_BIN
-        export JAVAWS_BIN
       else
         echo "Please set JAVA_HOME to the root of a Java 5 (or later) installation."
         exit 1
@@ -53,7 +49,6 @@
     fi
   else
     JAVA_BIN="${JAVA_HOME}/bin/java"
-    JAVAWS_BIN="${JAVA_HOME}/bin/javaws"
     export JAVA_BIN
     export JAVA_WS
   fi
@@ -130,54 +125,38 @@
   rm -fr "${INSTANCE_ROOT}/tmp/upgrade"
 fi
 
-# Test for presence of command line arguments
-if test -z "$1"
+# Launch the build extractor.
+# Configure the appropriate CLASSPATH.
+# BuildExtractor uses the existing install's
+# jars
+CLASSPATH=${INSTANCE_ROOT}/classes
+for JAR in ${INSTANCE_ROOT}/lib/*.jar
+do
+  CLASSPATH=${CLASSPATH}:${JAR}
+done
+export CLASSPATH
+"${JAVA_BIN}" org.opends.quicksetup.upgrader.BuildExtractor "${@}"
+
+if [ -r "${INSTANCE_ROOT}/tmp/upgrade" ]
 then
-
-  # If no arguments launch web start version
-  JAVAWS_VM_ARGS="-Dorg.opends.quicksetup.upgrader.Root=$INSTANCE_ROOT"
-  export JAVAWS_VM_ARGS
-  if test -z "${OPENDS_UPGRADE_JNLP}"
-  then
-    OPENDS_UPGRADE_JNLP=http://builds.opends.org/install/QuickUpgrade.jnlp
-  fi
-  "${JAVAWS_BIN}" "${OPENDS_UPGRADE_JNLP}"
-
-else
-
-  # Launch the build extractor.
   # Configure the appropriate CLASSPATH.
-  # BuildExtractor uses the existing install's
-  # jars
-  CLASSPATH=${INSTANCE_ROOT}/classes
-  for JAR in ${INSTANCE_ROOT}/lib/*.jar
+  # Unlike BuildExtractor, the Upgrader uses
+  # the newly extracted build's jars.
+  CLASSPATH=${INSTANCE_ROOT}/tmp/upgrade/classes
+  for JAR in ${INSTANCE_ROOT}/tmp/upgrade/lib/*.jar
   do
-    CLASSPATH=${CLASSPATH}:${JAR}
+    CLASSPATH=${JAR}:${CLASSPATH}
   done
-  export CLASSPATH
-  "${JAVA_BIN}" org.opends.quicksetup.upgrader.BuildExtractor "${@}"
+  # Launch the upgrade process.
+  "${JAVA_BIN}" org.opends.quicksetup.upgrader.UpgradeLauncher "${@}"
 
+  # Clean up if necessary
   if [ -r "${INSTANCE_ROOT}/tmp/upgrade" ]
   then
-    # Configure the appropriate CLASSPATH.
-    # Unlike BuildExtractor, the Upgrader uses
-    # the newly extracted build's jars.
-    CLASSPATH=${INSTANCE_ROOT}/tmp/upgrade/classes
-    for JAR in ${INSTANCE_ROOT}/tmp/upgrade/lib/*.jar
-    do
-      CLASSPATH=${JAR}:${CLASSPATH}
-    done
-    # Launch the upgrade process.
-    "${JAVA_BIN}" org.opends.quicksetup.upgrader.UpgradeLauncher "${@}"
-
-    # Clean up if necessary
-    if [ -r "${INSTANCE_ROOT}/tmp/upgrade" ]
-    then
-      rm -fr "${INSTANCE_ROOT}/tmp/upgrade"
-    fi
-  else
-    # Build extractor didn't work.  Invoke the upgrader
-    # to report errors and usage.
-    "${JAVA_BIN}" org.opends.quicksetup.upgrader.UpgradeLauncher "${@}"    
+    rm -fr "${INSTANCE_ROOT}/tmp/upgrade"
   fi
+else
+  # Build extractor didn't work.  Invoke the upgrader
+  # to report errors and usage.
+  "${JAVA_BIN}" org.opends.quicksetup.upgrader.UpgradeLauncher "${@}"
 fi
diff --git a/opendj-sdk/opends/resource/upgrade.bat b/opendj-sdk/opends/resource/upgrade.bat
index c2e4504..8ba3a5c 100644
--- a/opendj-sdk/opends/resource/upgrade.bat
+++ b/opendj-sdk/opends/resource/upgrade.bat
@@ -39,7 +39,6 @@
 if "%JAVA_HOME%" == "" goto noJavaHome
 if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
 set JAVA_BIN=%JAVA_HOME%\bin\java.exe
-set JAVAWS_BIN=%JAVA_HOME%\bin\javaws.exe
 if "%*" == "" goto callWebStartUpgrade
 goto callExtractor
 
@@ -47,8 +46,6 @@
 if not exist "%INSTANCE_ROOT%\lib\set-java-home.bat" goto noSetJavaHome
 call "%INSTANCE_ROOT%\lib\set-java-home.bat"
 set JAVA_BIN=%JAVA_HOME%\bin\java.exe
-set JAVAWS_BIN=%JAVA_HOME%\bin\javaws.exe
-if "%*" == "" goto callWebStartUpgrade
 goto callExtractor
 
 :noSetJavaHome
@@ -79,12 +76,6 @@
 "%JAVA_BIN%" org.opends.quicksetup.upgrader.BuildExtractor %*
 goto prepUpgrader
 
-:callWebStartUpgrade
-rem set JAVAWS_VM_ARGS=-Dorg.opends.quicksetup.upgrader.Root="%INSTANCE_ROOT%"
-if "%OPENDS_UPGRADE_JNLP%" == "" set OPENDS_UPGRADE_JNLP=http://build.opends.org/install/QuickUpgrade.jnlp
-"%JAVAWS_BIN%" "%OPENDS_UPGRADE_JNLP%"
-goto end
-
 :prepUpgrader
 if EXIST %INSTANCE_ROOT%\tmp\upgrade goto setClassPathToStageDir
 goto callUpgrader
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java
index 2f6bb10..a83568c 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java
@@ -29,6 +29,7 @@
 
 import org.opends.quicksetup.util.Utils;
 import org.opends.quicksetup.i18n.ResourceProvider;
+import org.opends.server.util.DynamicConstants;
 
 import java.util.HashMap;
 import java.util.List;
@@ -45,12 +46,25 @@
  */
 public class BuildInformation implements Comparable {
 
+  // These string values must be synchronized with Directory
+  // Server's main method.  These string values are considered
+  // stable by the server team and not candidates for
+  // internationalization.
   static private final String NAME = "Name";
   static private final String BUILD_ID = "Build ID";
   static private final String MAJOR_VERSION = "Major Version";
   static private final String MINOR_VERSION = "Minor Version";
   static private final String POINT_VERSION = "Point Version";
   static private final String REVISION_NUMBER = "Revision Number";
+  static private final String FIX_IDS = "Fix IDs";
+  static private final String DEBUG_BUILD = "Debug Build";
+  static private final String BUILD_OS = "Build OS";
+  static private final String BUILD_USER = "Build User";
+  static private final String BUILD_JAVA_VERSION = "Build Java Version";
+  static private final String BUILD_JAVA_VENDOR = "Build Java Vendor";
+  static private final String BUILD_JVM_VERSION = "Build JVM Version";
+  static private final String BUILD_JVM_VENDOR = "Build JVM Vendor";
+
 
   /**
    * Reads build information for a particular installation by reading the
@@ -94,13 +108,55 @@
         }
       }
     }
-    // Make sure we got values for import properties
+
+    // Make sure we got values for important properties that are used
+    // in compareTo, equals, and hashCode
     checkNotNull(bi.values,
             NAME,
             MAJOR_VERSION,
             MINOR_VERSION,
             POINT_VERSION,
             REVISION_NUMBER);
+
+    return bi;
+  }
+
+  /**
+   * Creates an instance from constants present in the current build.
+   * @return BuildInformation created from current constant values
+   * @throws ApplicationException if all or some important information could
+   * not be determined
+   */
+  public static BuildInformation getCurrent() throws ApplicationException {
+    BuildInformation bi = new BuildInformation();
+    bi.values.put(NAME, DynamicConstants.FULL_VERSION_STRING);
+    bi.values.put(BUILD_ID, DynamicConstants.BUILD_ID);
+    bi.values.put(MAJOR_VERSION,
+            String.valueOf(DynamicConstants.MAJOR_VERSION));
+    bi.values.put(MINOR_VERSION,
+            String.valueOf(DynamicConstants.MINOR_VERSION));
+    bi.values.put(POINT_VERSION,
+            String.valueOf(DynamicConstants.POINT_VERSION));
+    bi.values.put(REVISION_NUMBER,
+            String.valueOf(DynamicConstants.REVISION_NUMBER));
+    bi.values.put(FIX_IDS, DynamicConstants.FIX_IDS);
+    bi.values.put(DEBUG_BUILD, String.valueOf(DynamicConstants.DEBUG_BUILD));
+    bi.values.put(BUILD_OS, DynamicConstants.BUILD_OS);
+    bi.values.put(BUILD_USER, DynamicConstants.BUILD_USER);
+    bi.values.put(BUILD_JAVA_VERSION, DynamicConstants.BUILD_JAVA_VERSION);
+    bi.values.put(BUILD_JAVA_VENDOR, DynamicConstants.BUILD_JAVA_VENDOR);
+    bi.values.put(BUILD_JVM_VERSION, DynamicConstants.BUILD_JVM_VERSION);
+    bi.values.put(BUILD_JVM_VENDOR, DynamicConstants.BUILD_JVM_VENDOR);
+
+    // Make sure we got values for important properties that are used
+    // in compareTo, equals, and hashCode
+    checkNotNull(bi.values,
+            NAME,
+            MAJOR_VERSION,
+            MINOR_VERSION,
+            POINT_VERSION,
+            REVISION_NUMBER);
+
     return bi;
   }
 
@@ -203,6 +259,27 @@
     return 1;
   }
 
+  /**
+   * {@inheritDoc}
+   */
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+    return compareTo(o) == 0;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public int hashCode() {
+    int hc = 11;
+    hc = 31 * hc + getMajorVersion().hashCode();
+    hc = 31 * hc + getMinorVersion().hashCode();
+    hc = 31 * hc + getPointVersion().hashCode();
+    hc = 31 * hc + getRevisionNumber().hashCode();
+    return hc;
+  }
+
   static private void checkNotNull(Map values, String... props)
           throws ApplicationException {
     for (String prop : props) {
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Installation.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Installation.java
index 88b89c0..914e996 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Installation.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Installation.java
@@ -606,6 +606,24 @@
   }
 
   /**
+   * Gets the file for invoking a particular command appropriate for
+   * the current operating system.
+   * @param command namd of the command
+   * @return File representing the command
+   */
+  public File getCommandFile(String command) {
+    File commandFile;
+    if (Utils.isWindows()) {
+      commandFile = new File(getBinariesDirectory(),
+              command + ".bat");
+    } else {
+      commandFile = new File(getBinariesDirectory(),
+              command);
+    }
+    return commandFile;
+  }
+
+  /**
    * Gets the file responsible for stopping the server appropriate
    * for the current operating system.
    * @return File representing the stop command
@@ -700,7 +718,24 @@
    * build information
    */
   public BuildInformation getBuildInformation() throws ApplicationException {
-    if (buildInformation == null) {
+    return getBuildInformation(true);
+  }
+
+  /**
+   * Gets information about the build that was used to produce the bits
+   * for this installation.
+   * @param useCachedVersion where true indicates that a potentially cached
+   * version of the build information is acceptable for use; false indicates
+   * the the build information will be created from scratch which is potentially
+   * time consuming
+   * @return BuildInformation object describing this installation
+   * @throws ApplicationException if there is a problem obtaining the
+   * build information
+   */
+  public BuildInformation getBuildInformation(boolean useCachedVersion)
+          throws ApplicationException
+  {
+    if (buildInformation == null || useCachedVersion == false) {
       FutureTask<BuildInformation> ft = new FutureTask<BuildInformation>(
               new Callable<BuildInformation>() {
                 public BuildInformation call() throws ApplicationException {
@@ -718,4 +753,11 @@
     }
     return buildInformation;
   }
+
+  /**
+   * {@inheritDoc}
+   */
+  public String toString() {
+    return Utils.getPath(rootDirectory);
+  }
 }
\ No newline at end of file
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
index 02aa934..656b2cd 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
@@ -169,9 +169,10 @@
 upgrade-launcher-description=This utility may be used to upgrade the Directory \
   Server to a newer version.
 upgrade-launcher-usage=This utility may be used to upgrade the Directory Server \
-   to a newer version.  If no options are specified on the command line, the \
-   graphical version of this tool will launch.  Otherwise the the command line \
-   version will be launched.\n\nUsage:  {0} {options} where {options} \
+   to a newer version.  Use of this tool assumes that you have already downloaded an \
+   OpenDS install package (.zip) file.  You can also upgrade your server using \
+   the Java Web Start version of this tool by visiting the OpenDS web site at opends.org.\n\n\
+   Usage:  {0} {options} where {options} \
    include:\n\n\
      -V, --version\n    Display Directory Server version information.\n\
      -f, --file\n  Specifies an existing OpenDS package (.zip) \
@@ -905,10 +906,10 @@
 error-starting-server-with-no-connection-handlers=Error Starting Server with \
 no connection handlers: {0}.
 error-starting-server=Error Starting Directory Server.
-error-starting-server-in-windows=Could not connect to Server after Start.  \
+error-starting-server-in-windows=Could not connect to the server after requesting start.  \
 If you have a firewall configured check that it allows connections to port {0}.
-error-starting-server-in-unix=Could not connect to Server after Start.  \
-Verify that you have the rights to access to port {0}.
+error-starting-server-in-unix=Could not connect to the server after after requesting start.  \
+Verify that the server has access rights to port {0}.
 error-stopping-server=Error Stopping Directory Server.
 error-stopping-server-code=Error Stopping Directory Server.  Error code: {0}.
 error-reading-erroroutput=Error Reading error output.
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgradeLauncher.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgradeLauncher.java
index 61de1e8..d808e0f 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgradeLauncher.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgradeLauncher.java
@@ -80,7 +80,8 @@
    * {@inheritDoc}
    */
   protected boolean isCli() {
-    return args.length > 0;
+    // for now only CLI is supported via command line
+    return true;
   }
 
   /**
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
index 0794172..3eaa35a 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
@@ -40,12 +40,14 @@
 import org.opends.quicksetup.Step;
 import org.opends.quicksetup.BuildInformation;
 import org.opends.quicksetup.CurrentInstallStatus;
+import org.opends.quicksetup.webstart.WebStartDownloader;
 import org.opends.quicksetup.util.Utils;
 import org.opends.quicksetup.util.ZipExtractor;
 import org.opends.quicksetup.util.ServerController;
 import org.opends.quicksetup.util.InProcessServerController;
 import org.opends.quicksetup.util.ServerHealthChecker;
 import org.opends.quicksetup.util.FileManager;
+import org.opends.quicksetup.util.OperationOutput;
 import org.opends.quicksetup.ui.GuiApplication;
 import org.opends.quicksetup.ui.QuickSetupDialog;
 import org.opends.quicksetup.ui.UIFactory;
@@ -53,7 +55,6 @@
 import org.opends.quicksetup.ui.QuickSetupStepPanel;
 import org.opends.quicksetup.ui.QuickSetup;
 import org.opends.quicksetup.ui.FieldName;
-import org.opends.quicksetup.upgrader.ui.ChooseVersionPanel;
 import org.opends.quicksetup.upgrader.ui.UpgraderReviewPanel;
 import org.opends.quicksetup.upgrader.ui.WelcomePanel;
 
@@ -62,6 +63,7 @@
 import java.io.File;
 import java.io.FileFilter;
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.InetSocketAddress;
 import java.net.MalformedURLException;
 import java.net.Proxy;
@@ -89,8 +91,6 @@
 
     WELCOME("welcome-step"),
 
-    CHOOSE_VERSION("step-upgrade-choose-version"),
-
     REVIEW("review-step"),
 
     PROGRESS("progress-step");
@@ -475,8 +475,6 @@
     QuickSetupStepPanel pnl = null;
     if (UpgradeWizardStep.WELCOME.equals(step)) {
       pnl = new WelcomePanel(this);
-    } else if (UpgradeWizardStep.CHOOSE_VERSION.equals(step)) {
-      pnl = new ChooseVersionPanel(this);
     } else if (UpgradeWizardStep.REVIEW.equals(step)) {
       pnl = new UpgraderReviewPanel(this);
     } else if (UpgradeWizardStep.PROGRESS.equals(step)) {
@@ -491,8 +489,6 @@
   public WizardStep getNextWizardStep(WizardStep step) {
     WizardStep next = null;
     if (UpgradeWizardStep.WELCOME.equals(step)) {
-      next = UpgradeWizardStep.CHOOSE_VERSION;
-    } else if (UpgradeWizardStep.CHOOSE_VERSION.equals(step)) {
       next = UpgradeWizardStep.REVIEW;
     } else if (UpgradeWizardStep.REVIEW.equals(step)) {
       next = UpgradeWizardStep.PROGRESS;
@@ -508,8 +504,6 @@
     if (UpgradeWizardStep.PROGRESS.equals(step)) {
       prev = UpgradeWizardStep.REVIEW;
     } else if (UpgradeWizardStep.REVIEW.equals(step)) {
-      prev = UpgradeWizardStep.CHOOSE_VERSION;
-    } else if (UpgradeWizardStep.CHOOSE_VERSION.equals(step)) {
       prev = UpgradeWizardStep.WELCOME;
     }
     return prev;
@@ -520,7 +514,6 @@
    */
   public boolean canQuit(WizardStep step) {
     return UpgradeWizardStep.WELCOME == step ||
-            UpgradeWizardStep.CHOOSE_VERSION == step ||
             UpgradeWizardStep.REVIEW == step;
   }
 
@@ -657,26 +650,6 @@
         // do nothing; all fields are read-only
       }
 
-    } else if (cStep == UpgradeWizardStep.CHOOSE_VERSION) {
-      Build buildToDownload = null;
-      File buildFile = null;
-      Boolean downloadFirst =
-              (Boolean) qs.getFieldValue(FieldName.UPGRADE_DOWNLOAD);
-      if (downloadFirst) {
-        buildToDownload =
-                (Build) qs.getFieldValue(FieldName.UPGRADE_BUILD_TO_DOWNLOAD);
-      } else {
-        buildFile = (File) qs.getFieldValue(FieldName.UPGRADE_FILE);
-        if (buildFile == null) {
-          errorMsgs.add("You must specify a path to an OpenDS build file");
-        } else if (!buildFile.exists()) {
-          errorMsgs.add("File " + Utils.getPath(buildFile) +
-                  " does not exist.");
-          qs.displayFieldInvalid(FieldName.UPGRADE_FILE, true);
-        }
-      }
-      uud.setBuildToDownload(buildToDownload);
-      uud.setInstallPackage(buildFile);
     } else if (cStep == UpgradeWizardStep.REVIEW) {
       Boolean startServer =
               (Boolean) qs.getFieldValue(FieldName.SERVER_START);
@@ -734,75 +707,37 @@
 
     try {
 
+      ZipExtractor extractor = null;
       if (Utils.isWebStart()) {
         try {
-          LOG.log(Level.INFO, "waiting for Java Web Start jar download");
+          LOG.log(Level.INFO, "Waiting for Java Web Start jar download");
           waitForLoader(15); // TODO: ratio
+          LOG.log(Level.INFO, "Downloaded build file");
+          String zipName = WebStartDownloader.getZipFileName();
+          InputStream in =
+                  Upgrader.class.getClassLoader().getResourceAsStream(zipName);
+          extractor = new ZipExtractor(in, zipName);
         } catch (ApplicationException e) {
-          LOG.log(Level.SEVERE, "Error downloading WebStart jars", e);
-          throw e;
-        }
-      }
-
-      checkAbort();
-
-      File buildZip;
-      Build buildToDownload =
-              getUpgradeUserData().getInstallPackageToDownload();
-      if (buildToDownload != null) {
-        try {
-          LOG.log(Level.INFO, "build to download " + buildToDownload);
-          setCurrentProgressStep(UpgradeProgressStep.DOWNLOADING);
-          buildZip = new File(getStageDirectory(), "OpenDS.zip");
-          if (buildZip.exists()) {
-            LOG.log(Level.INFO, "build file " + buildZip.getName() +
-                    " already exists");
-            if (!buildZip.delete()) {
-              LOG.log(Level.WARNING, "removal of existing build file failed");
-              throw ApplicationException.createFileSystemException(
-                      "Could not delete existing build file " +
-                              Utils.getPath(buildZip), null);
-            }
-          }
-          LOG.log(Level.FINE, "Preparing to download " +
-                  buildToDownload.getUrl() +
-                  " to " + Utils.getPath(buildZip));
-          try {
-            getRemoteBuildManager().download(buildToDownload, buildZip);
-          } catch (IOException e) {
-            throw new ApplicationException(
-                    ApplicationException.Type.APPLICATION,
-                    "Failed to download build package .zip " +
-                            "file from " + buildToDownload.getUrl(), e);
-          }
-          LOG.log(Level.INFO, "download finished");
-          notifyListeners(formatter.getFormattedDone() +
-                  formatter.getLineBreak());
-        } catch (ApplicationException e) {
-          LOG.log(Level.INFO, "Error downloading build file", e);
+          LOG.log(Level.SEVERE, "Error downloading Web Start jars", e);
           throw e;
         }
       } else {
-        buildZip = getUpgradeUserData().getInstallPackage();
-        LOG.log(Level.INFO, "will use local build " + buildZip);
+        File buildZip = getUpgradeUserData().getInstallPackage();
+        LOG.log(Level.INFO, "Existing local build file " + buildZip.getName());
+        extractor = new ZipExtractor(buildZip);
       }
 
       checkAbort();
 
-      if (buildZip != null) {
-        LOG.log(Level.INFO, "existing local build file " + buildZip.getName());
-        try {
-          LOG.log(Level.INFO, "extracting local build file " + buildZip);
-          setCurrentProgressStep(UpgradeProgressStep.EXTRACTING);
-          ZipExtractor extractor = new ZipExtractor(buildZip);
-          extractor.extract(getStageDirectory());
-          notifyListeners(formatter.getFormattedDone() +
-                  formatter.getLineBreak());
-          LOG.log(Level.INFO, "extraction finished");
-        } catch (ApplicationException e) {
-          LOG.log(Level.INFO, "Error extracting build file", e);
-          throw e;
-        }
+      try {
+        setCurrentProgressStep(UpgradeProgressStep.EXTRACTING);
+        extractor.extract(getStageDirectory());
+        notifyListeners(formatter.getFormattedDone() +
+                formatter.getLineBreak());
+        LOG.log(Level.INFO, "extraction finished");
+      } catch (ApplicationException e) {
+        LOG.log(Level.INFO, "Error extracting build file", e);
+        throw e;
       }
 
       checkAbort();
@@ -821,20 +756,6 @@
 
       checkAbort();
 
-      try {
-        LOG.log(Level.INFO, "checking server health");
-        setCurrentProgressStep(UpgradeProgressStep.CHECK_SERVER_HEALTH);
-        checkServerHealth();
-        notifyListeners(formatter.getFormattedDone() +
-                formatter.getLineBreak());
-        LOG.log(Level.INFO, "server health check finished");
-      } catch (ApplicationException e) {
-        LOG.log(Level.INFO, "Server failed initial health check", e);
-        throw e;
-      }
-
-      checkAbort();
-
       boolean schemaCustomizationPresent = false;
       try {
         LOG.log(Level.INFO, "checking for schema customizations");
@@ -1019,6 +940,7 @@
           try {
             LOG.log(Level.INFO, "starting server");
             control.startServer();
+            notifyListeners(formatter.getLineBreak());
           } catch (ApplicationException e) {
             LOG.log(Level.INFO, "error starting server");
             this.runWarning = e;
@@ -1027,6 +949,7 @@
           try {
             LOG.log(Level.INFO, "stopping server");
             control.stopServer();
+            notifyListeners(formatter.getLineBreak());
           } catch (ApplicationException e) {
             LOG.log(Level.INFO, "error stopping server");
             this.runWarning = e;
@@ -1343,7 +1266,8 @@
   private void upgradeComponents() throws ApplicationException {
     try {
       File stageDir = getStageDirectory();
-      File root = getInstallation().getRootDirectory();
+      Installation installation = getInstallation();
+      File root = installation.getRootDirectory();
       FileManager fm = new FileManager();
       for (String fileName : stageDir.list()) {
         File f = new File(stageDir, fileName);
@@ -1351,6 +1275,13 @@
                 new UpgradeFileFilter(stageDir),
                 /*overwrite=*/true);
       }
+
+      // The bits should now be of the new version.  Have
+      // the installation update the build information so
+      // that it is correct.
+      LOG.log(Level.INFO, "upgraded bits to " +
+              installation.getBuildInformation(false));
+
     } catch (IOException e) {
       throw ApplicationException.createFileSystemException(
               "I/0 error upgrading components: " + e.getLocalizedMessage(), e);
@@ -1460,33 +1391,22 @@
   }
 
   private void backupDatabases() throws ApplicationException {
-    List<String> args = new ArrayList<String>();
-    args.add("--configClass");
-    args.add("org.opends.server.extensions.ConfigFileHandler");
-    args.add("--configFile");
-    args.add(getInstallation().getCurrentConfigurationFile().getPath());
-    args.add("-a"); // backup all
-    args.add("-d"); // backup to directory
+    ServerController sc = getServerController();
     try {
-      args.add(getUpgradeBackupDirectory().getCanonicalPath());
-    } catch (IOException e) {
-      // TODO i18n
-      throw new ApplicationException(
-              ApplicationException.Type.FILE_SYSTEM_ERROR,
-              "error backup up databases", e);
-    }
-    int ret = org.opends.server.tools.BackUpDB.mainBackUpDB(
-            args.toArray(new String[0]));
-    if (ret != 0) {
-      StringBuffer sb = new StringBuffer()
-              .append("'backup utility returned error code ")
-              .append(ret)
-              .append(" when invoked with args: ")
-              .append(Utils.listToString(args, " "));
-      throw new ApplicationException(
-              ApplicationException.Type.FILE_SYSTEM_ERROR,
-              sb.toString(), null);
+      OperationOutput output = sc.backupDatabases(getUpgradeBackupDirectory());
+      int ret = output.getReturnCode();
+      if (ret != 0) {
+        StringBuffer sb = new StringBuffer()
+                .append("'backup utility returned error code " + ret);
+        throw new ApplicationException(
+                ApplicationException.Type.FILE_SYSTEM_ERROR,
+                sb.toString(), null);
 
+      }
+    } catch (Exception e) {
+      throw new ApplicationException(
+              ApplicationException.Type.TOOL_ERROR,
+              "error backup up databases", e);
     }
   }
 
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgraderCliHelper.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgraderCliHelper.java
index 486034e..88245cb 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgraderCliHelper.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgraderCliHelper.java
@@ -83,8 +83,7 @@
       } else {
         // TODO i18N
         throw new UserDataException(null,
-                "Option -f is required for the command line version of the " +
-                        "upgrade tool.");
+                "Option -f is required.");
       }
 
     } catch (ArgumentException e) {
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/UpgraderReviewPanel.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/UpgraderReviewPanel.java
index 439fdd1..4b2077c 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/UpgraderReviewPanel.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/UpgraderReviewPanel.java
@@ -28,18 +28,20 @@
 package org.opends.quicksetup.upgrader.ui;
 
 import org.opends.quicksetup.UserData;
+import org.opends.quicksetup.BuildInformation;
+import org.opends.quicksetup.ApplicationException;
+import org.opends.quicksetup.i18n.ResourceProvider;
 import org.opends.quicksetup.ui.FieldName;
 import org.opends.quicksetup.ui.LabelFieldDescriptor;
 import org.opends.quicksetup.ui.ReviewPanel;
 import org.opends.quicksetup.ui.UIFactory;
-import org.opends.quicksetup.upgrader.Build;
-import org.opends.quicksetup.upgrader.UpgradeUserData;
 import org.opends.quicksetup.upgrader.Upgrader;
 import org.opends.quicksetup.util.Utils;
 
 import javax.swing.*;
 import java.awt.*;
 import java.util.logging.Logger;
+import java.util.logging.Level;
 
 /**
  * Presents upgrade information to the user to confirm before starting the
@@ -209,16 +211,20 @@
    * @return String indicating the new build
    */
   private String getNewBuildString() {
-    String newVersion;
-    UpgradeUserData uud = (UpgradeUserData)getUserData();
-    Build build = uud.getInstallPackageToDownload();
-    if (build != null) {
-      newVersion = build.getDisplayName();
-    } else {
-      // TODO: figure out the build from the zip somehow
-      newVersion = getMsg("upgrade-build-id-unknown");
+    String b = null;
+    try {
+      BuildInformation bi = BuildInformation.getCurrent();
+      if (bi != null) {
+        b = bi.toString();
+      }
+    } catch (ApplicationException e) {
+      LOG.log(Level.INFO, "error trying to determine new build string", e);
     }
-    return newVersion;
+    if (b == null) {
+      b = ResourceProvider.getInstance().
+              getMsg("upgrade-build-id-unknown");
+    }
+    return b;
   }
 
   /**
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/InProcessServerController.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/InProcessServerController.java
index 7e55038..319982d 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/InProcessServerController.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/InProcessServerController.java
@@ -76,9 +76,36 @@
    * Creates a new instance that will operate on <code>application</code>'s
    * installation.
    * @param installation representing the server instance to control
+   * @throws IllegalStateException if the the version of the OpenDS code
+   * running in this JVM is not the same version as the code whose bits
+   * are stored in <code>installation</code>.
    */
-  public InProcessServerController(Installation installation) {
-    this.installation = installation;
+  public InProcessServerController(Installation installation)
+          throws IllegalStateException
+  {
+
+    // Attempting to use DirectoryServer with a configuration file
+    // for a different version of the server can cause problems for
+    // the server at startup.
+    BuildInformation installBi = null;
+    BuildInformation currentBi = null;
+    try {
+      installBi = installation.getBuildInformation();
+      currentBi = BuildInformation.getCurrent();
+    } catch (Exception e) {
+      throw new IllegalStateException("Failed to verify the build version of " +
+              "the " + installation + " matches the currently executing " +
+              "version.");
+    }
+
+    if (!currentBi.equals(installBi)) {
+      throw new IllegalStateException("The build version of the " +
+              "installation " + installation + " is " + installBi +
+              " and does not match the currently executing version " +
+              currentBi);
+    }
+
+    this.installation=installation;
   }
 
   /**
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/OperationOutput.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/OperationOutput.java
index 8daec2d..c1d6e47 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/OperationOutput.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/OperationOutput.java
@@ -36,8 +36,11 @@
  */
 public class OperationOutput {
 
+  private int returnCode = -1;
+
   private Exception exception = null;
 
+  private List<String> outputMessages = new ArrayList<String>();
   private List<String> errorMessages = new ArrayList<String>();
   private List<String> debugMessages = new ArrayList<String>();
   private List<String> accessMessages = new ArrayList<String>();
@@ -69,6 +72,15 @@
   }
 
   /**
+   * Gets a list of strings representing output messages obtained
+   * by invoking the operation.
+   * @return List of Strings representing errorMessages
+   */
+  public List<String> getOutputMessages() {
+    return Collections.unmodifiableList(outputMessages);
+  }
+
+  /**
    * Gets a list of strings representing error messages obtained
    * by invoking the operation.
    * @return List of Strings representing errorMessages
@@ -96,6 +108,15 @@
   }
 
   /**
+   * Gets the return code produced by the operation if any.
+   * @return int representing any return code returned by the
+   * operation.  -1 indicates no return code was set.
+   */
+  public int getReturnCode() {
+    return this.returnCode;
+  }
+
+  /**
    * Sets the exception that occurred during execution.  Can be null to
    * indicate no exception was encountered.
    * @param exception Exception that occurred during invocation of the operation
@@ -113,6 +134,14 @@
   }
 
   /**
+   * Adds an output message.
+   * @param outputMessage an error message
+   */
+  void addOutputMessage(String outputMessage) {
+    this.outputMessages.add(outputMessage);
+  }
+
+  /**
    * Adds an access message.
    * @param accessMessage an error message
    */
@@ -145,4 +174,11 @@
     this.debugMessages = debugMessages;
   }
 
+  /**
+   * Sets the return code of the operation.
+   * @param i int representing the return code
+   */
+  void setReturnCode(int i) {
+    this.returnCode = i;
+  }
 }
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java
index 6b4689f..e31701e 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java
@@ -40,6 +40,7 @@
 import java.io.BufferedReader;
 import java.io.InputStreamReader;
 import java.io.IOException;
+import java.io.File;
 
 /**
  * Class used to manipulate an OpenDS server.
@@ -397,6 +398,47 @@
   }
 
   /**
+   * Backs up all the databases to a specified directory.
+   * @param backupDir File representing the directory where the backups will
+   * be stored
+   * @return OperationOutput containing information about the operation
+   * @throws IOException if the process could not be started
+   * @throws InterruptedException if the process was prematurely interrupted
+   */
+  public OperationOutput backupDatabases(File backupDir)
+          throws IOException, InterruptedException {
+    final OperationOutput output = new OperationOutput();
+    List<String> args = new ArrayList<String>();
+    args.add(Utils.getPath(installation.getCommandFile("backup")));
+    args.add("-a"); // backup all
+    args.add("-d"); // backup to directory
+    args.add(Utils.getPath(backupDir));
+    ProcessBuilder pb = new ProcessBuilder(args);
+    Process p = pb.start();
+
+    BufferedReader out =
+            new BufferedReader(new InputStreamReader(p.getErrorStream()));
+    new OutputReader(out) {
+      public void processLine(String line) {
+        output.addErrorMessage(line);
+        LOG.log(Level.INFO, "backup operation: " + line);
+      }
+    };
+
+    BufferedReader err =
+            new BufferedReader(new InputStreamReader(p.getInputStream()));
+    new OutputReader(err) {
+      public void processLine(String line) {
+        output.addOutputMessage(line);
+        LOG.log(Level.INFO, "backup operation: " + line);
+      }
+    };
+
+    output.setReturnCode(p.waitFor());
+    return output;
+  }
+
+  /**
    * This class is used to read the standard error and standard output of the
    * Stop process.
    * <p/>
@@ -456,6 +498,39 @@
   }
 
   /**
+   * This class is used to read an input stream and process ouput.
+   */
+  abstract private class OutputReader {
+
+    /**
+     * Called whenever new input is read from the reader.
+     * @param line String representing new input
+     */
+    public abstract void processLine(String line);
+
+    /**
+     * The protected constructor.
+     *
+     * @param reader  the BufferedReader of the stop process.
+     */
+    public OutputReader(final BufferedReader reader) {
+      Thread t = new Thread(new Runnable() {
+        public void run() {
+          try {
+            String line;
+            while (null != (line = reader.readLine())) {
+              processLine(line);
+            }
+          } catch (Throwable t) {
+            LOG.log(Level.INFO, "error reading output", t);
+          }
+        }
+      });
+      t.start();
+    }
+  }
+
+  /**
    * Returns the Message ID indicating that the server has started.
    * @return the Message ID indicating that the server has started.
    */
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ServerHealthChecker.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ServerHealthChecker.java
index 082b66a..78f09b1 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ServerHealthChecker.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ServerHealthChecker.java
@@ -72,9 +72,9 @@
    * @throws ApplicationException if things go wrong
    */
   public void checkServer() throws ApplicationException {
-    InProcessServerController control =
-            new InProcessServerController(installation);
+    InProcessServerController control = null;
     try {
+      control = new InProcessServerController(installation);
       if (installation.getStatus().isServerRunning()) {
         new ServerController(installation).stopServer();
       }
@@ -90,7 +90,9 @@
                         "tool: " + e.getLocalizedMessage(), e);
       }
     } finally {
-      control.stopServer();
+      if (control != null) {
+        control.stopServer();
+      }
     }
   }
 
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/webstart/WebStartDownloader.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/webstart/WebStartDownloader.java
index a8c0cf0..5059335 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/webstart/WebStartDownloader.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/webstart/WebStartDownloader.java
@@ -52,6 +52,19 @@
  */
 public class WebStartDownloader implements DownloadServiceListener,
         JnlpProperties {
+
+
+
+  /**
+   * Returns the name of the zip file name that contains all the installation.
+   * @return the name of the zip file name that contains all the installation.
+   */
+  static public String getZipFileName()
+  {
+    // Passed as a java option in the JNLP file
+    return System.getProperty(ZIP_FILE_NAME);
+  }
+
   private ApplicationException ex;
 
   private boolean isFinished;

--
Gitblit v1.10.0