JAL-1675 Chimera highlight side-chain; timeout added to REST calls
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 18 Mar 2015 20:29:08 +0000 (20:29 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 18 Mar 2015 20:29:08 +0000 (20:29 +0000)
src/ext/edu/ucsf/rbvi/strucviz2/ChimeraManager.java
src/jalview/ext/paradise/Annotate3D.java
src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java
src/jalview/ws/HttpClientUtils.java

index 2c40e1c..b74e65a 100644 (file)
@@ -783,8 +783,8 @@ public class ChimeraManager
     List<String> reply = new ArrayList<String>();
     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);
index 80b2ab8..68625bc 100644 (file)
@@ -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<Reader> readers = new ArrayList<Reader>();
-    readers.add(HttpClientUtils.doHttpUrlPost(twoDtoolsURL, vals));
+    readers.add(HttpClientUtils.doHttpUrlPost(twoDtoolsURL, vals, 0, 0));
     return readers.iterator();
 
   }
index f7c29da..9d1ed43 100644 (file)
@@ -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);
index c416aa5..c6d6629 100644 (file)
@@ -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<NameValuePair> vals) throws ClientProtocolException,
+          List<NameValuePair> 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");