From 77eebebe9004fbcedd79da2c5fe729a875f82281 Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Tue, 24 Apr 2007 20:25:01 +0000
Subject: [PATCH] fixed problems related to running the upgrader in Windows

---
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Launcher.java                      |   17 +++++++----------
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/InstallLauncher.java     |    2 +-
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallLauncher.java |    2 +-
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java         |    7 +++++++
 opendj-sdk/opends/resource/upgrade.bat                                                    |   19 +++++++++++++------
 5 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/opendj-sdk/opends/resource/upgrade.bat b/opendj-sdk/opends/resource/upgrade.bat
index ea1e591..7a3c0a9 100644
--- a/opendj-sdk/opends/resource/upgrade.bat
+++ b/opendj-sdk/opends/resource/upgrade.bat
@@ -32,18 +32,23 @@
 
 :checkJavaBin
 if "%JAVA_BIN%" == "" goto noJavaBin
+if "%*" == "" goto callWebStartUpgrade
 goto callExtractor
 
 :noJavaBin
 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
 
 :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
+set jAVAWS_BIN=%JAVA_HOME%\bin\javaws.exe
+if "%*" == "" goto callWebStartUpgrade
 goto callExtractor
 
 :noSetJavaHome
@@ -53,12 +58,7 @@
 
 set PATH=%SystemRoot%
 
-if "%*" == "" goto callLaunch
-goto callJava
-
-:callLaunch
-"%DIR_HOME%\lib\winlauncher.exe" launch "%DIR_HOME%" "%JAVA_BIN%" %JAVA_ARGS% org.opends.quicksetup.upgrader.UpgradeLauncher
-goto end
+if "%*" == "" goto callWebStartUpgrade
 
 :callExtractor
 if EXIST .\tmp\upgrade rd .\tmp\upgrade /s /q
@@ -68,6 +68,13 @@
 if %ERRORLEVEL%==0 goto callUpgrader
 goto end
 
+:callWebStartUpgrade
+set JAVAWS_VM_ARGS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005 -Dorg.opends.quicksetup.upgrader.Root="%DIR_HOME%"
+rem set JAVAWS_VM_ARGS=-Dorg.opends.quicksetup.upgrader.Root="%DIR_HOME%"
+if "%OPENDS_UPGRADE_JNLP%" == "" set OPENDS_UPGRADE_JNLP=http://build.opends.org/install/QuickUpgrade.jnlp
+"%JAVAWS_BIN%" "%OPENDS_UPGRADE_JNLP%"
+goto end
+
 :callUpgrader
 set CLASSPATH=""
 FOR %%x in ("%DIR_HOME%\tmp\upgrade\lib\*.jar") DO call "%DIR_HOME%\bat\setcp.bat" %%x
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Launcher.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Launcher.java
index 607b803..98c6492 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Launcher.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Launcher.java
@@ -114,7 +114,6 @@
    */
   protected void printUsage(String i18nMsg) {
     System.err.println(i18nMsg);
-    System.exit(QuickSetupCli.USER_DATA_ERROR);
   }
 
   /**
@@ -234,26 +233,24 @@
 
   /**
    * The main method which is called by the uninstall command lines.
+   * @return int exit code that should be returned upon exit of this program
    */
-  public void launch() {
+  public int launch() {
+    int exitCode = 0;
     if (shouldPrintUsage()) {
       printUsage();
+      exitCode = QuickSetupCli.USER_DATA_ERROR;
     } else if (isCli()) {
-      int exitCode = launchCli(args, createCliApplication());
-      if (exitCode != 0) {
-        System.exit(exitCode);
-      }
+      exitCode = launchCli(args, createCliApplication());
     } else {
       willLaunchGui();
-      int exitCode = launchGui(args);
+      exitCode = launchGui(args);
       if (exitCode != 0) {
         guiLaunchFailed();
         exitCode = launchCli(args, createCliApplication());
-        if (exitCode != 0) {
-          System.exit(exitCode);
-        }
       }
     }
+    return exitCode;
   }
 
   /**
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/InstallLauncher.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/InstallLauncher.java
index 04c0f88..6d6e2cf 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/InstallLauncher.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/InstallLauncher.java
@@ -49,7 +49,7 @@
    * will pass to the org.opends.server.tools.InstallDS class.
    */
   public static void main(String[] args) {
-    new InstallLauncher(args).launch();
+    System.exit(new InstallLauncher(args).launch());
   }
 
   /**
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallLauncher.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallLauncher.java
index f7c3967..73e2868 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallLauncher.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallLauncher.java
@@ -48,7 +48,7 @@
    * will pass to the org.opends.server.tools.InstallDS class.
    */
   public static void main(String[] args) {
-    new UninstallLauncher(args).launch();
+    System.exit(new UninstallLauncher(args).launch());
   }
 
   /**
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 7ebc621..91b6d72 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
@@ -242,6 +242,7 @@
     String[] args = new String[argList.size()];
     argList.toArray(args);
     ProcessBuilder pb = new ProcessBuilder(args);
+    pb.directory(installation.getBinariesDirectory());
     Map<String, String> env = pb.environment();
     env.put("JAVA_HOME", System.getProperty("java.home"));
     /* Remove JAVA_BIN to be sure that we use the JVM running the installer
@@ -249,6 +250,12 @@
      */
     env.remove("JAVA_BIN");
 
+    // Upgrader's classpath contains jars located in the temporary
+    // directory that we don't want locked by the directory server
+    // when it starts.  Since we're just calling the start-ds script
+    // it will figure out the correct classpath for the server.
+    env.remove("CLASSPATH");
+
     try
     {
       String startedId = getStartedId();

--
Gitblit v1.10.0