Updates to zip processing
Modified byte buffer management
diff --git a/cda/plugins/org.eclipse.mdht.cda.xml.ui/src/org/eclipse/mdht/cda/xml/ui/handlers/GenerateCDADataHandler.java b/cda/plugins/org.eclipse.mdht.cda.xml.ui/src/org/eclipse/mdht/cda/xml/ui/handlers/GenerateCDADataHandler.java
index b4a92a4..db043f9 100644
--- a/cda/plugins/org.eclipse.mdht.cda.xml.ui/src/org/eclipse/mdht/cda/xml/ui/handlers/GenerateCDADataHandler.java
+++ b/cda/plugins/org.eclipse.mdht.cda.xml.ui/src/org/eclipse/mdht/cda/xml/ui/handlers/GenerateCDADataHandler.java
@@ -1329,9 +1329,7 @@
if ("XML".equalsIgnoreCase(FilenameUtils.getExtension(entry.getName())) &&
!entry.getName().contains(filesFilter)) {
// zipInputStream is now the input stream for the xml document
- byte[] buffer = ByteStreams.toByteArray(zipInputStream);
- ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(buffer);
- wrapper = new WrapperForZipEnty(prefix, entry, byteArrayInputStream);
+ wrapper = new WrapperForZipEnty(prefix, entry, zipInputStream);
return true;
}
if ("ZIP".equalsIgnoreCase(FilenameUtils.getExtension(entry.getName()))) {
@@ -1343,7 +1341,8 @@
}
}
} else {
- zipInputStreams.pop();
+ ZipInputStream done = zipInputStreams.pop();
+ done.close();
}
} catch (IOException e) {
@@ -1363,13 +1362,23 @@
@Override
public boolean hasNext() {
- if (wrapper != null && wrapper.inputStream != null) {
- try {
- wrapper.inputStream.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
+ // if (wrapper != null && wrapper.zipInputStream != null) {
+ // try {
+ // wrapper.zipInputStream.close();
+ //
+ // } catch (IOException e) {
+ // e.printStackTrace();
+ // }
+ // }
+ //
+ // if (wrapper != null && wrapper.zipFile != null) {
+ // try {
+ // wrapper.zipFile.close();
+ // } catch (IOException e) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // }
+ // }
return walkZipFile(FilenameUtils.getBaseName(fileName));
}
@@ -2243,7 +2252,7 @@
ZipEntry zipEntry;
- InputStream inputStream;
+ ZipInputStream zipInputStream;
String prefix = "";
@@ -2255,10 +2264,10 @@
this.zipEntry = zipEntry;
}
- public WrapperForZipEnty(String prefix, ZipEntry zipEntry, InputStream inputStream) {
+ public WrapperForZipEnty(String prefix, ZipEntry zipEntry, ZipInputStream zipInputStream) {
this.prefix = prefix;
this.zipEntry = zipEntry;
- this.inputStream = inputStream;
+ this.zipInputStream = zipInputStream;
}
/*
@@ -2364,9 +2373,14 @@
*/
@Override
public InputStream getContents() throws CoreException {
+
try {
- if (this.inputStream != null) {
- return this.inputStream;
+ if (this.zipInputStream != null) {
+ byte[] buffer = ByteStreams.toByteArray(zipInputStream);
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(buffer);
+ return byteArrayInputStream;
+
+ // return this.inputStream;
} else {
return zipFile.getInputStream(this.zipEntry);
}