Removed dependency for Jersey webservice lib and updated code to use HttpClientUtils...
[jalview.git] / src / jalview / ws / intermine / IntermineFetchClient.java
1 package jalview.ws.intermine;
2
3 import jalview.ws.HttpClientUtils;
4
5 import java.io.IOException;
6
7 import org.apache.http.client.ClientProtocolException;
8
9
10 public class IntermineFetchClient
11 {
12
13
14   public static enum IntermineDB
15   {
16     YeastMine("Yeast Mine", "http://yeastmine.yeastgenome.org/yeastmine"), FlyMine(
17             "Fly Mine", "http://www.flymine.org/query"), FlyMine_Beta(
18                     "Fly Mine Beta",
19                     "http://beta.flymine.org/beta"), MouseMine("Mouse Mine",
20                             "http://www.mousemine.org/mousemine"), modMine(
21                                     "Mod Mine",
22                                     "http://intermine.modencode.org/modminetest"), RatMine(
23                                             "Rat Mine", "http://ratmine.mcw.edu/ratmine");
24
25     private final String name;
26     private final String Url;
27
28     IntermineDB(String name, String Url)
29     {
30       this.Url = Url;
31       this.name = name;
32     }
33
34     public String getName()
35     {
36       return this.name;
37     }
38
39     public String getURL()
40     {
41       return this.Url;
42     }
43   }
44
45   public static enum IntermineMethod
46   {
47     GET_VERSION("/service/version"), GET_RELEASE("/service/version/release"), GET_FASTA_LIST(
48             "/service/list/results/fasta"), GET_FASTA_QUERY(
49                     "/query/results/fasta");
50
51     private final String target;
52
53     IntermineMethod(String target)
54     {
55       this.target = target;
56     }
57
58     public String getTarget()
59     {
60       return target;
61     }
62
63   }
64
65   public static String[] getSupportedDBs()
66   {
67     String[] supportedDbs = new String[IntermineDB.values().length];
68     int count = 0;
69     for (IntermineDB db : IntermineDB.values())
70     {
71       supportedDbs[count++] = db.getName();
72     }
73     return supportedDbs;
74
75   }
76
77
78   public static String fetchData(String url)
79           throws ClientProtocolException, IOException
80   {
81
82     return HttpClientUtils.doHttpUrlGet(url);// client.resource(url).get(String.class);
83   }
84
85
86 }