From e7934050009ce7e6f43e2ce7d56c827a23ac287e Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Mon, 26 Feb 2007 21:13:28 +0000
Subject: [PATCH] Centralize the hardcoded strings of the different commands used in the setup and in the control panel in the class Utils.java.

---
 opends/src/statuspanel/org/opends/statuspanel/StatusCli.java                          |    8 -
 opends/src/quicksetup/org/opends/quicksetup/ui/InstallWelcomePanel.java               |    3 
 opends/src/statuspanel/org/opends/statuspanel/StatusPanelController.java              |    6 
 opends/src/statuspanel/org/opends/statuspanel/StatusPanelLauncher.java                |    8 -
 opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java   |    3 
 opends/src/quicksetup/org/opends/quicksetup/installer/InstallLauncher.java            |   12 -
 opends/src/quicksetup/org/opends/quicksetup/util/Utils.java                           |  168 +++++++++++++++++++++++++++++++++
 opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java |    6 
 opends/src/quicksetup/org/opends/quicksetup/QuickSetup.java                           |    6 
 opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java                  |   12 +
 opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java              |    6 
 opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallLauncher.java        |    8 -
 12 files changed, 203 insertions(+), 43 deletions(-)

diff --git a/opends/src/quicksetup/org/opends/quicksetup/QuickSetup.java b/opends/src/quicksetup/org/opends/quicksetup/QuickSetup.java
index 056d119..6019e72 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/QuickSetup.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/QuickSetup.java
@@ -622,7 +622,8 @@
       {
         try
         {
-          String cmd = Utils.isWindows()?"statuspanel.bat":"statuspanel";
+          String cmd = Utils.isWindows()?Utils.getWindowsStatusPanelFileName():
+              Utils.getUnixStatusPanelFileName();
           String serverPath;
           if (Utils.isWebStart())
           {
@@ -632,7 +633,8 @@
           {
             serverPath = Utils.getInstallPathFromClasspath();
           }
-          cmd = Utils.getPath(serverPath, "bin"+File.separator+cmd);
+          cmd = Utils.getPath(serverPath, Utils.getBinariesRelativePath()+
+                  File.separator+cmd);
           ProcessBuilder pb = new ProcessBuilder(new String[]{cmd});
           Map<String, String> env = pb.environment();
           env.put("JAVA_HOME", System.getProperty("java.home"));
diff --git a/opends/src/quicksetup/org/opends/quicksetup/installer/InstallLauncher.java b/opends/src/quicksetup/org/opends/quicksetup/installer/InstallLauncher.java
index d4be8d6..4cd4ecc 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/installer/InstallLauncher.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/installer/InstallLauncher.java
@@ -43,10 +43,6 @@
  */
 public class InstallLauncher
 {
-  private static String COMMAND_NAME_WINDOWS = "setup.bat";
-
-  private static String COMMAND_NAME_UNIX = "setup";
-
   /**
    * The main method which is called by the setup command lines.
    * @param args the arguments passed by the command lines.  In the case
@@ -93,10 +89,10 @@
       String arg;
       if (Utils.isWindows())
       {
-        arg = COMMAND_NAME_WINDOWS;
+        arg = Utils.getWindowsSetupFileName();
       } else
       {
-        arg = COMMAND_NAME_UNIX;
+        arg = Utils.getUnixSetupFileName();
       }
       /*
        * This is required because the usage message contains '{' characters that
@@ -142,11 +138,11 @@
     if (Utils.isWindows())
     {
       System.setProperty("org.opends.server.scriptName",
-          COMMAND_NAME_WINDOWS);
+          Utils.getWindowsSetupFileName());
     } else
     {
       System.setProperty("org.opends.server.scriptName",
-          COMMAND_NAME_UNIX);
+          Utils.getUnixSetupFileName());
     }
     ArrayList<String> newArgList = new ArrayList<String>();
     if (args != null)
diff --git a/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java b/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
index 28f7738..3ecf739 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
@@ -870,10 +870,12 @@
 
     if (Utils.isWindows())
     {
-      argList.add(Utils.getPath(getBinariesPath(), "start-ds.bat"));
+      argList.add(Utils.getPath(getBinariesPath(),
+              Utils.getWindowsStartFileName()));
     } else
     {
-      argList.add(Utils.getPath(getBinariesPath(), "start-ds"));
+      argList.add(Utils.getPath(getBinariesPath(),
+              Utils.getUnixStartFileName()));
     }
 
     String[] args = new String[argList.size()];
@@ -1043,11 +1045,13 @@
     String cmd;
     if (Utils.isWindows())
     {
-      cmd = "bin"+File.separator+"statuspanel.bat";
+      cmd = Utils.getBinariesRelativePath()+File.separator+
+      Utils.getWindowsStatusPanelFileName();
     }
     else
     {
-      cmd = "bin"+File.separator+"statuspanel";
+      cmd = Utils.getBinariesRelativePath()+File.separator+
+      Utils.getUnixStatusPanelFileName();
     }
     cmd = UIFactory.applyFontToHtml(cmd, UIFactory.INSTRUCTIONS_MONOSPACE_FONT);
     String[] args = {formatter.getFormattedText(getInstallationPath()), cmd};
diff --git a/opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java b/opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java
index 7456773..e274335 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java
@@ -152,9 +152,6 @@
       status = InstallProgressStep.FINISHED_SUCCESSFULLY;
       notifyListeners(null);
 
-      if (false)
-        throw new InstallException(InstallException.Type.DOWNLOAD_ERROR,
-            getMsg("error-zipinputstreamnull"), null);
     } catch (InstallException ex)
     {
       if (ex.getCause() != null)
diff --git a/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java b/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java
index caab21c..c1e21f5 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java
@@ -424,7 +424,7 @@
           try
           {
             copyZipEntry(entry, basePath, zipFirstPath, zipIn,
-                ratioBeforeCompleted, ratioWhenCompleted, permissions);
+            ratioBeforeCompleted, ratioWhenCompleted, permissions);
 
           } catch (IOException ioe)
           {
@@ -625,7 +625,8 @@
     } else if (path.endsWith(".sh"))
     {
       perm = "755";
-    } else if (path.endsWith("setup") || path.endsWith("uninstall"))
+    } else if (path.endsWith(Utils.getUnixSetupFileName()) ||
+            path.endsWith(Utils.getUnixUninstallFileName()))
     {
       perm = "755";
     } else
@@ -654,4 +655,3 @@
     return getUserData().getServerLocation();
   }
 }
-
diff --git a/opends/src/quicksetup/org/opends/quicksetup/ui/InstallWelcomePanel.java b/opends/src/quicksetup/org/opends/quicksetup/ui/InstallWelcomePanel.java
index f7b8cec..f01a81a 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/ui/InstallWelcomePanel.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/ui/InstallWelcomePanel.java
@@ -71,7 +71,8 @@
     {
       msgKey = "welcome-panel-webstart-instructions";
       args = new String[3];
-      String cmd = Utils.isWindows()?"setup.bat":"setup";
+      String cmd = Utils.isWindows()?Utils.getWindowsSetupFileName():
+          Utils.getUnixSetupFileName();
       args[0] = UIFactory.applyFontToHtml(cmd,
           UIFactory.INSTRUCTIONS_MONOSPACE_FONT);
       args[1] = org.opends.server.util.DynamicConstants.COMPACT_VERSION_STRING;
diff --git a/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallLauncher.java b/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallLauncher.java
index ccc1290..9f5595e 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallLauncher.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallLauncher.java
@@ -43,10 +43,6 @@
  */
 public class UninstallLauncher
 {
-  private static String COMMAND_NAME_WINDOWS = "uninstall.bat";
-
-  private static String COMMAND_NAME_UNIX = "uninstall";
-
   /**
    * The main method which is called by the uninstall command lines.
    * @param args the arguments passed by the command lines.
@@ -183,10 +179,10 @@
     String arg;
     if (Utils.isWindows())
     {
-      arg = COMMAND_NAME_WINDOWS;
+      arg = Utils.getWindowsUninstallFileName();
     } else
     {
-      arg = COMMAND_NAME_UNIX;
+      arg = Utils.getUnixUninstallFileName();
     }
     /*
      * This is required because the usage message contains '{' characters that
diff --git a/opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java b/opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java
index af96823..f6038e1 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java
@@ -636,10 +636,12 @@
 
     if (Utils.isWindows())
     {
-      argList.add(Utils.getPath(getBinariesPath(), "stop-ds.bat"));
+      argList.add(Utils.getPath(getBinariesPath(),
+              Utils.getWindowsStopFileName()));
     } else
     {
-      argList.add(Utils.getPath(getBinariesPath(), "stop-ds"));
+      argList.add(Utils.getPath(getBinariesPath(),
+              Utils.getUnixStopFileName()));
     }
     String[] args = new String[argList.size()];
     argList.toArray(args);
diff --git a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
index 2ab0749..ce0a509 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -117,6 +117,66 @@
    */
   private static final String CONFIG_FILE_PATH_RELATIVE = "config/config.ldif";
 
+  /**
+   * The UNIX setup script file name.
+   */
+  private static final String UNIX_SETUP_FILE_NAME = "setup";
+
+  /**
+   * The Windows setup batch file name.
+   */
+  private static final String WINDOWS_SETUP_FILE_NAME = "setup.bat";
+
+  /**
+   * The UNIX uninstall script file name.
+   */
+  private static final String UNIX_UNINSTALL_FILE_NAME = "uninstall";
+
+  /**
+   * The Windows uninstall batch file name.
+   */
+  private static final String WINDOWS_UNINSTALL_FILE_NAME = "uninstall.bat";
+
+  /**
+   * The UNIX start script file name.
+   */
+  private static final String UNIX_START_FILE_NAME = "start-ds";
+
+  /**
+   * The Windows start batch file name.
+   */
+  private static final String WINDOWS_START_FILE_NAME = "start-ds.bat";
+
+  /**
+   * The UNIX stop script file name.
+   */
+  private static final String UNIX_STOP_FILE_NAME = "stop-ds";
+
+  /**
+   * The Windows stop batch file name.
+   */
+  private static final String WINDOWS_STOP_FILE_NAME = "stop-ds.bat";
+
+  /**
+   * The UNIX status panel script file name.
+   */
+  private static final String UNIX_STATUSPANEL_FILE_NAME = "statuspanel";
+
+  /**
+   * The Windows status panel batch file name.
+   */
+  private static final String WINDOWS_STATUSPANEL_FILE_NAME = "statuspanel.bat";
+
+  /**
+   * The UNIX status command line script file name.
+   */
+  private static final String UNIX_STATUSCLI_FILE_NAME = "status";
+
+  /**
+   * The Windows status command line batch file name.
+   */
+  private static final String WINDOWS_STATUSCLI_FILE_NAME = "status.bat";
+
   private Utils()
   {
   }
@@ -1090,6 +1150,114 @@
   }
 
   /**
+   * Returns the name of the UNIX setup script file name.
+   * @return the name of the UNIX setup script file name.
+   */
+  public static String getUnixSetupFileName()
+  {
+    return UNIX_SETUP_FILE_NAME;
+  }
+
+  /**
+   * Returns the name of the Windows setup batch file name.
+   * @return the name of the Windows setup batch file name.
+   */
+  public static String getWindowsSetupFileName()
+  {
+    return WINDOWS_SETUP_FILE_NAME;
+  }
+
+  /**
+   * Returns the name of the UNIX uninstall script file name.
+   * @return the name of the UNIX uninstall script file name.
+   */
+  public static String getUnixUninstallFileName()
+  {
+    return UNIX_UNINSTALL_FILE_NAME;
+  }
+
+  /**
+   * Returns the name of the Windows uninstall batch file name.
+   * @return the name of the Windows uninstall batch file name.
+   */
+  public static String getWindowsUninstallFileName()
+  {
+    return WINDOWS_UNINSTALL_FILE_NAME;
+  }
+
+  /**
+   * Returns the name of the UNIX start script file name.
+   * @return the name of the UNIX start script file name.
+   */
+  public static String getUnixStartFileName()
+  {
+    return UNIX_START_FILE_NAME;
+  }
+
+  /**
+   * Returns the name of the Windows start batch file name.
+   * @return the name of the Windows start batch file name.
+   */
+  public static String getWindowsStartFileName()
+  {
+    return WINDOWS_START_FILE_NAME;
+  }
+
+  /**
+   * Returns the name of the UNIX stop script file name.
+   * @return the name of the UNIX stop script file name.
+   */
+  public static String getUnixStopFileName()
+  {
+    return UNIX_STOP_FILE_NAME;
+  }
+
+  /**
+   * Returns the name of the Windows stop batch file name.
+   * @return the name of the Windows stop batch file name.
+   */
+  public static String getWindowsStopFileName()
+  {
+    return WINDOWS_STOP_FILE_NAME;
+  }
+
+  /**
+   * Returns the name of the UNIX status panel script file name.
+   * @return the name of the UNIX status panel script file name.
+   */
+  public static String getUnixStatusPanelFileName()
+  {
+    return UNIX_STATUSPANEL_FILE_NAME;
+  }
+
+  /**
+   * Returns the name of the Windows status panel batch file name.
+   * @return the name of the Windows status panel batch file name.
+   */
+  public static String getWindowsStatusPanelFileName()
+  {
+    return WINDOWS_STATUSPANEL_FILE_NAME;
+  }
+
+  /**
+   * Returns the name of the UNIX status command line script file name.
+   * @return the name of the UNIX status command line script file name.
+   */
+  public static String getUnixStatusCliFileName()
+  {
+    return UNIX_STATUSCLI_FILE_NAME;
+  }
+
+  /**
+   * Returns the name of the Windows status command line batch file name.
+   * @return the name of the Windows status command line batch file name.
+   */
+  public static String getWindowsStatusCliFileName()
+  {
+    return WINDOWS_STATUSCLI_FILE_NAME;
+  }
+
+  /**
    * Displays a confirmation message dialog.
   *
   * @param parent
diff --git a/opends/src/statuspanel/org/opends/statuspanel/StatusCli.java b/opends/src/statuspanel/org/opends/statuspanel/StatusCli.java
index b1bd1b1..346b51f 100644
--- a/opends/src/statuspanel/org/opends/statuspanel/StatusCli.java
+++ b/opends/src/statuspanel/org/opends/statuspanel/StatusCli.java
@@ -74,10 +74,6 @@
    */
   static int BUG = 2;
 
-  private static String COMMAND_NAME_WINDOWS = "status.bat";
-
-  private static String COMMAND_NAME_UNIX = "status";
-
   /**
    * The main method which is called by the status command lines.
    * @param args the arguments passed by the status command lines.
@@ -339,10 +335,10 @@
     String arg;
     if (Utils.isWindows())
     {
-      arg = COMMAND_NAME_WINDOWS;
+      arg = Utils.getWindowsStatusCliFileName();
     } else
     {
-      arg = COMMAND_NAME_UNIX;
+      arg = Utils.getUnixStatusCliFileName();
     }
     /*
      * This is required because the usage message contains '{' characters that
diff --git a/opends/src/statuspanel/org/opends/statuspanel/StatusPanelController.java b/opends/src/statuspanel/org/opends/statuspanel/StatusPanelController.java
index f17ff38..9b866d0 100644
--- a/opends/src/statuspanel/org/opends/statuspanel/StatusPanelController.java
+++ b/opends/src/statuspanel/org/opends/statuspanel/StatusPanelController.java
@@ -658,10 +658,12 @@
 
     if (Utils.isWindows())
     {
-      argList.add(Utils.getPath(getBinariesPath(), "stop-ds.bat"));
+      argList.add(Utils.getPath(getBinariesPath(),
+              Utils.getWindowsStopFileName()));
     } else
     {
-      argList.add(Utils.getPath(getBinariesPath(), "stop-ds"));
+      argList.add(Utils.getPath(getBinariesPath(),
+              Utils.getUnixStopFileName()));
     }
     String[] args = new String[argList.size()];
     argList.toArray(args);
diff --git a/opends/src/statuspanel/org/opends/statuspanel/StatusPanelLauncher.java b/opends/src/statuspanel/org/opends/statuspanel/StatusPanelLauncher.java
index 53466b3..a3750b8 100644
--- a/opends/src/statuspanel/org/opends/statuspanel/StatusPanelLauncher.java
+++ b/opends/src/statuspanel/org/opends/statuspanel/StatusPanelLauncher.java
@@ -39,10 +39,6 @@
  */
 public class StatusPanelLauncher
 {
-  private static String COMMAND_NAME_WINDOWS = "statuspanel.bat";
-
-  private static String COMMAND_NAME_UNIX = "statuspanel";
-
   /**
    * The main method which is called by the control panel command lines.
    * @param args the arguments passed by the command lines.
@@ -124,10 +120,10 @@
     String arg;
     if (Utils.isWindows())
     {
-      arg = COMMAND_NAME_WINDOWS;
+      arg = Utils.getWindowsStatusPanelFileName();
     } else
     {
-      arg = COMMAND_NAME_UNIX;
+      arg = Utils.getUnixStatusPanelFileName();
     }
     /*
      * This is required because the usage message contains '{' characters that

--
Gitblit v1.10.0