From 1bd232f719d6511cff5dd6ebd7c71255d9813888 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Fri, 10 Sep 2021 14:55:29 +0100 Subject: [PATCH] JAL-3851 changed error response status codes to 201 for jetty reasons. Some example API calls in wget_commands.sh --- src/jalview/rest/AbstractEndpoint.java | 17 +++++++++++++++-- src/jalview/rest/AbstractEndpointAsync.java | 8 +++++++- src/jalview/rest/FetchSequencesEndpoint.java | 2 ++ wget_commands.sh | 10 ++++++++++ 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 wget_commands.sh diff --git a/src/jalview/rest/AbstractEndpoint.java b/src/jalview/rest/AbstractEndpoint.java index 4add269..2d366ea 100644 --- a/src/jalview/rest/AbstractEndpoint.java +++ b/src/jalview/rest/AbstractEndpoint.java @@ -79,8 +79,16 @@ public abstract class AbstractEndpoint implements EndpointI { String okString = request.getParameter("ok"); boolean ok = (okString != null && okString.equalsIgnoreCase("true")); - response.setStatus(ok ? HttpServletResponse.SC_OK - : HttpServletResponse.SC_BAD_REQUEST); + /* + * Annoyingly jetty is not adding content to anything other than a few + * 20x status codes. Possibly it is closing the PrintWriter. + * Find a fix for this! + ****************************************************/ + response.setStatus(ok ? HttpServletResponse.SC_OK : // + // HttpServletResponse.SC_BAD_REQUEST // + HttpServletResponse.SC_PARTIAL_CONTENT // + ); + String endpointName = getPath(); Cache.error(getAPI().getName() + " error: endpoint " + endpointName + " failed: '" + message + "'"); @@ -203,4 +211,9 @@ public abstract class AbstractEndpoint implements EndpointI : afs[0]; } + protected boolean deleteFromCache() + { + return false; + } + } \ No newline at end of file diff --git a/src/jalview/rest/AbstractEndpointAsync.java b/src/jalview/rest/AbstractEndpointAsync.java index 8abb1e9..923b068 100644 --- a/src/jalview/rest/AbstractEndpointAsync.java +++ b/src/jalview/rest/AbstractEndpointAsync.java @@ -202,7 +202,7 @@ public abstract class AbstractEndpointAsync extends AbstractEndpoint response.setStatus(HttpServletResponse.SC_ACCEPTED); break; case IN_PROGRESS: - response.setStatus(HttpServletResponse.SC_NO_CONTENT); + response.setStatus(HttpServletResponse.SC_ACCEPTED); break; case FINISHED: response.setStatus(HttpServletResponse.SC_CREATED); @@ -274,4 +274,10 @@ public abstract class AbstractEndpointAsync extends AbstractEndpoint changeStatus(Status.NOT_RUN); super.returnError(request, response, message); } + + @Override + protected boolean deleteFromCache() + { + return false; + } } diff --git a/src/jalview/rest/FetchSequencesEndpoint.java b/src/jalview/rest/FetchSequencesEndpoint.java index 56c67c6..e547534 100644 --- a/src/jalview/rest/FetchSequencesEndpoint.java +++ b/src/jalview/rest/FetchSequencesEndpoint.java @@ -81,6 +81,8 @@ public class FetchSequencesEndpoint extends AbstractEndpointAsync for (AlignmentViewPanel ap : aps) { AlignmentI al = ap.getAlignment(); + if (al == null) + continue; List seqs = (List) al.getSequences(); for (SequenceI seq : seqs) { diff --git a/wget_commands.sh b/wget_commands.sh new file mode 100644 index 0000000..58fd7c0 --- /dev/null +++ b/wget_commands.sh @@ -0,0 +1,10 @@ +wget -q -S -O - 'http://localhost:2021/jalview/api/fetchsequences/ensembl/ENSG00000139618?id=myBRCA2' +wget -q -S -O - 'http://localhost:2021/jalview/api/getcrossreferences/UNIPROT?fromId=myBRCA2' +wget -q -S -O - "http://localhost:2021/jalview/api/highlightsequence/ENST00000544455/30000?fromId=myBRCA2" +N=22946; while [ $N -lt 23002 ]; do wget -q -S -O - "http://localhost:2021/jalview/api/highlightsequence/ENST00000544455/${N}?fromId=myBRCA2"; N=$((N+1)); sleep 0.2; done +wget -q -S -O - 'http://localhost:2021/jalview/api/selectsequences/*/*?fromId=myBRCA2' +wget -q -S -O - 'http://localhost:2021/jalview/api/selectsequences/*/22946-23001?fromId=myBRCA2' +wget -q -S -O - 'http://localhost:2021/jalview/api/selectsequences/ENSG00000139618,ENST00000544455,ENST00000530893,ENST00000380152,ENST00000680887,ENST00000614259,ENST00000665585,ENST00000528762/22946-23001?fromId=myBRCA2' +wget -q -S -O - 'http://localhost:2021/jalview/api/selectsequences/ENSG00000139618,ENST00000544455,ENST00000380152,ENST00000680887,ENST00000614259,ENST00000528762/22946-23001?fromId=myBRCA2' +### open 3D structure 6hqu and repeat highlight + -- 1.7.10.2