From b13d03cf6a0c29dcb57fae4c4184320af36a90e5 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Thu, 10 Dec 2009 17:00:49 +0000
Subject: [PATCH] Complete a potential fix for issue 4394 (Quicksetup doesn't work with openJDK 1.6 64 bits (fedora core 12))

---
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/webstart/WebStartDownloader.java |   24 +++++++++++++++++-------
 opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java                  |   30 ++++++++++++++++++++++++++++++
 opendj-sdk/opends/src/messages/messages/quicksetup.properties                           |    2 +-
 3 files changed, 48 insertions(+), 8 deletions(-)

diff --git a/opendj-sdk/opends/src/messages/messages/quicksetup.properties b/opendj-sdk/opends/src/messages/messages/quicksetup.properties
index 584b0ea..e002c66 100644
--- a/opendj-sdk/opends/src/messages/messages/quicksetup.properties
+++ b/opendj-sdk/opends/src/messages/messages/quicksetup.properties
@@ -262,7 +262,7 @@
 INFO_DOWNLOADING_ERROR=An error occurred downloading remote file(s) %s.
 INFO_DOWNLOADING_ERROR_NO_SERVICE_FOUND=An error occurred.  Could not find \
  service '%s'.   Setup using JNLP is not supported with your JDK \
- installation.  Download a ZIP installation, un-zip it and run 'setup' to \
+ installation.  Download a ZIP installation, un-zip it and run script %s to \
  install the server.
 INFO_DOWNLOADING_RATIO=Downloading: %s%% Completed.
 INFO_EMPTY_ADMINISTRATOR_PWD=You must provide a Global Administrative User \
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
index 81feb79..21e22f8 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -99,6 +99,12 @@
   private final static String CUSTOMIZATION_CLASS_NAME =
     "org.opends.server.util.ReleaseDefinition";
 
+
+  /**
+   * The service name required by the JNLP downloader.
+   */
+  public static String JNLP_SERVICE_NAME = "javax.jnlp.DownloadService";
+
   /**
    * Enumeration that specify if the operation applies to the install directory
    * only, to the instance directory only, or both.
@@ -1801,6 +1807,30 @@
         }
       }
     }
+    if (Utils.isWebStart())
+    {
+      // Check that the JNLP service exists.
+      try
+      {
+        javax.jnlp.ServiceManager.lookup(JNLP_SERVICE_NAME);
+      }
+      catch (Throwable t)
+      {
+        String setupFile;
+        if (Utils.isWindows())
+        {
+          setupFile = Installation.WINDOWS_SETUP_FILE_NAME;
+        }
+        else
+        {
+          setupFile = Installation.UNIX_SETUP_FILE_NAME;
+        }
+        throw new IncompatibleVersionException(
+            INFO_DOWNLOADING_ERROR_NO_SERVICE_FOUND.get(
+                JNLP_SERVICE_NAME, setupFile),
+            t);
+      }
+    }
   }
 
   /**
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/webstart/WebStartDownloader.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/webstart/WebStartDownloader.java
index 502cb05..781ffb4 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/webstart/WebStartDownloader.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/webstart/WebStartDownloader.java
@@ -41,7 +41,9 @@
 
 
 import org.opends.quicksetup.ApplicationException;
+import org.opends.quicksetup.Installation;
 import org.opends.quicksetup.ReturnCode;
+import org.opends.quicksetup.util.Utils;
 import org.opends.server.util.SetupUtils;
 
 import static org.opends.quicksetup.util.Utils.*;
@@ -61,7 +63,6 @@
   static private final Logger LOG =
     Logger.getLogger(WebStartDownloader.class.getName());
 
-
   /**
    * Returns the name of the zip file name that contains all the installation.
    * @return the name of the zip file name that contains all the installation.
@@ -253,19 +254,28 @@
       throws IOException, ApplicationException
   {
     DownloadService ds;
-    String serviceName = "javax.jnlp.DownloadService";
     try
     {
       ds =
-          (DownloadService) ServiceManager.lookup(
-              "javax.jnlp.DownloadService");
+          (DownloadService) ServiceManager.lookup(Utils.JNLP_SERVICE_NAME);
     } catch (UnavailableServiceException e)
     {
-      LOG.log(Level.SEVERE, "Could not find service: "+serviceName, e);
+      LOG.log(Level.SEVERE, "Could not find service: "+
+          Utils.JNLP_SERVICE_NAME, e);
+      String setupFile;
+      if (Utils.isWindows())
+      {
+        setupFile = Installation.WINDOWS_SETUP_FILE_NAME;
+      }
+      else
+      {
+        setupFile = Installation.UNIX_SETUP_FILE_NAME;
+      }
       throw new ApplicationException(
         ReturnCode.DOWNLOAD_ERROR,
-        getThrowableMsg(
-            INFO_DOWNLOADING_ERROR_NO_SERVICE_FOUND.get(serviceName), e), e);
+        getThrowableMsg(INFO_DOWNLOADING_ERROR_NO_SERVICE_FOUND.get(
+            Utils.JNLP_SERVICE_NAME, setupFile),
+            e), e);
     }
 
     String[] urls = getJarUrls();

--
Gitblit v1.10.0