From 2d118fd1628a2305ba510fe75a8ffa07b7006be4 Mon Sep 17 00:00:00 2001 From: jprocter Date: Tue, 18 Sep 2007 10:24:42 +0000 Subject: [PATCH] really simple test for accessibility of a zip file (used to check for pathological vamsas archives that are created but cannot then be re-opened leading to all session data being lost after an update). git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@473 be28352e-c001-0410-b1a7-c7978e42abec --- src/uk/ac/vamsas/test/simpleclient/ZipTest.java | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/uk/ac/vamsas/test/simpleclient/ZipTest.java diff --git a/src/uk/ac/vamsas/test/simpleclient/ZipTest.java b/src/uk/ac/vamsas/test/simpleclient/ZipTest.java new file mode 100644 index 0000000..0c6fa11 --- /dev/null +++ b/src/uk/ac/vamsas/test/simpleclient/ZipTest.java @@ -0,0 +1,34 @@ +package uk.ac.vamsas.test.simpleclient; + +import java.io.File; +import java.util.jar.JarFile; +/** + * really simple test to see if we can open an archive and test for the existence of + * an entry called vamssDocument.xml. + * + * 'Pathological' archives fail this test (due to things like funny characters or lots of '.' in the entry name. + * + * @author JimP + * + */ +public class ZipTest { + + /** + * @param args single filename as an argument to open as a Jar file. + */ + public static void main(String[] args) { + File av = new File(args[0]); + try { + JarFile jf = new JarFile(av, false, JarFile.OPEN_READ); + if (jf.getEntry("vamsasDocument.xml")!=null) + { + System.out.println("Valid archive "+av); + } + jf.close(); + } catch (Exception f) + { + System.out.println("Couldn't access jar archive "+av); + f.printStackTrace(System.out); + } + } +} -- 1.7.10.2