1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
package jalview.ws.jws2; |
25 |
|
|
26 |
|
import java.io.IOException; |
27 |
|
import java.net.MalformedURLException; |
28 |
|
import java.net.URL; |
29 |
|
import java.util.HashSet; |
30 |
|
import java.util.Set; |
31 |
|
|
32 |
|
import compbio.data.msa.Category; |
33 |
|
import compbio.data.msa.JABAService; |
34 |
|
import compbio.ws.client.Jws2Client; |
35 |
|
import compbio.ws.client.Services; |
36 |
|
import jalview.bin.Console; |
37 |
|
import jalview.util.HttpUtils; |
38 |
|
import jalview.ws.jws2.jabaws2.Jws2Instance; |
39 |
|
import jalview.ws.jws2.jabaws2.Jws2InstanceFactory; |
40 |
|
|
41 |
|
|
42 |
|
@author |
43 |
|
|
44 |
|
|
|
|
| 65.6% |
Uncovered Elements: 33 (96) |
Complexity: 22 |
Complexity Density: 0.31 |
|
45 |
|
public class JabaWsServerQuery implements Runnable |
46 |
|
{ |
47 |
|
|
48 |
|
Jws2Discoverer jws2Discoverer = null; |
49 |
|
|
50 |
|
String jwsserver = null; |
51 |
|
|
52 |
|
boolean quit = false, running = false; |
53 |
|
|
54 |
|
|
55 |
|
@return |
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
57 |
300 |
public boolean isRunning()... |
58 |
|
{ |
59 |
300 |
return running; |
60 |
|
} |
61 |
|
|
62 |
|
|
63 |
|
@param |
64 |
|
|
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
66 |
56 |
public void setQuit(boolean quit)... |
67 |
|
{ |
68 |
56 |
this.quit = quit; |
69 |
|
} |
70 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
71 |
65 |
public JabaWsServerQuery(Jws2Discoverer jws2Discoverer, String server)... |
72 |
|
{ |
73 |
65 |
this.jws2Discoverer = jws2Discoverer; |
74 |
65 |
this.jwsserver = server; |
75 |
|
} |
76 |
|
|
77 |
|
Services[] JABAWS1SERVERS = new Services[] { Services.ClustalWS, |
78 |
|
Services.MuscleWS, Services.MafftWS, Services.ProbconsWS, |
79 |
|
Services.TcoffeeWS }; |
80 |
|
|
81 |
|
Services[] JABAWS2SERVERS = new Services[] { Services.ClustalWS, |
82 |
|
Services.MuscleWS, Services.MafftWS, Services.ProbconsWS, |
83 |
|
Services.TcoffeeWS, Services.AAConWS, Services.DisemblWS, |
84 |
|
Services.GlobPlotWS, Services.IUPredWS, Services.JronnWS, |
85 |
|
Services.RNAalifoldWS }; |
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
@see |
91 |
|
|
|
|
| 62.2% |
Uncovered Elements: 28 (74) |
Complexity: 15 |
Complexity Density: 0.27 |
|
92 |
65 |
@Override... |
93 |
|
public void run() |
94 |
|
{ |
95 |
65 |
running = true; |
96 |
65 |
try |
97 |
|
{ |
98 |
|
|
99 |
|
|
100 |
65 |
if (isValidUrl(jwsserver)) |
101 |
|
{ |
102 |
65 |
compbio.data.msa.RegistryWS registry = null; |
103 |
65 |
Set svccategories = null; |
104 |
65 |
boolean noservices = true; |
105 |
|
|
106 |
65 |
boolean jabasws2 = false; |
107 |
|
|
108 |
|
|
109 |
65 |
Set<Services> srv_set = new HashSet<Services>(); |
110 |
|
|
111 |
65 |
Set<Category> categories = Category.getCategories(); |
112 |
65 |
String svc_cat; |
113 |
|
|
114 |
65 |
try |
115 |
|
{ |
116 |
|
|
117 |
65 |
registry = Jws2Client.connectToRegistry(jwsserver); |
118 |
65 |
if (registry != null) |
119 |
|
{ |
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
65 |
jabasws2 = true; |
126 |
65 |
srv_set = registry.getSupportedServices(); |
127 |
|
|
128 |
|
|
129 |
65 |
jalview.bin.Console.outPrintln( |
130 |
|
"registry.getSupportedServices: " + srv_set.toString()); |
131 |
|
|
132 |
65 |
svccategories = registry.getServiceCategories(); |
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
} |
140 |
|
} catch (Exception ex) |
141 |
|
{ |
142 |
0 |
jalview.bin.Console.errPrintln( |
143 |
|
"Exception whilst trying to get at registry:"); |
144 |
0 |
ex.printStackTrace(); |
145 |
|
|
146 |
|
|
147 |
0 |
jalview.bin.Console.errPrintln("JWS2 Discoverer: " + jwsserver |
148 |
|
+ " is a JABAWS1 server. Using hardwired list."); |
149 |
0 |
for (Services srv : JABAWS1SERVERS) |
150 |
|
{ |
151 |
0 |
srv_set.add(srv); |
152 |
|
} |
153 |
|
} |
154 |
|
|
155 |
65 |
for (Category cat : categories) |
156 |
|
{ |
157 |
127 |
for (Services srv : cat.getServices()) |
158 |
|
{ |
159 |
433 |
if (quit) |
160 |
|
{ |
161 |
53 |
running = false; |
162 |
53 |
return; |
163 |
|
} |
164 |
380 |
if (!srv_set.contains(srv)) |
165 |
|
{ |
166 |
0 |
continue; |
167 |
|
} |
168 |
380 |
JABAService service = null; |
169 |
380 |
try |
170 |
|
{ |
171 |
380 |
service = Jws2Client.connect(jwsserver, srv); |
172 |
|
} catch (Exception e) |
173 |
|
{ |
174 |
0 |
jalview.bin.Console.errPrintln("Jws2 Discoverer: Problem on " |
175 |
|
+ jwsserver + " with service " + srv + ":\n" |
176 |
|
+ e.getMessage()); |
177 |
0 |
if (!(e instanceof javax.xml.ws.WebServiceException)) |
178 |
|
{ |
179 |
0 |
e.printStackTrace(); |
180 |
|
} |
181 |
|
|
182 |
0 |
jws2Discoverer.addInvalidServiceUrl(jwsserver); |
183 |
|
} |
184 |
380 |
; |
185 |
380 |
if (service != null |
186 |
|
&& !Jws2InstanceFactory.ignoreService(srv.toString())) |
187 |
|
{ |
188 |
380 |
noservices = false; |
189 |
380 |
Jws2Instance svc = null; |
190 |
380 |
if (registry != null) |
191 |
|
{ |
192 |
|
|
193 |
380 |
String description = registry.getServiceDescription(srv); |
194 |
|
|
195 |
380 |
svc = Jws2InstanceFactory.newJws2Instance(jwsserver, |
196 |
|
srv.toString(), cat.name, description, service); |
197 |
|
} |
198 |
380 |
if (svc == null) |
199 |
|
{ |
200 |
0 |
svc = Jws2InstanceFactory.newJws2Instance(jwsserver, |
201 |
|
srv.toString(), cat.name, |
202 |
|
"JABAWS 1 Alignment Service", service); |
203 |
|
} |
204 |
380 |
jws2Discoverer.addService(jwsserver, svc); |
205 |
|
} |
206 |
|
|
207 |
|
} |
208 |
|
} |
209 |
|
|
210 |
12 |
if (noservices) |
211 |
|
{ |
212 |
0 |
jws2Discoverer.addUrlwithnoservices(jwsserver); |
213 |
|
} |
214 |
|
} |
215 |
|
else |
216 |
|
{ |
217 |
0 |
jws2Discoverer.addInvalidServiceUrl(jwsserver); |
218 |
0 |
Console.warn("Ignoring invalid Jws2 service url " + jwsserver); |
219 |
|
} |
220 |
|
} catch (Exception e) |
221 |
|
{ |
222 |
0 |
e.printStackTrace(); |
223 |
0 |
Console.warn("Exception when discovering Jws2 services.", e); |
224 |
0 |
jws2Discoverer.addInvalidServiceUrl(jwsserver); |
225 |
|
} catch (Error e) |
226 |
|
{ |
227 |
0 |
Console.error("Exception when discovering Jws2 services.", e); |
228 |
0 |
jws2Discoverer.addInvalidServiceUrl(jwsserver); |
229 |
|
} |
230 |
12 |
running = false; |
231 |
|
} |
232 |
|
|
233 |
|
|
234 |
|
|
235 |
|
|
236 |
|
@return |
237 |
|
|
|
|
| 61.5% |
Uncovered Elements: 5 (13) |
Complexity: 4 |
Complexity Density: 0.36 |
|
238 |
65 |
private boolean isValidUrl(String server)... |
239 |
|
{ |
240 |
|
|
241 |
65 |
boolean result = false; |
242 |
65 |
if (server != null) |
243 |
|
{ |
244 |
65 |
try |
245 |
|
{ |
246 |
65 |
URL url = new URL(server); |
247 |
65 |
HttpUtils.openStream(url).close(); |
248 |
65 |
result = true; |
249 |
|
} catch (MalformedURLException e) |
250 |
|
{ |
251 |
0 |
jalview.bin.Console.errPrintln("Invalid server URL: " + server); |
252 |
0 |
result = false; |
253 |
|
} catch (IOException e) |
254 |
|
{ |
255 |
0 |
jalview.bin.Console.errPrintln("Error connecting to server: " |
256 |
|
+ server + ": " + e.toString()); |
257 |
0 |
result = false; |
258 |
|
} |
259 |
|
} |
260 |
65 |
return result; |
261 |
|
} |
262 |
|
|
263 |
|
} |