From 9e01bfedc057e6953c5c6953ca444326df5c4bea Mon Sep 17 00:00:00 2001
From: ludovicp <ludovicp@localhost>
Date: Mon, 31 May 2010 12:59:15 +0000
Subject: [PATCH] Resolve an issue when uninstalling in CLI mode and tool.properties has some properties. When doing uninstall, always stop the local server.

---
 opendj-sdk/opends/src/server/org/opends/server/tools/StopDS.java                  |    5 +++--
 opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java   |    8 +++++++-
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java |   27 ++++++++++++++++++++++++++-
 3 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java
index 305345f..6f1f267 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java
@@ -828,7 +828,13 @@
           notifyListeners(getFormattedWithPoints(
               INFO_PROGRESS_STOPPING_NON_VERBOSE.get()));
         }
-        new ServerController(this).stopServer(!isVerbose());
+        // In case of uninstall, the server stop has to run locally.
+        // In order to bypass the tools.properties mechanism, if any,
+        // we systematically add the --noPropertiesFile flag
+        // when we run the stop-ds command. This is done
+        // by setting the parameter "noPropertiesFile" to 'true'
+        // in the following call.
+        new ServerController(this).stopServer(!isVerbose(),true);
         if (!isVerbose())
         {
           notifyListeners(getFormattedDoneWithLineBreak());
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 5a34245..57feb1b 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
@@ -36,6 +36,7 @@
 
 import static org.opends.quicksetup.util.Utils.*;
 import org.opends.quicksetup.installer.InstallerHelper;
+import org.opends.server.tools.ToolConstants;
 import org.opends.server.util.SetupUtils;
 
 import javax.naming.NamingException;
@@ -112,6 +113,21 @@
    *          if something goes wrong.
    */
   public void stopServer(boolean suppressOutput) throws ApplicationException {
+    stopServer(suppressOutput,false);
+  }
+  /**
+   * This methods stops the server.
+   *
+   * @param suppressOutput boolean indicating that ouput to standard output
+   *                       streams from the server should be suppressed.
+   * @param noPropertiesFile boolean indicating if the stopServer should
+   *                       be called without taking into account the
+   *                       properties file.
+   * @throws org.opends.quicksetup.ApplicationException
+   *          if something goes wrong.
+   */
+  public void stopServer(boolean suppressOutput,boolean noPropertiesFile)
+  throws ApplicationException {
 
     if (suppressOutput && !StandardOutputSuppressor.isSuppressed()) {
       StandardOutputSuppressor.suppress();
@@ -135,8 +151,17 @@
       ArrayList<String> argList = new ArrayList<String>();
       argList.add(Utils.getScriptPath(
           Utils.getPath(installation.getServerStopCommandFile())));
-      String[] args = new String[argList.size()];
+      int size = argList.size();
+      if (noPropertiesFile)
+      {
+        size++;
+      }
+      String[] args = new String[size];
       argList.toArray(args);
+      if (noPropertiesFile)
+      {
+        args[argList.size()] = "--" + ToolConstants.OPTION_LONG_NO_PROP_FILE;
+      }
       ProcessBuilder pb = new ProcessBuilder(args);
       Map<String, String> env = pb.environment();
       env.put(SetupUtils.OPENDS_JAVA_HOME, System.getProperty("java.home"));
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/StopDS.java b/opendj-sdk/opends/src/server/org/opends/server/tools/StopDS.java
index e7bbb74..93701e2 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/StopDS.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/StopDS.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2006-2009 Sun Microsystems, Inc.
+ *      Copyright 2006-2010 Sun Microsystems, Inc.
  */
 package org.opends.server.tools;
 import org.opends.messages.Message;
@@ -827,7 +827,8 @@
           !"quiet".equals(arg.getName()) &&
           !"showusage".equals(arg.getName()) &&
           !"checkstoppability".equals(arg.getName()) &&
-          !"windowsnetstop".equals(arg.getName()))
+          !"windowsnetstop".equals(arg.getName()) &&
+          ! OPTION_LONG_NO_PROP_FILE.equals(arg.getLongIdentifier()))
       {
         stopThroughProtocol |= arg.isPresent();
       }

--
Gitblit v1.10.0