JAL-3026 implements simple REST client
[jalview.git] / src / jalview / javascript / web / ClientResponse.java
diff --git a/src/jalview/javascript/web/ClientResponse.java b/src/jalview/javascript/web/ClientResponse.java
new file mode 100644 (file)
index 0000000..e33dd98
--- /dev/null
@@ -0,0 +1,54 @@
+package jalview.javascript.web;
+
+import java.net.URI;
+
+public class ClientResponse
+{
+  
+  private String response;
+  private String encoding;
+
+  public ClientResponse(String response, String encoding) 
+  {
+    this.response = response;
+    this.encoding = encoding;
+  }
+
+  public String getEntity(Class<?> c)
+  {  
+    
+    // c will be String.class
+    
+    return response;
+  }
+
+  // https://www.ebi.ac.uk/pdbe/search/pdb/select?wt=json&fl=pdb_id,title,experimental_method,resolution&rows=500&start=0&q=(text:q93xj9_soltu)+AND+molecule_sequence:%5B%27%27+TO+*%5D+AND+status:REL&sort=overall_quality+desc
+  
+//{
+//"responseHeader":{
+//  "status":0,
+//  "QTime":0,
+//  "params":{
+//    "q":"(text:q93xj9_soltu) AND molecule_sequence:['' TO *] AND status:REL",
+//    "fl":"pdb_id,title,experimental_method,resolution",
+//    "start":"0",
+//    "sort":"overall_quality desc",
+//    "rows":"500",
+//    "wt":"json"}},
+//"response":{"numFound":1,"start":0,"docs":[
+//    {
+//      "experimental_method":["X-ray diffraction"],
+//      "pdb_id":"4zhp",
+//      "resolution":2.46,
+//      "title":"The crystal structure of Potato ferredoxin I with 2Fe-2S cluster"}]
+//}}
+//
+
+  public int getStatus()
+  {
+    // note, we could get the actual response. I am just assuming it is 200 or 400
+    return (response != null && (response.startsWith("{") == encoding.equals("application/json"))
+            ? 200 : 400);
+  }
+
+}