From eebe112fb9a05226379250e0773a43b219be18da Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Wed, 02 May 2007 19:22:13 +0000
Subject: [PATCH] mproves the amount of logging that is done in quicksetup applications. Much of what was simply relayed to the user as progress messages is not logged also.
---
opends/src/quicksetup/org/opends/quicksetup/util/ZipExtractor.java | 38 +++++++++++++++++++++++++++++---------
1 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/opends/src/quicksetup/org/opends/quicksetup/util/ZipExtractor.java b/opends/src/quicksetup/org/opends/quicksetup/util/ZipExtractor.java
index 662e23e..801355b 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/util/ZipExtractor.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/util/ZipExtractor.java
@@ -37,6 +37,8 @@
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
/**
* Class for extracting the contents of a zip file and managing
@@ -44,6 +46,9 @@
*/
public class ZipExtractor {
+ static private final Logger LOG =
+ Logger.getLogger(ZipExtractor.class.getName());
+
private InputStream is;
private int minRatio;
private int maxRatio;
@@ -54,6 +59,18 @@
/**
* Creates an instance of an ZipExtractor.
* @param zipFile File the zip file to extract
+ * @throws FileNotFoundException if the specified file does not exist
+ * @throws IllegalArgumentException if the zip file is not a zip file
+ */
+ public ZipExtractor(File zipFile)
+ throws FileNotFoundException, IllegalArgumentException
+ {
+ this(zipFile, 0, 0, 1, null);
+ }
+
+ /**
+ * Creates an instance of an ZipExtractor.
+ * @param zipFile File the zip file to extract
* @param minRatio int indicating the max ration
* @param maxRatio int indicating the min ration
* @param numberZipEntries number of entries in the input stream
@@ -146,7 +163,7 @@
try
{
copyZipEntry(entry, destination, zipFirstPath, zipIn,
- ratioBeforeCompleted, ratioWhenCompleted, permissions, application);
+ ratioBeforeCompleted, ratioWhenCompleted, permissions);
} catch (IOException ioe)
{
@@ -219,13 +236,11 @@
* copied.
* @param permissions an ArrayList with permissions whose contents will be
* updated.
- * @param app Application to be notified about progress
* @throws IOException if an error occurs.
*/
private void copyZipEntry(ZipEntry entry, String basePath,
String zipFirstPath, ZipInputStream is, int ratioBeforeCompleted,
- int ratioWhenCompleted, Map<String, ArrayList<String>> permissions,
- Application app)
+ int ratioWhenCompleted, Map<String, ArrayList<String>> permissions)
throws IOException
{
String entryName = entry.getName();
@@ -235,10 +250,13 @@
entryName = entryName.substring(zipFirstPath.length());
}
File path = new File(basePath, entryName);
- String progressSummary =
- ResourceProvider.getInstance().getMsg("progress-extracting",
- new String[]{ Utils.getPath(path) });
- app.notifyListeners(ratioBeforeCompleted, progressSummary);
+ if (application != null) {
+ String progressSummary =
+ ResourceProvider.getInstance().getMsg("progress-extracting",
+ new String[]{ Utils.getPath(path) });
+ application.notifyListeners(ratioBeforeCompleted, progressSummary);
+ }
+ LOG.log(Level.INFO, "extracting " + Utils.getPath(path));
if (Utils.insureParentsExist(path))
{
if (entry.isDirectory())
@@ -272,7 +290,9 @@
{
throw new IOException("Could not create parent path: " + path);
}
- application.notifyListenersDone(ratioWhenCompleted);
+ if (application != null) {
+ application.notifyListenersDone(ratioWhenCompleted);
+ }
}
/**
--
Gitblit v1.10.0