From c9d828643471890c2812f7d959a98ea8cb135fb8 Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Mon, 02 Apr 2007 15:07:10 +0000
Subject: [PATCH] further refactorings to delegate application logic to Application classes in addition to basic upgrade tool implementation classes and scripts

---
 opends/src/quicksetup/org/opends/quicksetup/ui/ServerSettingsPanel.java    |    2 
 opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties |   20 
 opends/src/quicksetup/org/opends/quicksetup/ui/ReviewPanel.java            |    2 
 opends/src/quicksetup/org/opends/quicksetup/util/ZipExtractor.java         |    3 
 opends/src/quicksetup/org/opends/quicksetup/ui/CurrentStepPanel.java       |   51 -
 opends/src/quicksetup/org/opends/quicksetup/ui/InstallWelcomePanel.java    |    2 
 opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgradeLauncher.java  |  104 ++++
 opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupDialog.java       |  257 +--------
 opends/src/quicksetup/org/opends/quicksetup/ui/StepsPanel.java             |   39 
 opends/src/quicksetup/org/opends/quicksetup/Step.java                      |   32 +
 opends/src/quicksetup/org/opends/quicksetup/ui/DataOptionsPanel.java       |    2 
 opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java       |  192 +++++++
 opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java   |  111 ++++
 opends/src/quicksetup/org/opends/quicksetup/UserData.java                  |   65 ++
 opends/resource/upgrade                                                    |  120 ++++
 opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupPanel.java        |    4 
 opends/src/quicksetup/org/opends/quicksetup/util/Utils.java                |   28 +
 opends/src/quicksetup/org/opends/quicksetup/ui/FramePanel.java             |    2 
 opends/src/quicksetup/org/opends/quicksetup/QuickSetup.java                |  103 ---
 opends/resource/README                                                     |    2 
 opends/resource/upgrade.bat                                                |   70 ++
 opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java         |  165 ++++++
 opends/src/quicksetup/org/opends/quicksetup/Application.java               |  118 ++++
 23 files changed, 1,112 insertions(+), 382 deletions(-)

diff --git a/opends/resource/README b/opends/resource/README
index e8b86dc..66dad87 100644
--- a/opends/resource/README
+++ b/opends/resource/README
@@ -5,7 +5,7 @@
 
 To configure the server, run the setup script on UNIX-based platforms, or the
 setup.bat batch file on Windows.  To start the server, run bin/start-ds.sh on
-UNIX-based platforms, or bin\start-ds.bat on Windows systems.
+UNIX-based platforms, or bat\start-ds.bat on Windows systems.
 
 This product is made available under the Common Development and Distribution
 License (CDDL).  The complete text for this license, and for alternate licenses
diff --git a/opends/resource/upgrade b/opends/resource/upgrade
new file mode 100644
index 0000000..e97ccb2
--- /dev/null
+++ b/opends/resource/upgrade
@@ -0,0 +1,120 @@
+#!/bin/sh
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License, Version 1.0 only
+# (the "License").  You may not use this file except in compliance
+# with the License.
+#
+# You can obtain a copy of the license at
+# trunk/opends/resource/legal-notices/OpenDS.LICENSE
+# or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at
+# trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
+# add the following below this CDDL HEADER, with the fields enclosed
+# by brackets "[]" replaced with your own identifying information:
+#      Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+#
+#      Portions Copyright 2006-2007 Sun Microsystems, Inc.
+
+
+# See if JAVA_HOME is set.  If not, then see if there is a java executable in
+# the path and try to figure it out.
+if test -z "${JAVA_BIN}"
+then
+  if test -z "${JAVA_HOME}"
+  then
+    if test -f "${INSTANCE_ROOT}/bin/set-java-home"
+    then
+      . "${INSTANCE_ROOT}/bin/set-java-home"
+      JAVA_BIN="${JAVA_HOME}/bin/java"
+      export JAVA_BIN
+    else
+      JAVA_BIN=`which java 2> /dev/null`
+      if test ${?} -eq 0
+      then
+        export JAVA_BIN
+      else
+        echo "Please set JAVA_HOME to the root of a Java 5.0 installation."
+        exit 1
+      fi
+    fi
+  else
+    JAVA_BIN="${JAVA_HOME}/bin/java"
+    export JAVA_BIN
+  fi
+fi
+
+
+# Explicitly set the PATH, LD_LIBRARY_PATH, LD_PRELOAD, and other important
+# system environment variables for security and compatibility reasons.
+PATH=/bin:/usr/bin
+LD_LIBRARY_PATH=
+LD_LIBRARY_PATH_32=
+LD_LIBRARY_PATH_64=
+LD_PRELOAD=
+LD_PRELOAD_32=
+LD_PRELOAD_64=
+export PATH LD_LIBRARY_PATH LD_LIBRARY_PATH_32 LD_LIBRARY_PATH_64 \
+       LD_PRELOAD LD_PRELOAD_32 LD_PRELOAD_34
+
+
+# Capture the current working directory so that we can change to it later.
+# Then capture the location of this script and the Directory Server instance
+# root so that we can use them to create appropriate paths.
+WORKING_DIR=`pwd`
+
+cd `dirname "${0}"`
+SCRIPT_DIR=`pwd`
+
+INSTANCE_ROOT=${SCRIPT_DIR}
+export INSTANCE_ROOT
+
+cd "${WORKING_DIR}"
+
+
+# Configure the appropriate CLASSPATH to test.
+CLASSPATH=${INSTANCE_ROOT}/classes
+for JAR in ${INSTANCE_ROOT}/lib/*.jar
+do
+  CLASSPATH=${CLASSPATH}:${JAR}
+done
+export CLASSPATH
+
+# Determine whether the detected Java environment is acceptable for use.
+if test -z "${JAVA_ARGS}"
+then
+  "${JAVA_BIN}" -client org.opends.server.tools.InstallDS -t 2> /dev/null
+  if test ${?} -eq 0
+  then
+    JAVA_ARGS="-client"
+  else
+    "${JAVA_BIN}" org.opends.server.tools.InstallDS -t 2> /dev/null
+    if test ${?} -ne 0
+    then
+      echo "ERROR:  The detected Java version could not be used.  Please set "
+      echo "        JAVA_HOME to the root of a Java 5.0 installation."
+      exit 1
+    fi
+  fi
+else
+  "${JAVA_BIN}" ${JAVA_ARGS} org.opends.server.tools.InstallDS -t 2> /dev/null
+  if test ${?} -ne 0
+  then
+    echo "ERROR:  The detected Java version could not be used.  Please set "
+    echo "        JAVA_HOME to the root of a Java 5.0 installation."
+    exit 1
+  fi
+fi
+
+
+# Launch the uninstall process.
+"${JAVA_BIN}" org.opends.quicksetup.upgrader.UpgradeLauncher "${@}"
diff --git a/opends/resource/upgrade.bat b/opends/resource/upgrade.bat
new file mode 100644
index 0000000..d0d4d4b
--- /dev/null
+++ b/opends/resource/upgrade.bat
@@ -0,0 +1,70 @@
+
+@echo off
+rem CDDL HEADER START
+rem
+rem The contents of this file are subject to the terms of the
+rem Common Development and Distribution License, Version 1.0 only
+rem (the "License").  You may not use this file except in compliance
+rem with the License.
+rem
+rem You can obtain a copy of the license at
+rem trunk/opends/resource/legal-notices/OpenDS.LICENSE
+rem or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+rem See the License for the specific language governing permissions
+rem and limitations under the License.
+rem
+rem When distributing Covered Code, include this CDDL HEADER in each
+rem file and include the License file at
+rem trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
+rem add the following below this CDDL HEADER, with the fields enclosed
+rem by brackets "[]" replaced with your own identifying information:
+rem      Portions Copyright [yyyy] [name of copyright owner]
+rem
+rem CDDL HEADER END
+rem
+rem
+rem      Portions Copyright 2006-2007 Sun Microsystems, Inc.
+
+setlocal
+
+set DIR_HOME=%~dP0.
+set INSTANCE_ROOT=%DIR_HOME%
+
+:checkJavaBin
+if "%JAVA_BIN%" == "" goto noJavaBin
+goto setClassPath
+
+:noJavaBin
+if "%JAVA_HOME%" == "" goto noJavaHome
+if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
+set JAVA_BIN=%JAVA_HOME%\bin\java.exe
+goto setClassPath
+
+:noJavaHome
+if not exist "%DIR_HOME%\bat\set-java-home.bat" goto noSetJavaHome
+call "%DIR_HOME%\bat\set-java-home.bat"
+set JAVA_BIN=%JAVA_HOME%\bin\java.exe
+goto setClassPath
+
+:noSetJavaHome
+echo Error: JAVA_HOME environment variable is not set.
+echo        Please set it to a valid Java 5 installation.
+goto end
+
+:setClassPath
+FOR %%x in ("%DIR_HOME%\lib\*.jar") DO call "%DIR_HOME%\bat\setcp.bat" %%x
+
+set PATH=%SystemRoot%
+
+if "%*" == "" goto callLaunch
+goto callJava
+
+:callLaunch
+"%DIR_HOME%\lib\winlauncher.exe" launch "%DIR_HOME%" "%JAVA_BIN%" %JAVA_ARGS% org.opends.quicksetup.uninstaller.UninstallLauncher
+goto end
+
+:callJava
+"%JAVA_BIN%" %JAVA_ARGS% org.opends.quicksetup.upgrader.UpgradeLauncher %*
+goto end
+
+:end
diff --git a/opends/src/quicksetup/org/opends/quicksetup/Application.java b/opends/src/quicksetup/org/opends/quicksetup/Application.java
index b23acbd..2e10a20 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/Application.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/Application.java
@@ -33,12 +33,16 @@
 import org.opends.quicksetup.i18n.ResourceProvider;
 import org.opends.quicksetup.util.Utils;
 import org.opends.quicksetup.util.ProgressMessageFormatter;
+import org.opends.quicksetup.ui.QuickSetupDialog;
+import org.opends.quicksetup.ui.QuickSetupStepPanel;
 
 import javax.naming.NamingException;
+import javax.swing.*;
 import java.io.*;
 import java.util.*;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import java.awt.event.WindowEvent;
 
 /**
  * This class represents an application that can be run in the context
@@ -56,6 +60,12 @@
   static private final Logger LOG =
           Logger.getLogger(Application.class.getName());
 
+  /** The currently displayed wizard step. */
+  private Step displayedStep;
+
+  /** Represents current install state. */
+  protected CurrentInstallStatus installStatus;
+
   /**
    * Creates an application by instantiating the Application class
    * denoted by the System property
@@ -113,10 +123,17 @@
    * of this application must have a default constructor.
    */
   public Application() {
-    // do nothing;
+    this.displayedStep = getFirstWizardStep();
   }
 
   /**
+   * Gets the frame title of the GUI application that will be used
+   * in some operating systems.
+   * @return internationalized String representing the frame title
+   */
+  abstract public String getFrameTitle();
+
+  /**
    * Sets this instances user data.
    * @param userData UserData this application will use
    *        when executing
@@ -588,6 +605,43 @@
   }
 
   /**
+   * Returns the initial wizard step.
+   * @return Step representing the first step to show in the wizard
+   */
+  public abstract Step getFirstWizardStep();
+
+  /**
+   * Called by the quicksetup controller when the user advances to
+   * a new step in the wizard.  Applications are expected to manipulate
+   * the QuickSetupDialog to reflect the current step.
+   *
+   * @param step     Step indicating the new current step
+   * @param userData UserData representing the data specified by the user
+   * @param dlg      QuickSetupDialog hosting the wizard
+   */
+  protected void setDisplayedWizardStep(Step step,
+                                        UserData userData,
+                                        QuickSetupDialog dlg) {
+    this.displayedStep = step;
+
+    // First call the panels to do the required updates on their layout
+    dlg.setDisplayedStep(step, userData);
+    setWizardDialogState(dlg, userData, step);
+  }
+
+  /**
+   * Called when the user advances to new step in the wizard.  Applications
+   * are expected to manipulate the QuickSetupDialog to reflect the current
+   * step.
+   * @param dlg QuickSetupDialog hosting the wizard
+   * @param userData UserData representing the data specified by the user
+   * @param step Step indicating the new current step
+   */
+  protected abstract void setWizardDialogState(QuickSetupDialog dlg,
+                                               UserData userData,
+                                               Step step);
+
+  /**
    * Returns the installation path.
    * @return the installation path.
    */
@@ -661,6 +715,68 @@
   public abstract String getSummary(ProgressStep step);
 
   /**
+   * Sets the current install status for this application.
+   * @param installStatus for the current installation.
+   */
+  public void setCurrentInstallStatus(CurrentInstallStatus installStatus) {
+    this.installStatus = installStatus;
+  }
+
+  /**
+   * Called by the controller when the window is closing.  The application
+   * can take application specific actions here.
+   * @param dlg QuickSetupDialog that will be closing
+   * @param evt The event from the Window indicating closing
+   */
+  abstract public void windowClosing(QuickSetupDialog dlg, WindowEvent evt);
+
+  /**
+   * This method is called when we detected that there is something installed
+   * we inform of this to the user and the user wants to proceed with the
+   * installation destroying the contents of the data and the configuration
+   * in the current installation.
+   */
+  public void forceToDisplay() {
+    // This is really only appropriate for Installer.
+    // The default implementation is to do nothing.
+    // The Installer application overrides this with
+    // whatever it needs.
+  }
+
+  /**
+   * Get the name of the button that will receive initial focus.
+   * @return ButtonName of the button to receive initial focus
+   */
+  abstract public ButtonName getInitialFocusButtonName();
+
+  /**
+   * Creates the main panel for the wizard dialog.
+   * @param dlg QuickSetupDialog used
+   * @return JPanel frame panel
+   */
+  abstract public JPanel createFramePanel(QuickSetupDialog dlg);
+
+  /**
+   * Returns the set of wizard steps used in this application's wizard.
+   * @return Set of Step objects representing wizard steps
+   */
+  abstract public Set<Step> getWizardSteps();
+
+  /**
+   * Creates a wizard panel given a specific step.
+   * @param step for which a panel representation should be created
+   * @return QuickSetupStepPanel for representing the <code>step</code>
+   */
+  abstract public QuickSetupStepPanel createWizardStepPanel(Step step);
+
+  /**
+   * Gets the next step in the wizard given a current step.
+   * @param step Step the current step
+   * @return Step the next step
+   */
+  abstract public Step getNextWizardStep(Step step);
+
+  /**
    * This class is used to read the standard error and standard output of the
    * Start process.
    *
diff --git a/opends/src/quicksetup/org/opends/quicksetup/QuickSetup.java b/opends/src/quicksetup/org/opends/quicksetup/QuickSetup.java
index 8b46ab7..a5dd54e 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/QuickSetup.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/QuickSetup.java
@@ -40,7 +40,6 @@
 import org.opends.quicksetup.util.ProgressMessageFormatter;
 import org.opends.quicksetup.util.Utils;
 import org.opends.quicksetup.util.HtmlProgressMessageFormatter;
-import org.opends.server.util.SetupUtils;
 
 import javax.swing.*;
 import java.io.File;
@@ -117,22 +116,22 @@
   {
     ProgressMessageFormatter formatter = new HtmlProgressMessageFormatter();
     try {
+      installStatus = new CurrentInstallStatus();
+
       application = Application.create();
       application.setProgressMessageFormatter(formatter);
+      application.setCurrentInstallStatus(installStatus);
+
+      initLookAndFeel();
+
+      /* In the calls to setCurrentStep the dialog will be created */
+      setCurrentStep(application.getFirstWizardStep());
+
     } catch (ApplicationException e) {
       LOG.log(Level.INFO, "error", e);
       throw new RuntimeException("failed to create quicksetup application", e);
     }
-    installStatus = new CurrentInstallStatus();
-    initLookAndFeel();
-    /* In the calls to setCurrentStep the dialog will be created */
-    if (Utils.isUninstall())
-    {
-      setCurrentStep(Step.CONFIRM_UNINSTALL);
-    } else
-    {
-      setCurrentStep(Step.WELCOME);
-    }
+
   }
 
   /**
@@ -496,7 +495,8 @@
     switch (cStep)
     {
     case WELCOME:
-      getDialog().forceToDisplaySetup();
+      application.forceToDisplay();
+      getDialog().forceToDisplay();
       setCurrentStep(Step.WELCOME);
       break;
     default:
@@ -815,7 +815,7 @@
       displayFieldInvalid(FieldName.DIRECTORY_MANAGER_PWD_CONFIRM, false);
     }
 
-    int defaultJMXPort = getDefaultJMXPort();
+    int defaultJMXPort = UserData.getDefaultJMXPort();
     if (defaultJMXPort != -1)
     {
       application.getUserData().setServerJMXPort(defaultJMXPort);
@@ -1056,37 +1056,6 @@
   }
 
   /**
-   * Provides an object representing the default data/install parameters that
-   * will be proposed to the user in the Installation wizard. This data includes
-   * elements such as the default dn of the directory manager or the default
-   * install location.
-   *
-   * @return the userData representing the default data/parameters that
-   *         will be proposed to the user.
-   */
-  private UserData getDefaultUserData()
-  {
-    UserData defaultUserData = application.createUserData();
-
-    DataOptions defaultDataOptions = new DefaultDataOptions();
-
-    defaultUserData.setServerLocation(Utils.getDefaultServerLocation());
-    // See what we can propose as port
-    int defaultPort = getDefaultPort();
-    if (defaultPort != -1)
-    {
-      defaultUserData.setServerPort(defaultPort);
-    }
-
-    defaultUserData.setDirectoryManagerDn("cn=Directory Manager");
-
-    defaultUserData.setDataOptions(defaultDataOptions);
-    defaultUserData.setStartServer(true);
-
-    return defaultUserData;
-  }
-
-  /**
    * The following three methods are just commodity methods to get localized
    * messages.
    * @param key String key
@@ -1211,7 +1180,8 @@
   {
     if (dialog == null)
     {
-      dialog = new QuickSetupDialog(getDefaultUserData(), installStatus);
+      dialog = new QuickSetupDialog(application,
+              installStatus);
       dialog.addButtonActionListener(this);
     }
     return dialog;
@@ -1345,49 +1315,6 @@
   }
 
   /**
-   * Provides the port that will be proposed to the user in the second page of
-   * the installation wizard. It will check whether we can use 389 and if not it
-   * will return -1.
-   *
-   * @return the port 389 if it is available and we can use and -1 if not.
-   */
-  private int getDefaultPort()
-  {
-    int defaultPort = -1;
-
-    for (int i=0;i<10000 && (defaultPort == -1);i+=1000)
-    {
-      int port = i + 389;
-      if (Utils.canUseAsPort(port))
-      {
-        defaultPort = port;
-      }
-    }
-    return defaultPort;
-  }
-
-  /**
-   * Provides the port that will be used by default for JMX.
-   *
-   * @return the port X689 if it is available and we can use and -1 if not.
-   */
-  private int getDefaultJMXPort()
-  {
-    int defaultJMXPort = -1;
-
-    for (int i=0;i<65000 && (defaultJMXPort == -1);i+=1000)
-    {
-      int port = i + SetupUtils.getDefaultJMXPort();
-      if (Utils.canUseAsPort(port))
-      {
-        defaultJMXPort = port;
-      }
-    }
-    return defaultJMXPort;
-  }
-
-
-  /**
    * Returns the number of free disk space in bytes required to install Open DS
    *
    * For the moment we just return 15 Megabytes. TODO we might want to have
diff --git a/opends/src/quicksetup/org/opends/quicksetup/Step.java b/opends/src/quicksetup/org/opends/quicksetup/Step.java
index 05e6e27..20ebe82 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/Step.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/Step.java
@@ -38,25 +38,45 @@
   /**
    * Welcome step for the installation.
    */
-  WELCOME,
+  WELCOME("welcome-step"),
   /**
    * Server Settings step (path, port, etc.).
    */
-  SERVER_SETTINGS,
+  SERVER_SETTINGS("server-settings-step"),
   /**
    * Data Options panel (suffix dn, LDIF path, etc.).
    */
-  DATA_OPTIONS,
+  DATA_OPTIONS("data-options-step"),
   /**
    * Review panel for the install.
    */
-  REVIEW,
+  REVIEW("review-step"),
   /**
    * Progress panel.
    */
-  PROGRESS,
+  PROGRESS("progress-step"),
   /**
    * Confirmation panel for the uninstallation.
    */
-  CONFIRM_UNINSTALL
+  CONFIRM_UNINSTALL("confirm-uninstall-step");
+
+  private String msgKey;
+
+  /**
+   * Creates a step.
+   * @param msgKey the message key used to access a message catalog to
+   * retreive this step's display name
+   */
+  Step(String msgKey) {
+    this.msgKey = msgKey;
+  }
+
+  /**
+   * Gets this steps message key.
+   * @return String message key used to access a message catalog to
+   * retreive this step's display name
+   */
+  public String getMessageKey() {
+    return msgKey;
+  }
 }
diff --git a/opends/src/quicksetup/org/opends/quicksetup/UserData.java b/opends/src/quicksetup/org/opends/quicksetup/UserData.java
index d47efa2..18cb4d2 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/UserData.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/UserData.java
@@ -27,6 +27,9 @@
 
 package org.opends.quicksetup;
 
+import org.opends.quicksetup.util.Utils;
+import org.opends.server.util.SetupUtils;
+
 /**
  * Represents user specified input data to an application.
  */
@@ -42,6 +45,25 @@
   private boolean stopServer;
 
   /**
+   * Creates a user data object with default values.
+   */
+  public UserData() {
+    DataOptions defaultDataOptions = new DefaultDataOptions();
+
+    setServerLocation(Utils.getDefaultServerLocation());
+    // See what we can propose as port
+    int defaultPort = getDefaultPort();
+    if (defaultPort != -1)
+    {
+      setServerPort(defaultPort);
+    }
+
+    setDirectoryManagerDn("cn=Directory Manager");
+
+    setDataOptions(defaultDataOptions);
+  }
+
+  /**
    * Sets the location of the server (installation path).
    * @param serverLocation the new server location (installation path).
    */
@@ -193,4 +215,47 @@
   {
     return stopServer;
   }
+
+  /**
+   * Provides the port that will be proposed to the user in the second page of
+   * the installation wizard. It will check whether we can use 389 and if not it
+   * will return -1.
+   *
+   * @return the port 389 if it is available and we can use and -1 if not.
+   */
+  static public int getDefaultPort()
+  {
+    int defaultPort = -1;
+
+    for (int i=0;i<10000 && (defaultPort == -1);i+=1000)
+    {
+      int port = i + 389;
+      if (Utils.canUseAsPort(port))
+      {
+        defaultPort = port;
+      }
+    }
+    return defaultPort;
+  }
+
+  /**
+   * Provides the port that will be used by default for JMX.
+   *
+   * @return the port X689 if it is available and we can use and -1 if not.
+   */
+  static public int getDefaultJMXPort()
+  {
+    int defaultJMXPort = -1;
+
+    for (int i=0;i<65000 && (defaultJMXPort == -1);i+=1000)
+    {
+      int port = i + SetupUtils.getDefaultJMXPort();
+      if (Utils.canUseAsPort(port))
+      {
+        defaultJMXPort = port;
+      }
+    }
+    return defaultJMXPort;
+  }
+
 }
diff --git a/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java b/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
index d4a66e1..b9690c0 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
@@ -26,16 +26,23 @@
  */
 package org.opends.quicksetup.installer;
 
+import static org.opends.quicksetup.Step.WELCOME;
+
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Map;
+import java.util.Set;
+import java.util.EnumSet;
+import java.awt.event.WindowEvent;
 
-import org.opends.quicksetup.ui.UIFactory;
+import org.opends.quicksetup.ui.*;
 import org.opends.quicksetup.util.Utils;
 import org.opends.quicksetup.*;
 import org.opends.server.util.SetupUtils;
 
+import javax.swing.*;
+
 
 /**
  * This is an abstract class that is in charge of actually performing the
@@ -55,12 +62,121 @@
  */
 public abstract class Installer extends Application {
 
+  /* Indicates that we've detected that there is something installed */
+  boolean forceToDisplaySetup = false;
+
   /**
    * An static String that contains the class name of ConfigFileHandler.
    */
   protected static final String CONFIG_CLASS_NAME =
       "org.opends.server.extensions.ConfigFileHandler";
 
+  /**
+   * {@inheritDoc}
+   */
+  public void forceToDisplay() {
+    forceToDisplaySetup = true;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public ButtonName getInitialFocusButtonName() {
+    ButtonName name = null;
+    if (!installStatus.isInstalled() || forceToDisplaySetup)
+    {
+      name = ButtonName.NEXT;
+    } else
+    {
+      if (installStatus.canOverwriteCurrentInstall())
+      {
+        name = ButtonName.CONTINUE_INSTALL;
+      }
+      else
+      {
+        name = ButtonName.QUIT;
+      }
+    }
+    return name;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public JPanel createFramePanel(QuickSetupDialog dlg) {
+    JPanel p;
+    if (installStatus.isInstalled() && !forceToDisplaySetup) {
+      p = dlg.getInstalledPanel();
+    } else {
+      p = new FramePanel(dlg.getStepsPanel(),
+              dlg.getCurrentStepPanel(),
+              dlg.getButtonsPanel());
+    }
+    return p;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public Set<Step> getWizardSteps() {
+    return EnumSet.of(WELCOME,
+            Step.SERVER_SETTINGS,
+            Step.DATA_OPTIONS,
+            Step.REVIEW,
+            Step.PROGRESS);
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public QuickSetupStepPanel createWizardStepPanel(Step step) {
+    QuickSetupStepPanel p = null;
+    switch (step) {
+      case WELCOME:
+        p = new InstallWelcomePanel();
+        break;
+      case SERVER_SETTINGS:
+        p = new ServerSettingsPanel(getUserData());
+        break;
+      case DATA_OPTIONS:
+        p = new DataOptionsPanel(getUserData());
+        break;
+      case REVIEW:
+        p = new ReviewPanel(getUserData());
+        break;
+      case PROGRESS:
+        p = new ProgressPanel();
+        break;
+    }
+    return p;
+  }
+
+  /**
+  * {@inheritDoc}
+  */
+  public void windowClosing(QuickSetupDialog dlg, WindowEvent evt) {
+
+    if (installStatus.isInstalled() && forceToDisplaySetup) {
+      // Simulate a close button event
+      dlg.notifyButtonEvent(ButtonName.QUIT);
+    } else {
+      if (dlg.getDisplayedStep() == Step.PROGRESS) {
+        // Simulate a close button event
+        dlg.notifyButtonEvent(ButtonName.CLOSE);
+      } else {
+        // Simulate a quit button event
+        dlg.notifyButtonEvent(ButtonName.QUIT);
+      }
+    }
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public String getFrameTitle() {
+    return getMsg("frame-install-title");
+  }
+
   /** Indicates the current progress step. */
   protected InstallProgressStep status =
           InstallProgressStep.NOT_STARTED;
@@ -68,12 +184,86 @@
   /**
    * {@inheritDoc}
    */
+  protected void setWizardDialogState(QuickSetupDialog dlg,
+                                      UserData userData,
+                                      Step step) {
+    if (!installStatus.isInstalled() || forceToDisplaySetup) {
+
+      // Set the default button for the frame
+      switch (step) {
+        case REVIEW:
+          dlg.setDefaultButton(ButtonName.FINISH);
+          break;
+
+        case PROGRESS:
+          dlg.setDefaultButton(ButtonName.CLOSE);
+          break;
+
+        default:
+          dlg.setDefaultButton(ButtonName.NEXT);
+      }
+
+      // Set the focus for the current step
+      switch (step) {
+        case WELCOME:
+          dlg.setFocusOnButton(ButtonName.NEXT);
+          break;
+
+        case SERVER_SETTINGS:
+          // The focus is set by the panel itself
+          break;
+
+        case DATA_OPTIONS:
+          // The focus is set by the panel itself
+          break;
+
+        case REVIEW:
+          dlg.setFocusOnButton(ButtonName.FINISH);
+          break;
+
+        case PROGRESS:
+          dlg.setFocusOnButton(ButtonName.CLOSE);
+          dlg.setButtonEnabled(ButtonName.CLOSE, false);
+          break;
+      }
+    }
+  }
+
+  /**
+   * {@inheritDoc}
+   */
   public ProgressStep getStatus()
   {
     return status;
   }
 
   /**
+   * {@inheritDoc}
+   */
+  public Step getFirstWizardStep() {
+    return WELCOME;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public Step getNextWizardStep(Step step) {
+    Step nextStep = null;
+    if (step != null) {
+      if (step.equals(Step.WELCOME)) {
+        nextStep = Step.SERVER_SETTINGS;
+      } else if (step.equals(Step.SERVER_SETTINGS)) {
+        nextStep = Step.DATA_OPTIONS;
+      } else if (step.equals(Step.DATA_OPTIONS)) {
+        nextStep = Step.REVIEW;
+      } else if (step.equals(Step.REVIEW)) {
+        nextStep = Step.PROGRESS;
+      }
+    }
+    return nextStep;
+  }
+
+  /**
    * Creates a template file based in the contents of the UserData object.
    * This template file is used to generate automatically data.  To generate
    * the template file the code will basically take into account the value of
diff --git a/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties b/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
index ccf5261..7be0483 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
+++ b/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
@@ -155,10 +155,30 @@
 cli-uninstall-server-stopped=The Server is Stopped.
 
 #
+# Upgrade command line messages
+#
+upgrade-launcher-usage=This utility may be used to upgrade the \
+Directory Server to a newer version.\n\
+Usage:  {0} {options}\n        where {options} include:\n\
+--cli\n\    Specifies to use the command line upgrade.  If not specified the \
+graphical\n\    interface will be launched.\n\
+-H  or   --help\n    Displays usage information for this program.\n\n\
+The following options will only be taken into account if the option --cli \n\
+(command line) is specified\n\
+-s  or   --silentUpgrade\n    Perform a silent upgrade.
+upgrade-launcher-launching-gui=Launching graphical upgrade...
+upgrade-launcher-launching-cli=Launching command line upgrade...
+upgrade-launcher-gui-launched-failed=\n\nThe graphical upgrade launch \
+failed.\n\nLaunching command line upgrade...
+cli-upgrade-unknown-argument=Unknown argument {0}
+
+
+#
 # Dialog titles
 #
 frame-install-title=OpenDS QuickSetup
 frame-uninstall-title=OpenDS Uninstall
+frame-upgrade-title=OpenDS Upgrade
 
 #
 # Wizard buttons (labels and tooltips)
diff --git a/opends/src/quicksetup/org/opends/quicksetup/ui/CurrentStepPanel.java b/opends/src/quicksetup/org/opends/quicksetup/ui/CurrentStepPanel.java
index 62404e3..a1eea93 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/ui/CurrentStepPanel.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/ui/CurrentStepPanel.java
@@ -31,13 +31,11 @@
 import java.awt.Dimension;
 
 import java.util.HashMap;
+import java.util.Set;
 
-import org.opends.quicksetup.CurrentInstallStatus;
-import org.opends.quicksetup.Step;
 import org.opends.quicksetup.event.ButtonActionListener;
 import org.opends.quicksetup.installer.FieldName;
-import org.opends.quicksetup.ProgressDescriptor;
-import org.opends.quicksetup.UserData;
+import org.opends.quicksetup.*;
 import org.opends.quicksetup.util.Utils;
 
 /**
@@ -53,12 +51,8 @@
  * CardLayout).
  *
  */
-class CurrentStepPanel extends QuickSetupPanel
+public class CurrentStepPanel extends QuickSetupPanel
 {
-  private UserData defaultUserData;
-
-  private CurrentInstallStatus installStatus;
-
   private static final long serialVersionUID = 5474803491510999334L;
 
   private HashMap<Step, QuickSetupStepPanel> hmPanels =
@@ -66,17 +60,11 @@
 
   /**
    * The constructor of this class.
-   * @param defaultUserData the default data that is used to initialize the
-   * contents of the panels (the proposed values).
-   * @param installStatus the object describing the current installation status.
-   * @param isUninstall boolean telling whether we are uninstalling or not.
+   * @param app Application used to create panels for populating the layout
    */
-  public CurrentStepPanel(UserData defaultUserData,
-      CurrentInstallStatus installStatus, boolean isUninstall)
+  public CurrentStepPanel(Application app)
   {
-    this.defaultUserData = defaultUserData;
-    this.installStatus = installStatus;
-    createLayout(isUninstall);
+    createLayout(app);
   }
 
   /**
@@ -126,24 +114,19 @@
 
   /**
    * Create the layout of the panel.
-   * @param isUninstall whether this is an install or uninstall panel.
+   * @param app Application used to create panels for populating the layout
    */
-  private void createLayout(boolean isUninstall)
+  private void createLayout(Application app)
   {
-    if (isUninstall)
-    {
-      hmPanels.put(Step.CONFIRM_UNINSTALL,
-          new ConfirmUninstallPanel(installStatus));
-      hmPanels.put(Step.PROGRESS, new ProgressPanel());
-    } else
-    {
-      hmPanels.put(Step.WELCOME, new InstallWelcomePanel());
-      hmPanels.put(Step.SERVER_SETTINGS, new ServerSettingsPanel(
-          defaultUserData));
-      hmPanels.put(Step.DATA_OPTIONS,
-          new DataOptionsPanel(defaultUserData));
-      hmPanels.put(Step.REVIEW, new ReviewPanel(defaultUserData));
-      hmPanels.put(Step.PROGRESS, new ProgressPanel());
+
+    Set<Step> steps = app.getWizardSteps();
+    if (steps != null) {
+      for (Step step : steps) {
+        QuickSetupStepPanel panel = app.createWizardStepPanel(step);
+        if (panel != null) {
+          hmPanels.put(step, panel);
+        }
+      }
     }
 
     int minWidth = 0;
diff --git a/opends/src/quicksetup/org/opends/quicksetup/ui/DataOptionsPanel.java b/opends/src/quicksetup/org/opends/quicksetup/ui/DataOptionsPanel.java
index 21b1f5a..7134845 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/ui/DataOptionsPanel.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/ui/DataOptionsPanel.java
@@ -54,7 +54,7 @@
  * to import data to the suffix or not, etc.
  *
  */
-class DataOptionsPanel extends QuickSetupStepPanel
+public class DataOptionsPanel extends QuickSetupStepPanel
 {
   private Component lastFocusComponent;
 
diff --git a/opends/src/quicksetup/org/opends/quicksetup/ui/FramePanel.java b/opends/src/quicksetup/org/opends/quicksetup/ui/FramePanel.java
index 9175bcb..e006439 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/ui/FramePanel.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/ui/FramePanel.java
@@ -50,7 +50,7 @@
  * transparency effects.
  *
  */
-class FramePanel extends JPanel
+public class FramePanel extends JPanel
 {
   private static final long serialVersionUID = 7733658951410876078L;
 
diff --git a/opends/src/quicksetup/org/opends/quicksetup/ui/InstallWelcomePanel.java b/opends/src/quicksetup/org/opends/quicksetup/ui/InstallWelcomePanel.java
index 33e09c8..920b364 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/ui/InstallWelcomePanel.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/ui/InstallWelcomePanel.java
@@ -35,7 +35,7 @@
  * This panel is used to show a welcome message.
  *
  */
-class InstallWelcomePanel extends QuickSetupStepPanel
+public class InstallWelcomePanel extends QuickSetupStepPanel
 {
   private static final long serialVersionUID = 6209217138897900860L;
 
diff --git a/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupDialog.java b/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupDialog.java
index 19494ba..3a8f10d 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupDialog.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupDialog.java
@@ -49,15 +49,14 @@
 import org.opends.quicksetup.util.Utils;
 
 /**
- * This class represents the dialog used by installer and the uninstaller.
+ * This class represents the dialog used by quicksetup applications.
  *
  * In its constructor it gets as parameters an object describing the current
  * installation status and the default values to be proposed to the user
  * in the panels.
  *
  * If we are installing Open DS and the server has already been installed it
- * will display an error message.  In the other cases it will display a wizard
- * (that is different depending on whether we are installing or uninstalling).
+ * will display an error message.  In the other cases it will display a wizard.
  *
  */
 public class QuickSetupDialog
@@ -76,67 +75,34 @@
 
   private Step displayedStep;
 
-  private UserData defaultUserData;
-
   private CurrentInstallStatus installStatus;
 
   private HashSet<ButtonActionListener> buttonListeners =
       new HashSet<ButtonActionListener>();
 
-  private boolean forceToDisplaySetup;
+  private Application application;
+
+  private boolean forceToDisplay;
 
   /**
    * Constructor of QuickSetupDialog.
-   * @param defaultUserData the default values to be proposed to the user in
-   * the wizard.
-   * @param installStatus the current installation status.
+   * @param app Application to run in as a wizard
+   * @param installStatus of the current environment
    */
-  public QuickSetupDialog(UserData defaultUserData,
+  public QuickSetupDialog(Application app,
       CurrentInstallStatus installStatus)
   {
-    this.defaultUserData = defaultUserData;
+    if (app == null) {
+      throw new IllegalArgumentException("application cannot be null");
+    }
+    this.application = app;
     this.installStatus = installStatus;
 
-    if (isUninstall())
-    {
-      frame = new JFrame(getMsg("frame-uninstall-title"));
-    } else
-    {
-      frame = new JFrame(getMsg("frame-install-title"));
-    }
-
+    frame = new JFrame(application.getFrameTitle());
     frame.getContentPane().add(getFramePanel());
-    frame.addWindowListener(new WindowAdapter()
-    {
-      public void windowClosing(WindowEvent e)
-      {
-        if (isUninstall())
-        {
-          if (getDisplayedStep() == Step.PROGRESS)
-          {
-            // Simulate a close button event
-            notifyButtonEvent(ButtonName.CLOSE);
-          } else
-          {
-            // Simulate a quit button event
-            notifyButtonEvent(ButtonName.QUIT);
-          }
-        } else if (isInstalled() && !forceToDisplaySetup)
-        {
-          // Simulate a close button event
-          notifyButtonEvent(ButtonName.QUIT);
-        } else
-        {
-          if (getDisplayedStep() == Step.PROGRESS)
-          {
-            // Simulate a close button event
-            notifyButtonEvent(ButtonName.CLOSE);
-          } else
-          {
-            // Simulate a quit button event
-            notifyButtonEvent(ButtonName.QUIT);
-          }
-        }
+    frame.addWindowListener(new WindowAdapter() {
+      public void windowClosing(WindowEvent e) {
+        application.windowClosing(QuickSetupDialog.this, e);
       }
     });
     frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
@@ -161,24 +127,7 @@
     int minWidth = (int) frame.getPreferredSize().getWidth();
     int minHeight = (int) frame.getPreferredSize().getHeight();
     Utils.centerOnScreen(frame);
-    if (isUninstall())
-    {
-      setFocusOnButton(ButtonName.FINISH);
-    } else if (!isInstalled() || forceToDisplaySetup)
-    {
-      setFocusOnButton(ButtonName.NEXT);
-    } else
-    {
-      if (installStatus.canOverwriteCurrentInstall())
-      {
-        setFocusOnButton(ButtonName.CONTINUE_INSTALL);
-      }
-      else
-      {
-        setFocusOnButton(ButtonName.QUIT);
-      }
-    }
-
+    setFocusOnButton(application.getInitialFocusButtonName());
     frame.addComponentListener(new MinimumSizeComponentListener(frame,
         minWidth, minHeight));
 
@@ -190,11 +139,10 @@
    * we inform of this to the user and the user wants to proceed with the
    * installation destroying the contents of the data and the configuration
    * in the current installation.
-   *
    */
-  public void forceToDisplaySetup()
+  public void forceToDisplay()
   {
-    forceToDisplaySetup = true;
+    this.forceToDisplay = true;
     frame.getContentPane().removeAll();
     frame.getContentPane().add(getFramePanel());
     frame.pack();
@@ -223,84 +171,11 @@
   public void setDisplayedStep(Step step, UserData userData)
   {
     displayedStep = step;
-    if (isUninstall())
-    {
-      // First call the panels to do the required updates on their layout
-      getButtonsPanel().setDisplayedStep(step);
-      getStepsPanel().setDisplayedStep(step);
-      getCurrentStepPanel().setDisplayedStep(step, userData);
 
-      // Set the default button for the frame
-      switch (step)
-      {
-      case CONFIRM_UNINSTALL:
-        setDefaultButton(ButtonName.FINISH);
-        break;
-
-      case PROGRESS:
-        setDefaultButton(ButtonName.CLOSE);
-        break;
-      }
-
-      // Set the focus for the current step
-      switch (step)
-      {
-      case CONFIRM_UNINSTALL:
-        setFocusOnButton(ButtonName.FINISH);
-        break;
-
-      case PROGRESS:
-        setFocusOnButton(ButtonName.CLOSE);
-        setButtonEnabled(ButtonName.CLOSE, false);
-        break;
-      }
-    } else if (!isInstalled() || forceToDisplaySetup)
-    {
-      // First call the panels to do the required updates on their layout
-      getButtonsPanel().setDisplayedStep(step);
-      getStepsPanel().setDisplayedStep(step);
-      getCurrentStepPanel().setDisplayedStep(step, userData);
-
-      // Set the default button for the frame
-      switch (step)
-      {
-      case REVIEW:
-        setDefaultButton(ButtonName.FINISH);
-        break;
-
-      case PROGRESS:
-        setDefaultButton(ButtonName.CLOSE);
-        break;
-
-      default:
-        setDefaultButton(ButtonName.NEXT);
-      }
-
-      // Set the focus for the current step
-      switch (step)
-      {
-      case WELCOME:
-        setFocusOnButton(ButtonName.NEXT);
-        break;
-
-      case SERVER_SETTINGS:
-        // The focus is set by the panel itself
-        break;
-
-      case DATA_OPTIONS:
-        // The focus is set by the panel itself
-        break;
-
-      case REVIEW:
-        setFocusOnButton(ButtonName.FINISH);
-        break;
-
-      case PROGRESS:
-        setFocusOnButton(ButtonName.CLOSE);
-        setButtonEnabled(ButtonName.CLOSE, false);
-        break;
-      }
-    }
+    // First call the panels to do the required updates on their layout
+    getButtonsPanel().setDisplayedStep(step);
+    getStepsPanel().setDisplayedStep(step);
+    getCurrentStepPanel().setDisplayedStep(step, userData);
   }
 
   /**
@@ -404,25 +279,6 @@
   }
 
   /**
-   * Removes a button listener.
-   * @param l the ButtonActionListener to be removed.
-   */
-  public void removeButtonActionListener(ButtonActionListener l)
-  {
-    if (isUninstall())
-    {
-      getButtonsPanel().removeButtonActionListener(l);
-    } else if (isInstalled() && !forceToDisplaySetup)
-    {
-      getInstalledPanel().removeButtonActionListener(l);
-    } else
-    {
-      getButtonsPanel().removeButtonActionListener(l);
-    }
-    buttonListeners.remove(l);
-  }
-
-  /**
    * This method is called to inform that a worker has started (the QuickSetup
    * is doing some data validation).  The worker is doing its tasks outside
    * the event thread to avoid blocking of the painting and this class is
@@ -508,7 +364,7 @@
    * @param buttonName the button name of the button.
    * @param enable boolean indicating to enable or to disable the button.
    */
-  private void setButtonEnabled(ButtonName buttonName, boolean enable)
+  public void setButtonEnabled(ButtonName buttonName, boolean enable)
   {
     getButton(buttonName).setEnabled(enable);
   }
@@ -519,41 +375,21 @@
    */
   private JPanel getFramePanel()
   {
-    JPanel p;
-    if (isUninstall())
-    {
-      if (framePanel == null)
-      {
-        framePanel =
-            new FramePanel(getStepsPanel(), getCurrentStepPanel(),
-                getButtonsPanel());
-      }
-      p = framePanel;
-    } else if (isInstalled() && !forceToDisplaySetup)
-    {
-      p = getInstalledPanel();
-    } else
-    {
-      if (framePanel == null)
-      {
-        framePanel =
-            new FramePanel(getStepsPanel(), getCurrentStepPanel(),
-                getButtonsPanel());
-      }
-      p = framePanel;
+    if (framePanel == null) {
+      framePanel = application.createFramePanel(this);
     }
-    return p;
+    return framePanel;
   }
 
   /**
    * Returns the steps panel.
    * @return the steps panel.
    */
-  private StepsPanel getStepsPanel()
+  public StepsPanel getStepsPanel()
   {
     if (stepsPanel == null)
     {
-      stepsPanel = new StepsPanel(isUninstall());
+      stepsPanel = new StepsPanel(application);
     }
     return stepsPanel;
   }
@@ -562,12 +398,11 @@
    * Returns the current step panel.
    * @return the current step panel.
    */
-  private CurrentStepPanel getCurrentStepPanel()
+  public CurrentStepPanel getCurrentStepPanel()
   {
     if (currentStepPanel == null)
     {
-      currentStepPanel = new CurrentStepPanel(defaultUserData, installStatus,
-          isUninstall());
+      currentStepPanel = new CurrentStepPanel(application);
     }
     return currentStepPanel;
   }
@@ -577,7 +412,7 @@
    * Returns the buttons panel.
    * @return the buttons panel.
    */
-  private ButtonsPanel getButtonsPanel()
+  public ButtonsPanel getButtonsPanel()
   {
     if (buttonsPanel == null)
     {
@@ -605,10 +440,7 @@
   private JButton getButton(ButtonName buttonName)
   {
     JButton button;
-    if (isUninstall())
-    {
-      button = getButtonsPanel().getButton(buttonName);
-    } else if (isInstalled() && !forceToDisplaySetup)
+    if (isInstalled() && !forceToDisplay)
     {
       if (buttonName == ButtonName.QUIT)
       {
@@ -618,8 +450,7 @@
         button = getInstalledPanel().getContinueInstallButton();
       } else
       {
-        throw new IllegalStateException("Invalid button name " + buttonName
-            + " if server is installed");
+        button = getButtonsPanel().getButton(buttonName);
       }
     } else
     {
@@ -632,7 +463,7 @@
    * Sets the focus in the button associated with the ButtonName.
    * @param buttonName the ButtonName associated with the button.
    */
-  private void setFocusOnButton(ButtonName buttonName)
+  public void setFocusOnButton(ButtonName buttonName)
   {
     getButton(buttonName).requestFocusInWindow();
   }
@@ -641,7 +472,7 @@
    * Sets the default button for the frame.
    * @param buttonName the ButtonName associated with the button.
    */
-  private void setDefaultButton(ButtonName buttonName)
+  public void setDefaultButton(ButtonName buttonName)
   {
     getFrame().getRootPane().setDefaultButton(getButton(buttonName));
   }
@@ -665,18 +496,6 @@
   }
 
   /**
-   * Returns <CODE>true</CODE> if this is an uninstallation and
-   * <CODE>false</CODE> otherwise.
-   * @return <CODE>true</CODE> if this is an uninstallation and
-   * <CODE>false</CODE> otherwise.
-   */
-  private boolean isUninstall()
-  {
-    return Utils.isUninstall();
-  }
-
-
-  /**
    * Returns <CODE>true</CODE> if the server is already installed and
    * <CODE>false</CODE> otherwise.
    * @return <CODE>true</CODE> if the server is already installed and
@@ -695,7 +514,7 @@
    * to inform the user that the server is already installed when the
    * installation has been launched.
    */
-  private QuickSetupErrorPanel getInstalledPanel()
+  public QuickSetupErrorPanel getInstalledPanel()
   {
     if (installedPanel == null)
     {
@@ -709,7 +528,7 @@
    * in the button associated with buttonName.
    * @param buttonName the ButtonName associated with the button.
    */
-  private void notifyButtonEvent(ButtonName buttonName)
+  public void notifyButtonEvent(ButtonName buttonName)
   {
     ButtonEvent be = new ButtonEvent(this, buttonName);
     for (ButtonActionListener li : buttonListeners)
diff --git a/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupPanel.java b/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupPanel.java
index 89810c1..98c1d35 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupPanel.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupPanel.java
@@ -85,7 +85,7 @@
    * have something of type:
    * key=value
    *
-   * @see ResourceProvider.getMsg(String key)
+   * @see ResourceProvider#getMsg(String)
    * @param key the key in the properties file.
    * @return the value associated to the key in the properties file.
    * properties file.
@@ -105,7 +105,7 @@
    * mykey=value with argument {0}.
    *
    * This method will return "value with argument value1".
-   * @see ResourceProvider.getMsg(String key, String[] args)
+   * @see ResourceProvider#getMsg(String, String[])
    * @param key the key in the properties file.
    * @param args the arguments to be passed to generate the resulting value.
    * @return the value associated to the key in the properties file.
diff --git a/opends/src/quicksetup/org/opends/quicksetup/ui/ReviewPanel.java b/opends/src/quicksetup/org/opends/quicksetup/ui/ReviewPanel.java
index 0cfa0a5..37883f1 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/ui/ReviewPanel.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/ui/ReviewPanel.java
@@ -45,7 +45,7 @@
  * This is the panel that contains the Review Panel.
  *
  */
-class ReviewPanel extends QuickSetupStepPanel
+public class ReviewPanel extends QuickSetupStepPanel
 {
   private static final long serialVersionUID = -7356174829193265699L;
 
diff --git a/opends/src/quicksetup/org/opends/quicksetup/ui/ServerSettingsPanel.java b/opends/src/quicksetup/org/opends/quicksetup/ui/ServerSettingsPanel.java
index 75eaec4..53f4bb1 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/ui/ServerSettingsPanel.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/ui/ServerSettingsPanel.java
@@ -51,7 +51,7 @@
  * Manager DN, etc.
  *
  */
-class ServerSettingsPanel extends QuickSetupStepPanel
+public class ServerSettingsPanel extends QuickSetupStepPanel
 {
   private UserData defaultUserData;
 
diff --git a/opends/src/quicksetup/org/opends/quicksetup/ui/StepsPanel.java b/opends/src/quicksetup/org/opends/quicksetup/ui/StepsPanel.java
index 40e274f..93e5226 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/ui/StepsPanel.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/ui/StepsPanel.java
@@ -38,6 +38,7 @@
 import javax.swing.JPanel;
 
 import org.opends.quicksetup.Step;
+import org.opends.quicksetup.Application;
 
 /**
  * This class displays the different steps of the wizard.  It appears on the
@@ -47,7 +48,7 @@
  * The current displayed step can be changed calling the method setCurrentStep.
  *
  */
-class StepsPanel extends QuickSetupPanel
+public class StepsPanel extends QuickSetupPanel
 {
   private static final long serialVersionUID = -2003945907121690657L;
 
@@ -57,11 +58,11 @@
 
   /**
    * Creates a StepsPanel.
-   * @param isUninstall tells whether we are installing or uninstalling.
+   * @param app Application whose steps this class represents
    */
-  public StepsPanel(boolean isUninstall)
+  public StepsPanel(Application app)
   {
-    createLayout(isUninstall);
+    createLayout(app);
   }
 
   /**
@@ -95,9 +96,9 @@
 
   /**
    * Creates the layout of the panel.
-   * @param isUninstall tells whether we are installing or uninstalling.
+   * @param app Application whose steps this class represents
    */
-  private void createLayout(boolean isUninstall)
+  private void createLayout(Application app)
   {
     setLayout(new GridBagLayout());
 
@@ -112,25 +113,15 @@
 
     HashMap<Step, String> hmText = new HashMap<Step, String>();
     ArrayList<Step> orderedSteps = new ArrayList<Step>();
-    if (isUninstall)
-    {
-      hmText.put(Step.CONFIRM_UNINSTALL, getMsg("confirm-uninstall-step"));
-      hmText.put(Step.PROGRESS, getMsg("progress-step"));
-      orderedSteps.add(Step.CONFIRM_UNINSTALL);
-      orderedSteps.add(Step.PROGRESS);
-    } else
-    {
-      hmText.put(Step.WELCOME, getMsg("welcome-step"));
-      hmText.put(Step.SERVER_SETTINGS, getMsg("server-settings-step"));
-      hmText.put(Step.DATA_OPTIONS, getMsg("data-options-step"));
-      hmText.put(Step.REVIEW, getMsg("review-step"));
-      hmText.put(Step.PROGRESS, getMsg("progress-step"));
-      orderedSteps.add(Step.WELCOME);
-      orderedSteps.add(Step.SERVER_SETTINGS);
-      orderedSteps.add(Step.DATA_OPTIONS);
-      orderedSteps.add(Step.REVIEW);
-      orderedSteps.add(Step.PROGRESS);
+
+    Step step = app.getFirstWizardStep();
+    hmText.put(step, getMsg(step.getMessageKey()));
+    orderedSteps.add(step);
+    while (null != (step = app.getNextWizardStep(step))) {
+      hmText.put(step, getMsg(step.getMessageKey()));
+      orderedSteps.add(step);
     }
+
     for (Step s : orderedSteps)
     {
       if (s != orderedSteps.get(0))
diff --git a/opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java b/opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java
index 12ff3a5..7ee1c77 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java
@@ -28,11 +28,14 @@
 package org.opends.quicksetup.uninstaller;
 
 import org.opends.quicksetup.*;
+import org.opends.quicksetup.ui.*;
 import org.opends.quicksetup.util.Utils;
 import org.opends.server.tools.ConfigureWindowsService;
 
+import javax.swing.*;
 import java.io.*;
 import java.util.*;
+import java.awt.event.WindowEvent;
 
 /**
  * This class is in charge of performing the uninstallation of Open DS.
@@ -56,6 +59,13 @@
   /**
    * {@inheritDoc}
    */
+  public String getFrameTitle() {
+    return getMsg("frame-uninstall-title");
+  }
+
+  /**
+   * {@inheritDoc}
+   */
   public UserData createUserData() {
     return new UninstallUserData();
   }
@@ -63,6 +73,54 @@
   /**
    * {@inheritDoc}
    */
+  public Step getFirstWizardStep() {
+    return Step.CONFIRM_UNINSTALL;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public Step getNextWizardStep(Step step) {
+    Step nextStep = null;
+    if (step != null && step.equals(Step.CONFIRM_UNINSTALL)) {
+      nextStep = Step.PROGRESS;
+    }
+    return nextStep;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  protected void setWizardDialogState(QuickSetupDialog dlg,
+                                      UserData userData,
+                                      Step step) {
+      // Set the default button for the frame
+      switch (step) {
+        case CONFIRM_UNINSTALL:
+          dlg.setDefaultButton(ButtonName.FINISH);
+          break;
+
+        case PROGRESS:
+          dlg.setDefaultButton(ButtonName.CLOSE);
+          break;
+      }
+
+      // Set the focus for the current step
+      switch (step) {
+        case CONFIRM_UNINSTALL:
+          dlg.setFocusOnButton(ButtonName.FINISH);
+          break;
+
+        case PROGRESS:
+          dlg.setFocusOnButton(ButtonName.CLOSE);
+          dlg.setButtonEnabled(ButtonName.CLOSE, false);
+          break;
+      }
+  }
+
+  /**
+   * {@inheritDoc}
+   */
   public UserData createUserData(String[] args, CurrentInstallStatus status)
     throws UserDataException
   {
@@ -359,6 +417,59 @@
   }
 
   /**
+   * {@inheritDoc}
+   */
+  public void windowClosing(QuickSetupDialog dlg, WindowEvent evt) {
+    if (dlg.getDisplayedStep() == Step.PROGRESS) {
+      // Simulate a close button event
+      dlg.notifyButtonEvent(ButtonName.CLOSE);
+    } else {
+      // Simulate a quit button event
+      dlg.notifyButtonEvent(ButtonName.QUIT);
+    }
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public ButtonName getInitialFocusButtonName() {
+    return ButtonName.FINISH;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public JPanel createFramePanel(QuickSetupDialog dlg) {
+    return new FramePanel(dlg.getStepsPanel(),
+            dlg.getCurrentStepPanel(),
+            dlg.getButtonsPanel());
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public Set<Step> getWizardSteps() {
+    return EnumSet.of(Step.CONFIRM_UNINSTALL,
+            Step.PROGRESS);
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public QuickSetupStepPanel createWizardStepPanel(Step step) {
+    QuickSetupStepPanel p = null;
+    switch (step) {
+      case CONFIRM_UNINSTALL:
+        p = new ConfirmUninstallPanel(installStatus);
+        break;
+      case PROGRESS:
+        p = new ProgressPanel();
+        break;
+    }
+    return p;
+  }
+
+  /**
    * This methods stops the server.
    * @throws ApplicationException if something goes wrong.
    */
diff --git a/opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgradeLauncher.java b/opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgradeLauncher.java
new file mode 100644
index 0000000..8cd1ff6
--- /dev/null
+++ b/opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgradeLauncher.java
@@ -0,0 +1,104 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License").  You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE
+ * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
+ * add the following below this CDDL HEADER, with the fields enclosed
+ * by brackets "[]" replaced with your own identifying information:
+ *      Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ *      Portions Copyright 2007 Sun Microsystems, Inc.
+ */
+
+package org.opends.quicksetup.upgrader;
+
+import org.opends.quicksetup.Launcher;
+import org.opends.quicksetup.CliApplication;
+import org.opends.quicksetup.util.Utils;
+
+/**
+ * This class is called by the upgrade and upgrade.bat
+ * command line utilities to launch an upgrade process.
+ */
+public class UpgradeLauncher extends Launcher {
+
+  /**
+   * The main method which is called by the setup command lines.
+   *
+   * @param args the arguments passed by the command lines.  In the case
+   * we want to launch the cli setup they are basically the arguments that we
+   * will pass to the org.opends.server.tools.InstallDS class.
+   */
+  public static void main(String[] args) {
+    new UpgradeLauncher(args).launch();
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  protected String getFrameTitle() {
+    return getMsg("frame-upgrade-title");
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  protected void printUsage() {
+    String arg;
+    if (Utils.isWindows()) {
+      arg = Utils.getWindowsUpgradeFileName();
+    } else {
+      arg = Utils.getUnixUpgradeFileName();
+    }
+    String msg = getMsg("upgrade-launcher-usage");
+    /*
+     * This is required because the usage message contains '{' characters that
+     * mess up the MessageFormat.format method.
+     */
+    msg = msg.replace("{0}", arg);
+    printUsage(msg);
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  protected CliApplication createCliApplication() {
+    return new Upgrader();
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  protected void willLaunchGui() {
+    System.out.println(getMsg("upgrade-launcher-launching-gui"));
+    System.setProperty("org.opends.quicksetup.Application.class",
+            "org.opends.quicksetup.upgrader.Upgrader");
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  protected void guiLaunchFailed() {
+    System.err.println(getMsg("upgrade-launcher-gui-launched-failed"));
+  }
+
+  private UpgradeLauncher(String[] args) {
+    super(args);
+  }
+
+}
diff --git a/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java b/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
new file mode 100644
index 0000000..672260c
--- /dev/null
+++ b/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
@@ -0,0 +1,165 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License").  You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE
+ * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
+ * add the following below this CDDL HEADER, with the fields enclosed
+ * by brackets "[]" replaced with your own identifying information:
+ *      Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ *      Portions Copyright 2007 Sun Microsystems, Inc.
+ */
+
+package org.opends.quicksetup.upgrader;
+
+import org.opends.quicksetup.*;
+import org.opends.quicksetup.ui.QuickSetupDialog;
+import org.opends.quicksetup.ui.QuickSetupStepPanel;
+
+import javax.swing.*;
+import java.awt.event.WindowEvent;
+import java.util.Set;
+
+/**
+ * QuickSetup application of ugrading the bits of an installation of
+ * OpenDS.
+ */
+public class Upgrader extends Application implements CliApplication {
+
+  /**
+   * {@inheritDoc}
+   */
+  public String getFrameTitle() {
+    return null;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public Step getFirstWizardStep() {
+    return Step.WELCOME;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  protected void setWizardDialogState(QuickSetupDialog dlg,
+                                      UserData userData,
+                                      Step step) {
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  protected String getInstallationPath() {
+    return null;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  protected String getBinariesPath() {
+    return null;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public ProgressStep getStatus() {
+    return null;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public Integer getRatio(ProgressStep step) {
+    return null;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public String getSummary(ProgressStep step) {
+    return null;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public void windowClosing(QuickSetupDialog dlg, WindowEvent evt) {
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public ButtonName getInitialFocusButtonName() {
+    return null;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public JPanel createFramePanel(QuickSetupDialog dlg) {
+    return null;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public Set<Step> getWizardSteps() {
+    return null;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public QuickSetupStepPanel createWizardStepPanel(Step step) {
+    return null;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public Step getNextWizardStep(Step step) {
+    return null;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public void run() {
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public UserData createUserData(String[] args,
+                                 CurrentInstallStatus status)
+          throws UserDataException
+  {
+    return null;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public ApplicationException getException() {
+    return null;
+  }
+
+}
diff --git a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
index 7f07b4f..30684c3 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -140,6 +140,16 @@
   private static final String WINDOWS_UNINSTALL_FILE_NAME = "uninstall.bat";
 
   /**
+   * The UNIX uninstall script file name.
+   */
+  private static final String UNIX_UPGRADE_FILE_NAME = "upgrade";
+
+  /**
+   * The Windows uninstall batch file name.
+   */
+  private static final String WINDOWS_UPGRADE_FILE_NAME = "upgrade.bat";
+
+  /**
    * The UNIX start script file name.
    */
   private static final String UNIX_START_FILE_NAME = "start-ds";
@@ -1167,6 +1177,24 @@
   }
 
   /**
+   * Returns the name of the UNIX upgrade script file name.
+   * @return the name of the UNIX upgrade script file name.
+   */
+  public static String getUnixUpgradeFileName()
+  {
+    return UNIX_UPGRADE_FILE_NAME;
+  }
+
+  /**
+   * Returns the name of the Windows upgrade batch file name.
+   * @return the name of the Windows upgrade batch file name.
+   */
+  public static String getWindowsUpgradeFileName()
+  {
+    return WINDOWS_UPGRADE_FILE_NAME;
+  }
+
+  /**
    * Returns the name of the UNIX start script file name.
    * @return the name of the UNIX start script file name.
    */
diff --git a/opends/src/quicksetup/org/opends/quicksetup/util/ZipExtractor.java b/opends/src/quicksetup/org/opends/quicksetup/util/ZipExtractor.java
index 393d80b..2febcb2 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/util/ZipExtractor.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/util/ZipExtractor.java
@@ -283,7 +283,8 @@
     {
       perm = "755";
     } else if (path.endsWith(Utils.getUnixSetupFileName()) ||
-            path.endsWith(Utils.getUnixUninstallFileName()))
+            path.endsWith(Utils.getUnixUninstallFileName()) ||
+            path.endsWith(Utils.getUnixUpgradeFileName()))
     {
       perm = "755";
     } else

--
Gitblit v1.10.0