From a4ac34fe8be4d0a19a494298b8652126a796a185 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 18 Mar 2015 20:29:08 +0000 Subject: [PATCH] JAL-1675 Chimera highlight side-chain; timeout added to REST calls --- src/ext/edu/ucsf/rbvi/strucviz2/ChimeraManager.java | 4 ++-- src/jalview/ext/paradise/Annotate3D.java | 4 +--- src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java | 4 ++-- src/jalview/ws/HttpClientUtils.java | 14 +++++++++++++- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/ext/edu/ucsf/rbvi/strucviz2/ChimeraManager.java b/src/ext/edu/ucsf/rbvi/strucviz2/ChimeraManager.java index 2c40e1c..b74e65a 100644 --- a/src/ext/edu/ucsf/rbvi/strucviz2/ChimeraManager.java +++ b/src/ext/edu/ucsf/rbvi/strucviz2/ChimeraManager.java @@ -783,8 +783,8 @@ public class ChimeraManager List reply = new ArrayList(); BufferedReader response = null; try { - response = HttpClientUtils.doHttpUrlPost(restUrl, - commands); + response = HttpClientUtils + .doHttpUrlPost(restUrl, commands, 100, 2000); String line = ""; while ((line = response.readLine()) != null) { reply.add(line); diff --git a/src/jalview/ext/paradise/Annotate3D.java b/src/jalview/ext/paradise/Annotate3D.java index 80b2ab8..68625bc 100644 --- a/src/jalview/ext/paradise/Annotate3D.java +++ b/src/jalview/ext/paradise/Annotate3D.java @@ -29,7 +29,6 @@ import java.io.Reader; import java.io.StringReader; import java.net.URL; import java.util.ArrayList; -import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -37,7 +36,6 @@ import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; import org.json.simple.JSONArray; import org.json.simple.JSONObject; -import org.json.simple.JSONStreamAware; import org.json.simple.parser.ContentHandler; import org.json.simple.parser.ParseException; @@ -138,7 +136,7 @@ public class Annotate3D // return processJsonResponseFor(HttpClientUtils.doHttpUrlPost(twoDtoolsURL, // vals)); ArrayList readers = new ArrayList(); - readers.add(HttpClientUtils.doHttpUrlPost(twoDtoolsURL, vals)); + readers.add(HttpClientUtils.doHttpUrlPost(twoDtoolsURL, vals, 0, 0)); return readers.iterator(); } diff --git a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java index f7c29da..9d1ed43 100644 --- a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java +++ b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java @@ -865,11 +865,11 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel StringBuilder command = new StringBuilder(32); if (lastMousedOverAtomSpec != null) { - command.append("~select " + lastMousedOverAtomSpec + ";"); + command.append("~show " + lastMousedOverAtomSpec + ";"); } viewerCommandHistory(false); + command.append("show ").append(atomSpec); String cmd = command.toString(); - cmd = "select " + atomSpec; if (cmd.length() > 0) { viewer.sendChimeraCommand(cmd, false); diff --git a/src/jalview/ws/HttpClientUtils.java b/src/jalview/ws/HttpClientUtils.java index c416aa5..c6d6629 100644 --- a/src/jalview/ws/HttpClientUtils.java +++ b/src/jalview/ws/HttpClientUtils.java @@ -43,6 +43,7 @@ import org.apache.http.entity.mime.content.StringBody; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.params.BasicHttpParams; import org.apache.http.params.CoreProtocolPNames; +import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; /** @@ -65,12 +66,23 @@ public class HttpClientUtils * @throws Exception */ public static BufferedReader doHttpUrlPost(String postUrl, - List vals) throws ClientProtocolException, + List vals, int connectionTimeoutMs, + int readTimeoutMs) throws ClientProtocolException, IOException { + // todo use HttpClient 4.3 or later and class RequestConfig HttpParams params = new BasicHttpParams(); params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); + if (connectionTimeoutMs > 0) + { + HttpConnectionParams + .setConnectionTimeout(params, connectionTimeoutMs); + } + if (readTimeoutMs > 0) + { + HttpConnectionParams.setSoTimeout(params, readTimeoutMs); + } HttpClient httpclient = new DefaultHttpClient(params); HttpPost httppost = new HttpPost(postUrl); UrlEncodedFormEntity ue = new UrlEncodedFormEntity(vals, "UTF-8"); -- 1.7.10.2