Updates to processing Zip Archive

Added the ability to process zip of zips
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 1e2be10..7d4737f 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
@@ -14,6 +14,7 @@
 
 import java.io.BufferedReader;
 import java.io.BufferedWriter;
+import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileReader;
@@ -34,7 +35,6 @@
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.Date;
-import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -45,6 +45,7 @@
 import java.util.concurrent.TimeUnit;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
+import java.util.zip.ZipInputStream;
 
 import javax.swing.text.html.HTMLEditorKit;
 
@@ -154,6 +155,7 @@
 import org.openhealthtools.mdht.uml.cda.hitsp.HITSPPackage;
 
 import com.google.common.base.Stopwatch;
+import com.google.common.io.ByteStreams;
 
 public class GenerateCDADataHandler extends GenerateCDABaseHandler {
 
@@ -556,8 +558,14 @@
 
 				}
 
-			}
-			if (selection instanceof IStructuredSelection) {
+				if (completed) {
+					for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
+						project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+					}
+					PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+				}
+
+			} else if (selection instanceof IStructuredSelection) {
 
 				final IStructuredSelection iss = (IStructuredSelection) selection;
 
@@ -1117,6 +1125,34 @@
 		return path;
 	}
 
+	private void processZipFile(String prefix, ArrayList<IFile> documents, ZipInputStream zipInputStream)
+			throws IOException {
+
+		ZipEntry entry;
+		while ((entry = zipInputStream.getNextEntry()) != null) {
+			/*
+			 * What is not obvious from the documentation on ZipInputStream
+			 * is the getNextEntry() modifies the zipInputStream state such that the input stream itself is now the entry
+			 *
+			 */
+			if (!entry.isDirectory()) {
+				if ("XML".equalsIgnoreCase(FilenameUtils.getExtension(entry.getName()))) {
+					// zipInputStream is now the input stream for the xml document
+					byte[] buffer = ByteStreams.toByteArray(zipInputStream);
+					ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(buffer);
+					WrapperForZipEnty wrapper = new WrapperForZipEnty(prefix, entry, byteArrayInputStream);
+					documents.add(wrapper);
+				}
+				if ("ZIP".equalsIgnoreCase(FilenameUtils.getExtension(entry.getName()))) {
+					// zipInputStream is now the input stream of the archive
+					ZipInputStream embeddedZipInputStream = new ZipInputStream(zipInputStream);
+					processZipFile(prefix + "/" + entry.getName(), documents, embeddedZipInputStream);
+				}
+			}
+		}
+
+	}
+
 	void processSelection(IFolder selectedFolder, IFile selectedFile, IProgressMonitor monitor, String splitOption,
 			HashSet<EClass> sectionFilter, HashMap<EClass, HashSet<EClass>> theSectionCache) throws Exception {
 
@@ -1185,20 +1221,6 @@
 			}
 		};
 
-		/*
-		 * zipFile
-		 *
-		 * for (Enumeration e = zp.entries(); e.hasMoreElements();) {
-		 * ZipEntry zipEntry = (ZipEntry) e.nextElement();
-		 * ClinicalDocument cd = CDAUtil.load(zp.getInputStream(zipEntry));
-		 * CDAUtil.save(cd, System.out);
-		 *
-		 *
-		 * }
-		 */
-
-		// zipFile.entries().
-		// folder.members().length + 50
 		ArrayList<IFile> documents = new ArrayList<IFile>();
 
 		IFolder folder = null;
@@ -1213,18 +1235,8 @@
 		}
 
 		if (selectedFile != null) {
-
 			folder = (IFolder) selectedFile.getParent();
-			ZipFile zipFile = new ZipFile(selectedFile.getLocation().toOSString());
-
-			WrapperForZipEnty.zipFile = zipFile;
-
-			for (Enumeration<?> e = zipFile.entries(); e.hasMoreElements();) {
-				ZipEntry zipEntry = (ZipEntry) e.nextElement();
-
-				WrapperForZipEnty wrapper = new WrapperForZipEnty(zipEntry);
-				documents.add(wrapper);
-			}
+			processZipFile(selectedFile.getName(), documents, new ZipInputStream(selectedFile.getContents()));
 		}
 
 		fileCount = documents.size() + 50;
@@ -1298,8 +1310,6 @@
 						if (!omitValidation) {
 							vr = new ValidationResult();
 						}
-						// ValidationResult result = new ValidationResult();
-						// System.out.println("\n***** Sample validation results *****");
 
 						clinicalDocument = CDAUtil.load(is, vr);
 						console.println("End Load " + stopwatch.elapsed(TimeUnit.MILLISECONDS));
@@ -1687,17 +1697,30 @@
 	 */
 	private static class WrapperForZipEnty implements IFile {
 
-		static ZipFile zipFile;
+		ZipFile zipFile;
 
 		ZipEntry zipEntry;
 
+		InputStream inputStream;
+
+		String prefix = "";
+
 		/**
 		 * @param zipEntry
 		 */
-		public WrapperForZipEnty(ZipEntry zipEntry) {
+		public WrapperForZipEnty(ZipFile zipFile, ZipEntry zipEntry) {
+			this.zipFile = zipFile;
 			this.zipEntry = zipEntry;
 		}
 
+		public WrapperForZipEnty(String prefix, ZipEntry zipEntry, InputStream inputStream) {
+			this.prefix = prefix;
+			this.zipEntry = zipEntry;
+			this.inputStream = inputStream;
+			// this.zipFile = zipFile;
+			// this.zipEntry = zipEntry;
+		}
+
 		/*
 		 * (non-Javadoc)
 		 *
@@ -1802,7 +1825,11 @@
 		@Override
 		public InputStream getContents() throws CoreException {
 			try {
-				return zipFile.getInputStream(this.zipEntry);
+				if (this.inputStream != null) {
+					return this.inputStream;
+				} else {
+					return zipFile.getInputStream(this.zipEntry);
+				}
 			} catch (IOException e) {
 				throw new CoreException(null);
 			}
@@ -2701,7 +2728,7 @@
 		 */
 		@Override
 		public String getName() {
-			return zipEntry.getName();
+			return prefix + zipEntry.getName();
 		}
 
 		/*