fixing several GD# -- see green colors
[jalview.git] / src / jalview / javascript / web / ClientResponse.java
1 package jalview.javascript.web;
2
3 import java.net.URI;
4
5 /**
6  * minimal implementation of com.sun.jersey.api.client.ClientResponse
7  * 
8  * @author hansonr
9  *
10  */
11 public class ClientResponse
12 {
13   
14   private String response;
15   private String[] encoding;
16
17   public ClientResponse(String response, String... encoding) 
18   {
19     this.response = response;
20     this.encoding = encoding;
21   }
22
23   public String getEntity(Class<?> c)
24   {  
25     
26     // c will be String.class
27     
28     return response;
29   }
30
31   // 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
32   
33 //{
34 //"responseHeader":{
35 //  "status":0,
36 //  "QTime":0,
37 //  "params":{
38 //    "q":"(text:q93xj9_soltu) AND molecule_sequence:['' TO *] AND status:REL",
39 //    "fl":"pdb_id,title,experimental_method,resolution",
40 //    "start":"0",
41 //    "sort":"overall_quality desc",
42 //    "rows":"500",
43 //    "wt":"json"}},
44 //"response":{"numFound":1,"start":0,"docs":[
45 //    {
46 //      "experimental_method":["X-ray diffraction"],
47 //      "pdb_id":"4zhp",
48 //      "resolution":2.46,
49 //      "title":"The crystal structure of Potato ferredoxin I with 2Fe-2S cluster"}]
50 //}}
51 //
52
53   public int getStatus()
54   {
55     // note, we could get the actual response. I am just assuming it is 200 or 400
56     return (response != null && (response.startsWith("{") == encoding[0].equals("application/json"))
57             ? 200 : 400);
58   }
59
60 }