From 508d3949e86d0fd27885d1b825889a80d7a46ee7 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 17 May 2013 13:58:41 +0000
Subject: [PATCH] OPENDJ-842 (CR-1699) On Windows, the setup command hangs when the length of the install path is too long

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

diff --git a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
index 2228310..1efbf14 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -27,7 +27,6 @@
  */
 package org.opends.quicksetup.util;
 
-import org.opends.messages.Message;
 import static org.opends.messages.QuickSetupMessages.*;
 
 import java.io.BufferedOutputStream;
@@ -68,16 +67,16 @@
 import org.opends.admin.ads.SuffixDescriptor;
 import org.opends.admin.ads.TopologyCacheException;
 import org.opends.admin.ads.util.ConnectionUtils;
+import org.opends.messages.Message;
+import org.opends.messages.MessageBuilder;
+import org.opends.messages.MessageDescriptor;
 import org.opends.quicksetup.*;
 import org.opends.quicksetup.installer.AuthenticationData;
 import org.opends.quicksetup.installer.DataReplicationOptions;
 import org.opends.quicksetup.installer.NewSuffixOptions;
 import org.opends.quicksetup.installer.SuffixesToReplicateOptions;
 import org.opends.quicksetup.ui.UIFactory;
-
 import org.opends.server.util.SetupUtils;
-import org.opends.messages.MessageBuilder;
-import org.opends.messages.MessageDescriptor;
 
 
 /**
@@ -197,6 +196,7 @@
             // in the logger and then kill the process.
             Thread t = new Thread(new Runnable()
             {
+              @Override
               public void run()
               {
                 try
@@ -1107,19 +1107,7 @@
     /* Get the install path from the Class Path */
     String sep = System.getProperty("path.separator");
     String[] classPaths = System.getProperty("java.class.path").split(sep);
-    String path = null;
-    for (int i = 0; i < classPaths.length && (path == null); i++)
-    {
-      for (int j = 0; j < Installation.OPEN_DS_JAR_RELATIVE_PATHS.length &&
-      (path == null); j++)
-      {
-        String normPath = classPaths[i].replace(File.separatorChar, '/');
-        if (normPath.endsWith(Installation.OPEN_DS_JAR_RELATIVE_PATHS[j]))
-        {
-          path = classPaths[i];
-        }
-      }
-    }
+    String path = getInstallPath(classPaths);
     if (path != null) {
       File f = new File(path).getAbsoluteFile();
       File librariesDir = f.getParentFile();
@@ -1141,6 +1129,19 @@
     return installPath;
   }
 
+  private static String getInstallPath(final String[] classPaths)
+  {
+    for (String classPath : classPaths)
+    {
+      final String normPath = classPath.replace(File.separatorChar, '/');
+      if (normPath.endsWith(Installation.OPENDJ_BOOTSTRAP_JAR_RELATIVE_PATH))
+      {
+        return classPath;
+      }
+    }
+    return null;
+  }
+
   /**
    * Returns the path of the installation of the directory server.  Note that
    * this method assumes that this code is being run locally.
@@ -1455,9 +1456,7 @@
    * @return true if the string contains HTML
    */
   static public boolean containsHtml(String text) {
-    return (text != null &&
-            text.indexOf('<') != -1 &&
-            text.indexOf('>') != -1);
+    return text != null && text.indexOf('<') != -1 && text.indexOf('>') != -1;
   }
 
   private static EmptyPrintStream emptyStream = new EmptyPrintStream();
@@ -1941,13 +1940,9 @@
     builder.append(formatter.getFormattedProgress(Message.raw(cmd.get(0))));
     int initialIndex = 1;
     StringBuilder sbSeparator = new StringBuilder();
-    if (Utils.isWindows())
+    sbSeparator.append(formatter.getSpace());
+    if (!Utils.isWindows())
     {
-      sbSeparator.append(formatter.getSpace());
-    }
-    else
-    {
-      sbSeparator.append(formatter.getSpace());
       sbSeparator.append("\\");
       sbSeparator.append(formatter.getLineBreak());
       for (int i=0 ; i < 10 ; i++)
@@ -2576,6 +2571,7 @@
   /**
    * {@inheritDoc}
    */
+  @Override
   public void println(String msg)
   {
     LOG.log(Level.INFO, "EmptyStream msg: "+msg);

--
Gitblit v1.10.0