return null;
}
try {
- rfile.seek(entrypos.longValue());
+ jstream.reset();
+ ZipEntry entry = null;
+ long epos = entrypos.longValue();
+ do {
+ entry = jstream.getNextEntry();
+ } while (entry!=null && epos-->0);
+ // rfile.seek(entrypos.longValue());
// make a Jar entry from a zip entry.
-
- return new JarEntry(jstream.getNextEntry());
+ return new JarEntry(entry);
}
catch (Exception e) {
log.warn("Whilst seeking for "+entryname, e);
--- /dev/null
+package org.vamsas.test.simpleclient;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.vamsas.client.simpleclient.SessionFile;
+import org.vamsas.client.simpleclient.VamsasArchiveReader;
+import org.vamsas.client.simpleclient.VamsasFile;
+import org.vamsas.objects.core.VAMSAS;
+import org.vamsas.objects.core.VamsasDocument;
+
+public class ArchiveStreamReader {
+ /**
+ * tests VamsasArchiveReader archive reader on a vamsas jar file opened as a stream
+ * @param args
+ */
+ public static void main(String args[]) {
+
+ try {
+ VamsasFile av = new VamsasFile(new File(args[0]));
+ VamsasArchiveReader var = new VamsasArchiveReader(av.getLock());
+ VAMSAS roots[]=null;
+ if (var.isValid()) {
+ InputStreamReader vdoc = new InputStreamReader(var.getVamsasDocumentStream());
+ VamsasDocument doc = VamsasDocument.unmarshal(vdoc);
+ if (ArchiveReports.reportDocument(doc, var, true, System.out)) {
+ roots = doc.getVAMSAS();
+ }
+ } else {
+ InputStream vxmlis = var.getVamsasXmlStream();
+
+ if (vxmlis!=null) { // Might be an old vamsas file.
+ BufferedInputStream ixml = new BufferedInputStream(var.getVamsasXmlStream());
+ InputStreamReader vxml = new InputStreamReader(ixml);
+ VAMSAS root;
+ // unmarshal seems to always close the stream (should check this)
+ if ((root = VAMSAS.unmarshal(vxml))!=null) {
+ System.out.println("Read a root.");
+ roots = new VAMSAS[1];
+ roots[0] = root;
+ }
+ }
+ }
+ if (!ArchiveReports.rootReport(roots, true, System.out))
+ System.err.print(args[0]+" is not a valid vamsas archive.");
+ } catch (Exception e) {
+ e.printStackTrace(System.err);
+ }
+ }
+}