From c569573347162c7221303de2aed30e8c5fe4beda Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Mon, 20 Nov 2006 16:59:18 +0000
Subject: [PATCH] The following modifications are targeted to improve the output displayed by the Java WebStart Setup. There were two issues with the existing code:
---
opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties | 2 +
opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartDownloader.java | 77 +++++++++++++++++++++++++++++++++-----
opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java | 34 +++++++++++++----
3 files changed, 94 insertions(+), 19 deletions(-)
diff --git a/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartDownloader.java b/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartDownloader.java
index 4b82688..61e2bb2 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartDownloader.java
+++ b/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;
}
/**
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 a5cbccb..490e944 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java
+++ b/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[] arg =
- { String.valueOf(perc) };
- String summary = getMsg("downloading-ratio", arg);
+ 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) };
+
+ summary = getMsg("downloading-ratio", arg);
+ }
hmSummary.put(InstallProgressStep.DOWNLOADING, summary);
notifyListeners(ratio, summary, null);
diff --git a/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties b/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
index 59d2c03..140b26b 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
+++ b/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 \
--
Gitblit v1.10.0