From f8372f9b8f798114d0b4fa896abeac187c074480 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Fri, 16 Nov 2007 16:41:24 +0000
Subject: [PATCH] Fix for issue 1618 unable to install to folder with DN syntax.

---
 opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java         |    7 ++-
 opends/src/server/org/opends/server/util/CertificateManager.java               |    2 
 opends/src/quicksetup/org/opends/quicksetup/util/ExternalTools.java            |    5 +-
 opends/src/server/org/opends/server/tools/ConfigureWindowsService.java         |    3 +
 opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java                 |    6 ++-
 opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelController.java |    6 ++-
 opends/src/quicksetup/org/opends/quicksetup/util/Utils.java                    |   12 ++++++
 opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java              |    3 +
 opends/src/server/org/opends/server/util/SetupUtils.java                       |   23 +++++++++++
 9 files changed, 55 insertions(+), 12 deletions(-)

diff --git a/opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelController.java b/opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelController.java
index 5dccc3d..62b3f8e 100644
--- a/opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelController.java
+++ b/opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelController.java
@@ -560,7 +560,8 @@
 
     ArrayList<String> argList = new ArrayList<String>();
     Installation installation = Installation.getLocal();
-    argList.add(Utils.getPath(installation.getServerStartCommandFile()));
+    argList.add(Utils.getScriptPath(
+        Utils.getPath(installation.getServerStartCommandFile())));
 
     String[] args = new String[argList.size()];
     argList.toArray(args);
@@ -674,7 +675,8 @@
 
     ArrayList<String> argList = new ArrayList<String>();
     Installation installation = Installation.getLocal();
-    argList.add(Utils.getPath(installation.getServerStopCommandFile()));
+    argList.add(Utils.getScriptPath(
+        Utils.getPath(installation.getServerStopCommandFile())));
     String[] args = new String[argList.size()];
     argList.toArray(args);
     ProcessBuilder pb = new ProcessBuilder(args);
diff --git a/opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java b/opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java
index fda36d4..1b4b777 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java
@@ -90,7 +90,8 @@
           throws ApplicationException {
     BuildInformation bi = new BuildInformation();
     List<String> args = new ArrayList<String>();
-    args.add(Utils.getPath(installation.getServerStartCommandFile()));
+    args.add(Utils.getScriptPath(
+        Utils.getPath(installation.getServerStartCommandFile())));
     args.add("-F"); // full verbose
     ProcessBuilder pb = new ProcessBuilder(args);
     InputStream is = null;
diff --git a/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java b/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java
index eb1e1bc..50ffe25 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetup.java
@@ -398,10 +398,12 @@
           if (isMacOS()) {
             ArrayList<String> cmd = new ArrayList<String>();
             cmd.add(MAC_APPLICATIONS_OPENER);
-            cmd.add(getPath(installation.getStatusPanelCommandFile()));
+            cmd.add(getScriptPath(
+                getPath(installation.getStatusPanelCommandFile())));
             pb = new ProcessBuilder(cmd);
           } else {
-            String cmd = getPath(installation.getStatusPanelCommandFile());
+            String cmd = getScriptPath(
+                getPath(installation.getStatusPanelCommandFile()));
             pb = new ProcessBuilder(cmd);
           }
           Map<String, String> env = pb.environment();
diff --git a/opends/src/quicksetup/org/opends/quicksetup/util/ExternalTools.java b/opends/src/quicksetup/org/opends/quicksetup/util/ExternalTools.java
index 9d220d2..6ee2df0 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/util/ExternalTools.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/util/ExternalTools.java
@@ -72,7 +72,8 @@
           throws IOException, InterruptedException {
     String toolName = Installation.BACKUP;
     List<String> args = new ArrayList<String>();
-    args.add(Utils.getPath(installation.getCommandFile(toolName)));
+    args.add(Utils.getScriptPath(
+        Utils.getPath(installation.getCommandFile(toolName))));
     args.add("-a"); // backup all
     args.add("-d"); // backup to directory
     args.add(Utils.getPath(backupDir));
@@ -94,7 +95,7 @@
     List<String> args = new ArrayList<String>();
     args.add(Utils.getPath(installation.getCommandFile(toolName)));
     args.add("-s"); // source LDIF
-    args.add(Utils.getPath(source));
+    args.add(Utils.getScriptPath(Utils.getPath(source)));
     args.add("-t"); // target LDIF
     args.add(Utils.getPath(target));
     if (otherArgs != null) {
diff --git a/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java b/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java
index f3d4c99..53e15f5 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/util/ServerController.java
@@ -124,7 +124,8 @@
       LOG.log(Level.INFO, "stopping server");
 
       ArrayList<String> argList = new ArrayList<String>();
-      argList.add(Utils.getPath(installation.getServerStopCommandFile()));
+      argList.add(Utils.getScriptPath(
+          Utils.getPath(installation.getServerStopCommandFile())));
       String[] args = new String[argList.size()];
       argList.toArray(args);
       ProcessBuilder pb = new ProcessBuilder(args);
@@ -285,7 +286,8 @@
     LOG.log(Level.INFO, "starting server");
 
     ArrayList<String> argList = new ArrayList<String>();
-    argList.add(Utils.getPath(installation.getServerStartCommandFile()));
+    argList.add(Utils.getScriptPath(
+        Utils.getPath(installation.getServerStartCommandFile())));
     String[] args = new String[argList.size()];
     argList.toArray(args);
     ProcessBuilder pb = new ProcessBuilder(args);
@@ -298,7 +300,6 @@
     // 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();
diff --git a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
index a50ccf5..63efce0 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -134,6 +134,18 @@
   }
 
   /**
+   * Returns the String that can be used to launch an script using Runtime.exec.
+   * This method is required because in Windows the script that contain a "="
+   * in their path must be quoted.
+   * @param script the script name
+   * @return the absolute path for the given parentPath and relativePath.
+   */
+  public static String getScriptPath(String script)
+  {
+    return SetupUtils.getScriptPath(script);
+  }
+
+  /**
    * Returns the absolute path for the given parentPath and relativePath.
    * @param f File to get the path
    * @return the absolute path for the given parentPath and relativePath.
diff --git a/opends/src/server/org/opends/server/tools/ConfigureWindowsService.java b/opends/src/server/org/opends/server/tools/ConfigureWindowsService.java
index d0a10b3..b3c29d8 100644
--- a/opends/src/server/org/opends/server/tools/ConfigureWindowsService.java
+++ b/opends/src/server/org/opends/server/tools/ConfigureWindowsService.java
@@ -773,7 +773,8 @@
    */
   private static String getBinaryFullPath()
   {
-    return getServerRoot()+"\\lib\\opends_service.exe";
+    return SetupUtils.getScriptPath(
+        getServerRoot()+"\\lib\\opends_service.exe");
   }
 
   /**
diff --git a/opends/src/server/org/opends/server/util/CertificateManager.java b/opends/src/server/org/opends/server/util/CertificateManager.java
index 70b6415..512c7c4 100644
--- a/opends/src/server/org/opends/server/util/CertificateManager.java
+++ b/opends/src/server/org/opends/server/util/CertificateManager.java
@@ -152,7 +152,7 @@
       keytoolCommand = null;
     }
 
-    KEYTOOL_COMMAND = keytoolCommand;
+    KEYTOOL_COMMAND = SetupUtils.getScriptPath(keytoolCommand);
   }
 
 
diff --git a/opends/src/server/org/opends/server/util/SetupUtils.java b/opends/src/server/org/opends/server/util/SetupUtils.java
index 963d434..08716ff 100644
--- a/opends/src/server/org/opends/server/util/SetupUtils.java
+++ b/opends/src/server/org/opends/server/util/SetupUtils.java
@@ -487,5 +487,28 @@
   {
     return "true".equals(System.getProperty(IS_WEBSTART));
   }
+
+  /**
+   * Returns the String that can be used to launch an script using Runtime.exec.
+   * This method is required because in Windows the script that contain a "="
+   * in their path must be quoted.
+   * @param script the script name
+   * @return the absolute path for the given parentPath and relativePath.
+   */
+  public static String getScriptPath(String script)
+  {
+    String s = script;
+    if (isWindows())
+    {
+      if (s != null)
+      {
+        if (!s.startsWith("\"") || !s.endsWith("\""))
+        {
+          s = "\""+script+"\"";
+        }
+      }
+    }
+    return s;
+  }
 }
 

--
Gitblit v1.10.0