mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

jvergara
10.45.2009 3b280d4ad42d3339f75fa4d0b99138702eb237a3
Commit a potential fix for issue 4394 (Quicksetup doesn't work with openJDK 1.6 64 bits (fedora core 12))

The fix is not really a fix for this, the code silently ignored the non existence of the javax.jnlp.DownloadService. The modifications consist basically on identifying this situation and providing an error message informing of this and of the alternatives the user has to setup OpenDS (download a ZIP file).
2 files modified
179 ■■■■ changed files
opends/src/messages/messages/quicksetup.properties 4 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/webstart/WebStartDownloader.java 175 ●●●● patch | view | raw | blame | history
opends/src/messages/messages/quicksetup.properties
@@ -260,6 +260,10 @@
INFO_DIV_OPEN_SUCCESSFUL_BACKGROUND_3_COLOR=E1E1A7
INFO_DOWNLOADING=Downloading...
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 \
 install the server.
INFO_DOWNLOADING_RATIO=Downloading: %s%% Completed.
INFO_EMPTY_ADMINISTRATOR_PWD=You must provide a Global Administrative User \
 Password.
opends/src/quicksetup/org/opends/quicksetup/webstart/WebStartDownloader.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 */
package org.opends.quicksetup.webstart;
@@ -31,6 +31,8 @@
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jnlp.DownloadService;
import javax.jnlp.DownloadServiceListener;
@@ -56,7 +58,8 @@
 * ProgressStep.DOWNLOADING step.
 */
public class WebStartDownloader implements DownloadServiceListener {
  static private final Logger LOG =
    Logger.getLogger(WebStartDownloader.class.getName());
  /**
@@ -134,6 +137,9 @@
        try
        {
          startDownload(forceDownload);
        } catch (ApplicationException ex)
        {
          WebStartDownloader.this.ex = ex;
        } catch (MalformedURLException mfe)
        {
          // This is a bug
@@ -241,11 +247,13 @@
   * @throws MalformedURLException if there is an error with the URLs that we
   * get from the property SetupUtils.LAZY_JAR_URLS
   * @throws IOException if a network problem occurs.
   * @throws ApplicationException if the download service is not available.
   */
  private void startDownload(boolean forceDownload)
      throws IOException
      throws IOException, ApplicationException
  {
    DownloadService ds;
    String serviceName = "javax.jnlp.DownloadService";
    try
    {
      ds =
@@ -253,97 +261,98 @@
              "javax.jnlp.DownloadService");
    } catch (UnavailableServiceException e)
    {
      ds = null;
      LOG.log(Level.SEVERE, "Could not find service: "+serviceName, e);
      throw new ApplicationException(
        ReturnCode.DOWNLOAD_ERROR,
        getThrowableMsg(
            INFO_DOWNLOADING_ERROR_NO_SERVICE_FOUND.get(serviceName), e), e);
    }
    if (ds != null)
    String[] urls = getJarUrls();
    String[] versions = getJarVersions();
    /*
     * Calculate the percentages that correspond to each file.
     * TODO ideally this should be done dynamically, but as this is just
     * to provide progress, updating this information from time to time can
     * be enough and does not complexify the build process.
     */
    int[] percentageMax = new int[urls.length];
    int[] ratios = new int[urls.length];
    int totalRatios = 0;
    for (int i=0; i<percentageMax.length; i++)
    {
      String[] urls = getJarUrls();
      String[] versions = getJarVersions();
      /*
       * Calculate the percentages that correspond to each file.
       * TODO ideally this should be done dynamically, but as this is just
       * to provide progress, updating this information from time to time can
       * be enough and does not complexify the build process.
       */
      int[] percentageMax = new int[urls.length];
      int[] ratios = new int[urls.length];
      int totalRatios = 0;
      for (int i=0; i<percentageMax.length; i++)
      int ratio;
      if (urls[i].endsWith("OpenDS.jar"))
      {
        int ratio;
        if (urls[i].endsWith("OpenDS.jar"))
        ratio =  23;
      }
      else if (urls[i].endsWith("je.jar"))
      {
        ratio = 11;
      }
      else if (urls[i].endsWith("zipped.jar"))
      {
        ratio = 110;
      }
      else if (urls[i].endsWith("aspectjrt.jar"))
      {
        ratio = 10;
      }
      else
      {
        ratio = (100 / urls.length);
      }
      ratios[i] = ratio;
      totalRatios += ratio;
    }
    for (int i=0; i<percentageMax.length; i++)
    {
      int r = 0;
      for (int j=0; j<=i; j++)
      {
        r += ratios[j];
      }
      percentageMax[i] = (100 * r)/totalRatios;
    }
    for (int i = 0; i < urls.length && (getException() == null); i++)
    {
      if (i == 0)
      {
        currentPercMin = 0;
      }
      else {
        currentPercMin = percentageMax[i-1];
      }
      currentPercMax = percentageMax[i];
      // determine if a particular resource is cached
      String sUrl = urls[i];
      String version = versions[i];
      URL url = new URL(sUrl);
      boolean cached = ds.isResourceCached(url, version);
      if (cached && forceDownload)
      {
        try
        {
          ratio =  23;
        }
        else if (urls[i].endsWith("je.jar"))
          ds.removeResource(url, version);
        } catch (IOException ioe)
        {
          ratio = 11;
        }
        else if (urls[i].endsWith("zipped.jar"))
        {
          ratio = 110;
        }
        else if (urls[i].endsWith("aspectjrt.jar"))
        {
          ratio = 10;
        }
        else
        {
          ratio = (100 / urls.length);
        }
        ratios[i] = ratio;
        totalRatios += ratio;
        cached = false;
      }
      for (int i=0; i<percentageMax.length; i++)
      if (!cached)
      {
        int r = 0;
        for (int j=0; j<=i; j++)
        {
          r += ratios[j];
        }
        percentageMax[i] = (100 * r)/totalRatios;
        // if not in the cache load the resource into the cache
        ds.loadResource(url, version, this);
      }
      for (int i = 0; i < urls.length && (getException() == null); i++)
      {
        if (i == 0)
        {
          currentPercMin = 0;
        }
        else {
          currentPercMin = percentageMax[i-1];
        }
        currentPercMax = percentageMax[i];
        // determine if a particular resource is cached
        String sUrl = urls[i];
        String version = versions[i];
        URL url = new URL(sUrl);
        boolean cached = ds.isResourceCached(url, version);
        if (cached && forceDownload)
        {
          try
          {
            ds.removeResource(url, version);
          } catch (IOException ioe)
          {
          }
          cached = false;
        }
        if (!cached)
        {
          // if not in the cache load the resource into the cache
          ds.loadResource(url, version, this);
        }
        downloadPercentage = currentPercMax;
      }
      downloadPercentage = currentPercMax;
    }
    isFinished = true;
  }