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

jvergara
20.59.2006 c569573347162c7221303de2aed30e8c5fe4beda
The following modifications are targeted to improve the output displayed by the Java WebStart Setup.  There were two issues with the existing code:

1. We used to pass the parameter 'overallPercent' of the validating method of WebStartDownloader to calculate the downloaded percentage. This is wrong as this value corresponds to the validation percentage. This produced to sometimes display a downloaded 0 % while we were validating the files.

2. We did not provide any additional feedback while we were validating a jar file. This produced the displayed message to be stuck at 'Downloading: 33 % Completed' or 'Downloading: 66 % Completed'.


The fix for the first issue is trivial: the value indicating the percentage of downloaded files is not modified in the validating method nor in the upgradingArchive method of the WebStartDownloader class.

The fix for the second issue consists of adding some interfaces to WebStartDownloader to know whether we are downloading a jar file, validating a jar file or upgrading a jar file. In addition to that two methods have been added to know how much of the current jar file has been validated or upgraded. This way we can have know a more complete (and lively) message during download. When we are just downloading a jar file the message will stay the same. For example:


'Downloading: 23 % Completed'

But when we are validating a jar file the message will be:

'Downloading: 33% Completed - Validating file: 89 % Completed.
3 files modified
109 ■■■■ changed files
opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartDownloader.java 77 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java 30 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties 2 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartDownloader.java
@@ -63,6 +63,33 @@
  private int currentPercMax = 0;
  private int currentValidatingPercent = 0;
  private int currentUpgradingPercent = 0;
  private Status status = Status.DOWNLOADING;
  /**
   * This enumeration contains the different Status on which
   * the dowloading process of the jars can be.
   *
   */
  public enum Status
    {
    /**
     * Downloading a jar file.
     */
    DOWNLOADING,
    /**
     * Validating a jar file.
     */
    VALIDATING,
    /**
     * Upgrading a jar file.
     */
    UPGRADING
    };
  /**
   * Starts the downloading of the jar files.  If forceDownload is set to
   * <CODE>true</CODE> the files will be re-downloaded even if they already
@@ -84,14 +111,12 @@
          startDownload(forceDownload);
        } catch (MalformedURLException mfe)
        {
          mfe.printStackTrace();
          // This is a bug
          ex =
              new InstallException(InstallException.Type.BUG, getExceptionMsg(
                  "bug-msg", mfe), mfe);
        } catch (IOException ioe)
        {
          ioe.printStackTrace();
          StringBuffer buf = new StringBuffer();
          String[] jars = getJarUrls();
          for (int i = 0; i < jars.length; i++)
@@ -109,7 +134,6 @@
                  getExceptionMsg("downloading-error", arg, ioe), ioe);
        } catch (RuntimeException re)
        {
          re.printStackTrace();
          // This is a bug
          ex =
              new InstallException(InstallException.Type.BUG, getExceptionMsg(
@@ -132,6 +156,15 @@
  }
  /**
   * Returns the Status of the current download process.
   * @return the current status of the download process.
   */
  public Status getStatus()
  {
    return status;
  }
  /**
   * Returns the current download percentage.
   * @return the current download percentage.
   */
@@ -141,6 +174,24 @@
  }
  /**
   * Returns the completed percentage for the file being currently validated.
   * @return the completed percentage for the file being currently validated.
   */
  public int getCurrentValidatingPercentage()
  {
    return currentValidatingPercent;
  }
  /**
   * Returns the completed percentage for the file being currently upgraded.
   * @return the completed percentage for the file being currently upgraded.
   */
  public int getCurrentUpgradingPercentage()
  {
    return currentUpgradingPercent;
  }
  /**
   * Starts synchronously the downloading on this thread.  The thread calling
   * this method will be blocked.  If forceDownload is set to
   * <CODE>true</CODE> the files will be re-downloaded even if they already
@@ -153,8 +204,7 @@
  private void startDownload(boolean forceDownload)
      throws MalformedURLException, IOException
  {
    DownloadService ds;
    DownloadService ds = null;
    try
    {
      ds =
@@ -198,6 +248,7 @@
          // if not in the cache load the resource into the cache
          ds.loadResource(url, version, this);
        }
        downloadPercentage = currentPercMax;
      }
    }
    isFinished = true;
@@ -235,6 +286,7 @@
    {
      downloadPercentage = getPercentage(overallPercent);
    }
    status = Status.DOWNLOADING;
  }
  /**
@@ -243,10 +295,8 @@
  public void upgradingArchive(URL url, String version, int patchPercent,
      int overallPercent)
  {
    if (overallPercent >= 0)
    {
      downloadPercentage = getPercentage(overallPercent);
    }
    currentUpgradingPercent = overallPercent;
    status = Status.UPGRADING;
  }
  /**
@@ -255,10 +305,15 @@
  public void validating(URL url, String version, long entry, long total,
      int overallPercent)
  {
    if (overallPercent >= 0)
    if (total > 0)
    {
      downloadPercentage = getPercentage(overallPercent);
      currentValidatingPercent = (int)((100 * entry) / total);
    }
    else {
      currentValidatingPercent = 0;
    }
    status = Status.VALIDATING;
  }
  /**
opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java
@@ -186,10 +186,6 @@
    } catch (InstallException ex)
    {
      if (ex.getCause() != null)
      {
        ex.getCause().printStackTrace();
      }
      status = InstallProgressStep.FINISHED_WITH_ERROR;
      String html = getHtmlError(ex, true);
      notifyListeners(html);
@@ -330,17 +326,39 @@
  private void waitForLoader(Integer maxRatio) throws InstallException
  {
    int lastPercentage = -1;
    WebStartDownloader.Status lastStatus =
      WebStartDownloader.Status.DOWNLOADING;
    while (!loader.isFinished() && (loader.getException() == null))
    {
      // Pool until is over
      int perc = loader.getDownloadPercentage();
      if (perc != lastPercentage)
      WebStartDownloader.Status downloadStatus = loader.getStatus();
      if ((perc != lastPercentage) || (downloadStatus != lastStatus))
      {
        lastPercentage = perc;
        int ratio = (perc * maxRatio) / 100;
        String summary;
        switch (downloadStatus)
        {
        case VALIDATING:
          String[] argsValidating =
            { String.valueOf(perc),
              String.valueOf(loader.getCurrentValidatingPercentage())};
          summary = getMsg("validating-ratio", argsValidating);
          break;
        case UPGRADING:
          String[] argsUpgrading =
            { String.valueOf(perc),
              String.valueOf(loader.getCurrentUpgradingPercentage())};
          summary = getMsg("upgrading-ratio", argsUpgrading);
          break;
        default:
        String[] arg =
          { String.valueOf(perc) };
        String summary = getMsg("downloading-ratio", arg);
          summary = getMsg("downloading-ratio", arg);
        }
        hmSummary.put(InstallProgressStep.DOWNLOADING, summary);
        notifyListeners(ratio, summary, null);
opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
@@ -322,6 +322,8 @@
progress-extracting=Extracting {0}
progress-configuring=Configuring Directory Server
downloading-ratio=Downloading: {0}% Completed.
validating-ratio=Downloading: {0}% Completed - Validating file: {1} % Completed.
upgrading-ratio=Downloading: {0}% Completed - Upgrading file: {1} % Completed.
progress-creating-base-entry=Creating Base Entry {0}
progress-importing-ldif=Importing LDIF file {0}:
progress-import-automatically-generated=Importing Automatically-Generated Data \