From 95798000b6af5e5805d7be753766e6d2fd5cb4aa Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Fri, 23 Sep 2011 16:17:43 +0000
Subject: [PATCH] Fix OPENDJ-298 - Review screen content is wrong when using QuickSetup. The issue was due to an exception being thrown while building the review screen. The exception was due to the computation of the path of Binaries, incorrect as the Java WebStart Install had not created the install location yet. The fix is to use an alternate way to compute the command path, similar to what was done for setup.

---
 opends/src/quicksetup/org/opends/quicksetup/util/Utils.java |   48 +++++++++++++++---------------------------------
 1 files changed, 15 insertions(+), 33 deletions(-)

diff --git a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
index bdc996f..9ce7c32 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -23,6 +23,7 @@
  *
  *
  *      Copyright 2006-2010 Sun Microsystems, Inc.
+ *      Portions Copyright 2011 ForgeRock AS
  */
 package org.opends.quicksetup.util;
 
@@ -2485,7 +2486,7 @@
       UserData userData, Set<String> baseDNs, ServerDescriptor server)
   {
     ArrayList<String> cmdLine = new ArrayList<String>();
-    String cmdName = getCommandLinePath("dsreplication");
+    String cmdName = getCommandLinePath(userData, "dsreplication");
     cmdLine.add(cmdName);
     cmdLine.add("enable");
 
@@ -2560,50 +2561,31 @@
 
   /**
    * Returns the full path of the command-line for a given script name.
+   * @param userData  the user data.
    * @param scriptBasicName the script basic name (with no extension).
    * @return the full path of the command-line for a given script name.
    */
-  private static String getCommandLinePath(String scriptBasicName)
+  private static String getCommandLinePath(UserData userData,
+                                           String scriptBasicName)
   {
     String cmdLineName;
     if (isWindows())
     {
-      cmdLineName = getBinaryDir()+scriptBasicName+".bat";
+      cmdLineName = getInstallDir(userData)
+          + Installation.WINDOWS_BINARIES_PATH_RELATIVE
+          + File.separatorChar
+          + scriptBasicName + ".bat";
     }
     else
     {
-      cmdLineName = getBinaryDir()+scriptBasicName;
+      cmdLineName = getInstallDir(userData)
+          + Installation.UNIX_BINARIES_PATH_RELATIVE
+          + File.separatorChar
+          + scriptBasicName;
     }
     return cmdLineName;
   }
 
-  private static String binDir;
-  /**
-   * Returns the binary/script directory.
-   * @return the binary/script directory.
-   */
-  private static String getBinaryDir()
-  {
-    if (binDir == null)
-    {
-      File f = Installation.getLocal().getBinariesDirectory();
-      try
-      {
-        binDir = f.getCanonicalPath();
-      }
-      catch (Throwable t)
-      {
-        binDir = f.getAbsolutePath();
-      }
-      if (binDir.lastIndexOf(File.separatorChar) != (binDir.length() - 1))
-      {
-        binDir += File.separatorChar;
-      }
-    }
-
-    return binDir;
-  }
-
   private static String installDir;
   /**
    * Returns the installation directory.
@@ -2645,7 +2627,7 @@
       UserData userData, Set<String> baseDNs, ServerDescriptor server)
   {
     ArrayList<String> cmdLine = new ArrayList<String>();
-    String cmdName = getCommandLinePath("dsreplication");
+    String cmdName = getCommandLinePath(userData, "dsreplication");
     cmdLine.add(cmdName);
     cmdLine.add("initialize");
 
@@ -2774,7 +2756,7 @@
   {
     ArrayList<ArrayList<String>> cmdLines = new ArrayList<ArrayList<String>>();
 
-    String cmdName = getCommandLinePath("dsconfig");
+    String cmdName = getCommandLinePath(userData, "dsconfig");
 
     ArrayList<String> connectionArgs = new ArrayList<String>();
     connectionArgs.add("--hostName");

--
Gitblit v1.10.0