From: Mateusz Warowny Date: Tue, 12 Mar 2024 12:50:07 +0000 (+0100) Subject: JAL-1601 Read full file before passing to FileParse X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=cc248239489d51080e79783f196e752acf4ee64e;p=jalview.git JAL-1601 Read full file before passing to FileParse FileParse fails to read file from the URL in javascript. It's related to errors in AjaxURLConnection implementation in j2s. --- diff --git a/src/jalview/ws2/client/jpred4/JPred4WSClient.java b/src/jalview/ws2/client/jpred4/JPred4WSClient.java index 3782723..fccd876 100644 --- a/src/jalview/ws2/client/jpred4/JPred4WSClient.java +++ b/src/jalview/ws2/client/jpred4/JPred4WSClient.java @@ -1,5 +1,6 @@ package jalview.ws2.client.jpred4; +import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.List; @@ -113,14 +114,24 @@ public class JPred4WSClient implements SecStructPredWebServiceClientI @Override public AlignFile getAlignmentFile(WebServiceJobHandle job) throws IOException { - var url = client.getResultURL(job.getJobId(), ResultTypes.PSIBLAST_ALIGN); - return new FastaFile(url.toString(), DataSourceType.URL); + var stream = client.getResultStream(job.getJobId(), ResultTypes.PSIBLAST_ALIGN); + var buffer = new byte[2048]; + var file = new ByteArrayOutputStream(); + var len = 0; + while ((len= stream.read(buffer)) >= 0) + file.write(buffer, 0, len); + return new FastaFile(file.toString("UTF-8"), DataSourceType.PASTE); } @Override public JPredFile getPredictionFile(WebServiceJobHandle job) throws IOException { - var url = client.getResultURL(job.getJobId(), ResultTypes.CONCISE); - return new JPredFile(url.toString(), DataSourceType.URL); + var stream = client.getResultStream(job.getJobId(), ResultTypes.CONCISE); + var buffer = new byte[2048]; + var file = new ByteArrayOutputStream(); + var len = 0; + while ((len= stream.read(buffer)) >= 0) + file.write(buffer, 0, len); + return new JPredFile(file.toString("UTF-8"), DataSourceType.PASTE); } }