From: hansonr Date: Wed, 7 Nov 2018 13:40:57 +0000 (-0600) Subject: JAL-3026-JAL-3063 session test files X-Git-Tag: Release_2_11_4_0~45^2~18^2~425^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=380b48863edc503824ef53482d16058aa3d9a75c;p=jalview.git JAL-3026-JAL-3063 session test files JS loads java50.jvx, but not java50b.jvx. --- diff --git a/src/jalview/project/Jalview2XML.java b/src/jalview/project/Jalview2XML.java index 194cbf2..47a07a0 100644 --- a/src/jalview/project/Jalview2XML.java +++ b/src/jalview/project/Jalview2XML.java @@ -1617,6 +1617,7 @@ public class Jalview2XML // using save and then load try { + fileName = fileName.replace('\\', '/'); System.out.println("Writing jar entry " + fileName); JarEntry entry = new JarEntry(fileName); jout.putNextEntry(entry); @@ -1797,6 +1798,7 @@ public class Jalview2XML { if (jout != null) { + jarEntryName = jarEntryName.replace('\\','/'); System.out.println("Writing jar entry " + jarEntryName); jout.putNextEntry(new JarEntry(jarEntryName)); DataOutputStream dout = new DataOutputStream(jout); @@ -2523,68 +2525,52 @@ public class Jalview2XML return af; } - @SuppressWarnings("unused") -private jarInputStreamProvider createjarInputStreamProvider( - final Object ofile) throws MalformedURLException - { - - // BH 2018 allow for bytes already attached to File object - final String file = ofile.toString(); - byte[] bytes = /** @j2sNative ofile._bytes ||*/null; - if (bytes != null) { - - return new jarInputStreamProvider() - { - - @Override - public JarInputStream getJarInputStream() throws IOException - { - return new JarInputStream(new ByteArrayInputStream(bytes)); - } - - @Override - public String getFilename() - { - return file; - } - }; - + @SuppressWarnings("unused") + private jarInputStreamProvider createjarInputStreamProvider(final Object ofile) throws MalformedURLException { + + // BH 2018 allow for bytes already attached to File object + try { + String file = (ofile instanceof File ? ((File) ofile).getCanonicalPath() : ofile.toString()); + byte[] bytes = /** @j2sNative ofile._bytes || */ + null; + URL url = null; + errorMessage = null; + uniqueSetSuffix = null; + seqRefIds = null; + viewportsAdded.clear(); + frefedSequence = null; + + if (file.startsWith("http://")) { + url = new URL(file); + } + final URL _url = url; + return new jarInputStreamProvider() { + + @Override + public JarInputStream getJarInputStream() throws IOException { + if (bytes != null) { + System.out.println("Jalview2XML: opening byte jarInputStream for bytes.length=" + bytes.length); + return new JarInputStream(new ByteArrayInputStream(bytes)); + } + if (_url != null) { + System.out.println("Jalview2XML: opening url jarInputStream for " + _url); + return new JarInputStream(_url.openStream()); + } else { + System.out.println("Jalview2XML: opening file jarInputStream for " + file); + return new JarInputStream(new FileInputStream(file)); + } + } + + @Override + public String getFilename() { + return file; + } + }; + } catch (IOException e) { + e.printStackTrace(); + return null; + } } - URL url = null; - errorMessage = null; - uniqueSetSuffix = null; - seqRefIds = null; - viewportsAdded.clear(); - frefedSequence = null; - - if (file.startsWith("http://")) - { - url = new URL(file); - } - final URL _url = url; - return new jarInputStreamProvider() - { - - @Override - public JarInputStream getJarInputStream() throws IOException - { - if (_url != null) - { - return new JarInputStream(_url.openStream()); - } - else - { - return new JarInputStream(new FileInputStream(file)); - } - } - - @Override - public String getFilename() - { - return file; - } - }; - } /** * Recover jalview session from a jalview project archive. Caller may @@ -2622,6 +2608,7 @@ private jarInputStreamProvider createjarInputStreamProvider( for (int i = 0; i < entryCount; i++) { jarentry = jin.getNextJarEntry(); + System.out.println("Jalview2XML#loadJalviewAlign: jarentry=" + (jarentry == null ? null : jarentry.getName())); } if (jarentry != null && jarentry.getName().endsWith(".xml")) @@ -2637,7 +2624,7 @@ private jarInputStreamProvider createjarInputStreamProvider( JAXBElement jbe = um .unmarshal(streamReader, JalviewModel.class); JalviewModel object = jbe.getValue(); - + System.out.println("processing JalviewModel object=" + object); /* Unmarshaller unmar = new Unmarshaller(object); unmar.setValidation(false); @@ -2984,6 +2971,7 @@ private jarInputStreamProvider createjarInputStreamProvider( do { entry = jin.getNextJarEntry(); + System.out.println("Jalview2XML#copyJarEntry: jarentry=" + (entry == null ? null : entry.getName())); } while (entry != null && !entry.getName().equals(jarEntryName)); if (entry != null) { @@ -5821,6 +5809,7 @@ private jarInputStreamProvider createjarInputStreamProvider( do { entry = jin.getNextJarEntry(); + System.out.println("Jalview2XML#readJarEntry: jarentry=" + (entry == null ? null : entry.getName())); } while (entry != null && !entry.getName().equals(jarEntryName)); if (entry != null) diff --git a/temp/java50.jvx b/temp/java50.jvx new file mode 100644 index 0000000..8bd396a Binary files /dev/null and b/temp/java50.jvx differ diff --git a/temp/java50b.jvx b/temp/java50b.jvx new file mode 100644 index 0000000..3926122 Binary files /dev/null and b/temp/java50b.jvx differ