1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.ws.jws1; |
22 |
|
|
23 |
|
import jalview.gui.JvOptionPane; |
24 |
|
import jalview.util.MessageManager; |
25 |
|
|
26 |
|
import java.util.Hashtable; |
27 |
|
import java.util.StringTokenizer; |
28 |
|
import java.util.Vector; |
29 |
|
|
30 |
|
import ext.vamsas.IRegistry; |
31 |
|
import ext.vamsas.IRegistryServiceLocator; |
32 |
|
import ext.vamsas.RegistryServiceSoapBindingStub; |
33 |
|
import ext.vamsas.ServiceHandle; |
34 |
|
import ext.vamsas.ServiceHandles; |
35 |
|
|
|
|
| 38.5% |
Uncovered Elements: 96 (156) |
Complexity: 39 |
Complexity Density: 0.37 |
|
36 |
|
public class Discoverer implements Runnable |
37 |
|
{ |
38 |
|
ext.vamsas.IRegistry registry; |
39 |
|
|
40 |
|
private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport( |
41 |
|
this); |
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
@param |
47 |
|
|
48 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
49 |
1 |
public void addPropertyChangeListener(... |
50 |
|
java.beans.PropertyChangeListener listener) |
51 |
|
{ |
52 |
1 |
changeSupport.addPropertyChangeListener(listener); |
53 |
|
} |
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
@param |
59 |
|
|
60 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
61 |
0 |
public void removePropertyChangeListener(... |
62 |
|
java.beans.PropertyChangeListener listener) |
63 |
|
{ |
64 |
0 |
changeSupport.removePropertyChangeListener(listener); |
65 |
|
} |
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
@param |
71 |
|
|
72 |
|
@param |
73 |
|
|
74 |
|
@param |
75 |
|
|
76 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
77 |
0 |
public void firePropertyChange(String prop, Object oldvalue,... |
78 |
|
Object newvalue) |
79 |
|
{ |
80 |
0 |
changeSupport.firePropertyChange(prop, oldvalue, newvalue); |
81 |
|
} |
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
@return |
87 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.22 |
|
88 |
0 |
private IRegistry locateWebService(java.net.URL WsURL)... |
89 |
|
{ |
90 |
0 |
IRegistryServiceLocator loc = new IRegistryServiceLocator(); |
91 |
0 |
IRegistry server = null; |
92 |
0 |
try |
93 |
|
{ |
94 |
0 |
server = loc.getRegistryService(WsURL); |
95 |
0 |
((RegistryServiceSoapBindingStub) server).setTimeout(60000); |
96 |
|
|
97 |
|
|
98 |
|
} catch (Exception ex) |
99 |
|
{ |
100 |
0 |
jalview.bin.Cache.log.error( |
101 |
|
"Serious! Service location failed\nfor URL :" + WsURL + "\n", |
102 |
|
ex); |
103 |
|
|
104 |
0 |
return null; |
105 |
|
} |
106 |
|
|
107 |
0 |
loc.getEngine().setOption("axis", "1"); |
108 |
|
|
109 |
0 |
return server; |
110 |
|
} |
111 |
|
|
112 |
|
static private java.net.URL RootServiceURL = null; |
113 |
|
|
114 |
|
static public Vector ServiceURLList = null; |
115 |
|
|
116 |
|
static private boolean reallyDiscoverServices = true; |
117 |
|
|
118 |
|
public static java.util.Hashtable services = null; |
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
public static java.util.Vector serviceList = null; |
125 |
|
|
|
|
| 0% |
Uncovered Elements: 26 (26) |
Complexity: 7 |
Complexity Density: 0.39 |
|
126 |
0 |
static private Vector getDiscoveryURLS()... |
127 |
|
{ |
128 |
0 |
Vector urls = new Vector(); |
129 |
0 |
String RootServiceURLs = jalview.bin.Cache.getDefault("DISCOVERY_URLS", |
130 |
|
"http://www.compbio.dundee.ac.uk/JalviewWS/services/ServiceRegistry"); |
131 |
|
|
132 |
0 |
try |
133 |
|
{ |
134 |
0 |
StringTokenizer st = new StringTokenizer(RootServiceURLs, ","); |
135 |
0 |
while (st.hasMoreElements()) |
136 |
|
{ |
137 |
0 |
String url = null; |
138 |
0 |
try |
139 |
|
{ |
140 |
0 |
java.net.URL u = new java.net.URL(url = st.nextToken()); |
141 |
0 |
if (!urls.contains(u)) |
142 |
|
{ |
143 |
0 |
urls.add(u); |
144 |
|
} |
145 |
|
else |
146 |
|
{ |
147 |
0 |
jalview.bin.Cache.log |
148 |
|
.info("Ignoring duplicate url in DISCOVERY_URLS list"); |
149 |
|
} |
150 |
|
} catch (Exception ex) |
151 |
|
{ |
152 |
0 |
jalview.bin.Cache.log |
153 |
|
.warn("Problem whilst trying to make a URL from '" |
154 |
0 |
+ ((url != null) ? url : "<null>") + "'"); |
155 |
0 |
jalview.bin.Cache.log.warn( |
156 |
|
"This was probably due to a malformed comma separated list" |
157 |
|
+ " in the DISCOVERY_URLS entry of $(HOME)/.jalview_properties)"); |
158 |
0 |
jalview.bin.Cache.log.debug("Exception was ", ex); |
159 |
|
} |
160 |
|
} |
161 |
|
} catch (Exception ex) |
162 |
|
{ |
163 |
0 |
jalview.bin.Cache.log.warn( |
164 |
|
"Error parsing comma separated list of urls in DISCOVERY_URLS.", |
165 |
|
ex); |
166 |
|
} |
167 |
0 |
if (urls.size() > 0) |
168 |
|
{ |
169 |
0 |
return urls; |
170 |
|
} |
171 |
0 |
return null; |
172 |
|
} |
173 |
|
|
174 |
|
|
175 |
|
|
176 |
|
|
|
|
| 78.6% |
Uncovered Elements: 3 (14) |
Complexity: 3 |
Complexity Density: 0.25 |
|
177 |
11 |
static public void doDiscovery()... |
178 |
|
{ |
179 |
11 |
jalview.bin.Cache.log |
180 |
|
.debug("(Re)-Initialising the discovery URL list."); |
181 |
11 |
try |
182 |
|
{ |
183 |
11 |
reallyDiscoverServices = jalview.bin.Cache |
184 |
|
.getDefault("DISCOVERY_START", false); |
185 |
11 |
if (reallyDiscoverServices) |
186 |
|
{ |
187 |
0 |
ServiceURLList = getDiscoveryURLS(); |
188 |
|
} |
189 |
|
else |
190 |
|
{ |
191 |
11 |
jalview.bin.Cache.log.debug("Setting default services"); |
192 |
11 |
services = new Hashtable(); |
193 |
|
|
194 |
11 |
ServiceHandle[] defServices = { new ServiceHandle("MsaWS", |
195 |
|
"Edgar, Robert C. (2004), MUSCLE: multiple sequence alignment " |
196 |
|
+ "with high accuracy and high throughput, Nucleic Acids Research 32(5), 1792-97.", |
197 |
|
"http://www.compbio.dundee.ac.uk/JalviewWS/services/MuscleWS", |
198 |
|
MessageManager.getString( |
199 |
|
"label.muscle_multiple_protein_sequence_alignment")), |
200 |
|
new ServiceHandle("MsaWS", |
201 |
|
"Katoh, K., K. Kuma, K., Toh, H., and Miyata, T. (2005) " |
202 |
|
+ "\"MAFFT version 5: improvement in accuracy of multiple sequence alignment.\"" |
203 |
|
+ " Nucleic Acids Research, 33 511-518", |
204 |
|
"http://www.compbio.dundee.ac.uk/JalviewWS/services/MafftWS", |
205 |
|
MessageManager.getString( |
206 |
|
"label.mafft_multiple_sequence_alignment")), |
207 |
|
new ServiceHandle("MsaWS", |
208 |
|
"Thompson, J.D., Higgins, D.G. and Gibson, T.J. (1994) CLUSTAL W: improving the sensitivity of progressive multiple" |
209 |
|
+ " sequence alignment through sequence weighting, position specific gap penalties and weight matrix choice." |
210 |
|
+ " Nucleic Acids Research, 22 4673-4680", |
211 |
|
"http://www.compbio.dundee.ac.uk/JalviewWS/services/ClustalWS", |
212 |
|
MessageManager.getString( |
213 |
|
"label.clustalw_multiple_sequence_alignment")), |
214 |
|
new ServiceHandle("SecStrPred", |
215 |
|
"Drozdetskiy A, Cole C, Procter J & Barton GJ. (2015)\nJPred4: a protein secondary structure prediction server" |
216 |
|
+ "\nNucleic Acids Research, Web Server issue (first published 15th April 2015)" |
217 |
|
+ "\ndoi://10.1093/nar/gkv332", |
218 |
|
"http://www.compbio.dundee.ac.uk/JalviewWS/services/jpred", |
219 |
|
"JPred Secondary Structure Prediction") }; |
220 |
11 |
services = new Hashtable(); |
221 |
11 |
serviceList = new Vector(); |
222 |
11 |
buildServiceLists(defServices, serviceList, services); |
223 |
|
} |
224 |
|
|
225 |
|
} catch (Exception e) |
226 |
|
{ |
227 |
0 |
System.err.println( |
228 |
|
"jalview.rootRegistry is not a proper url!\nWas set to " |
229 |
|
+ RootServiceURL + "\n" + e); |
230 |
|
} |
231 |
|
|
232 |
|
} |
233 |
|
|
234 |
|
|
235 |
|
|
236 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 7 |
Complexity Density: 0.5 |
|
237 |
0 |
private ServiceHandle[] getServices(java.net.URL location)... |
238 |
|
{ |
239 |
0 |
ServiceHandles shs = null; |
240 |
0 |
try |
241 |
|
{ |
242 |
0 |
jalview.bin.Cache.log.debug("Discovering services using " + location); |
243 |
0 |
shs = locateWebService(location).getServices(); |
244 |
|
} catch (org.apache.axis.AxisFault f) |
245 |
|
{ |
246 |
|
|
247 |
0 |
if (f.getFaultReason().indexOf("(407)") > -1) |
248 |
|
{ |
249 |
0 |
if (jalview.gui.Desktop.desktop != null) |
250 |
|
{ |
251 |
0 |
JvOptionPane.showMessageDialog(jalview.gui.Desktop.desktop, |
252 |
|
MessageManager.getString("label.set_proxy_settings"), |
253 |
|
MessageManager |
254 |
|
.getString("label.proxy_authorization_failed"), |
255 |
|
JvOptionPane.WARNING_MESSAGE); |
256 |
|
} |
257 |
|
} |
258 |
|
else |
259 |
|
{ |
260 |
0 |
jalview.bin.Cache.log.warn("No Discovery service at " + location); |
261 |
0 |
jalview.bin.Cache.log.debug("Axis Fault", f); |
262 |
|
} |
263 |
|
} catch (Exception e) |
264 |
|
{ |
265 |
0 |
jalview.bin.Cache.log.warn("No Discovery service at " + location); |
266 |
0 |
jalview.bin.Cache.log.debug("Discovery Service General Exception", e); |
267 |
|
} |
268 |
0 |
if ((shs != null) && shs.getServices().length > 0) |
269 |
|
{ |
270 |
0 |
return shs.getServices(); |
271 |
|
} |
272 |
0 |
return null; |
273 |
|
} |
274 |
|
|
275 |
|
|
276 |
|
|
277 |
|
|
278 |
|
|
279 |
|
@param |
280 |
|
|
281 |
|
@param |
282 |
|
|
283 |
|
@param |
284 |
|
|
285 |
|
@return |
286 |
|
|
|
|
| 51.6% |
Uncovered Elements: 15 (31) |
Complexity: 8 |
Complexity Density: 0.42 |
|
287 |
11 |
static private boolean buildServiceLists(ServiceHandle[] sh, Vector cat,... |
288 |
|
Hashtable sscat) |
289 |
|
{ |
290 |
11 |
boolean seenNewDiscovery = false; |
291 |
55 |
for (int i = 0, j = sh.length; i < j; i++) |
292 |
|
{ |
293 |
44 |
if (!cat.contains(sh[i])) |
294 |
|
{ |
295 |
44 |
jalview.bin.Cache.log.debug("A " + sh[i].getAbstractName() |
296 |
|
+ " service called " + sh[i].getName() + " exists at " |
297 |
|
+ sh[i].getEndpointURL() + "\n"); |
298 |
44 |
if (!sscat.containsKey(sh[i].getAbstractName())) |
299 |
|
{ |
300 |
22 |
sscat.put(sh[i].getAbstractName(), cat = new Vector()); |
301 |
|
} |
302 |
|
else |
303 |
|
{ |
304 |
22 |
cat = (Vector) sscat.get(sh[i].getAbstractName()); |
305 |
|
} |
306 |
44 |
cat.add(sh[i]); |
307 |
44 |
if (sh[i].getAbstractName().equals("Registry")) |
308 |
|
{ |
309 |
0 |
for (int s = 0, sUrls = ServiceURLList.size(); s < sUrls; s++) |
310 |
|
{ |
311 |
0 |
java.net.URL disc_serv = null; |
312 |
0 |
try |
313 |
|
{ |
314 |
0 |
disc_serv = new java.net.URL(sh[i].getEndpointURL()); |
315 |
0 |
if (!ServiceURLList.contains(disc_serv)) |
316 |
|
{ |
317 |
0 |
jalview.bin.Cache.log.debug( |
318 |
|
"Adding new discovery service at " + disc_serv); |
319 |
0 |
ServiceURLList.add(disc_serv); |
320 |
0 |
seenNewDiscovery = true; |
321 |
|
} |
322 |
|
} catch (Exception e) |
323 |
|
{ |
324 |
0 |
jalview.bin.Cache.log |
325 |
|
.debug("Ignoring bad discovery service URL " |
326 |
|
+ sh[i].getEndpointURL(), e); |
327 |
|
} |
328 |
|
} |
329 |
|
} |
330 |
|
} |
331 |
|
} |
332 |
11 |
return seenNewDiscovery; |
333 |
|
} |
334 |
|
|
|
|
| 36.4% |
Uncovered Elements: 14 (22) |
Complexity: 4 |
Complexity Density: 0.25 |
|
335 |
11 |
public void discoverServices()... |
336 |
|
{ |
337 |
11 |
Hashtable sscat = new Hashtable(); |
338 |
11 |
Vector cat = new Vector(); |
339 |
11 |
ServiceHandle sh[] = null; |
340 |
11 |
int s_url = 0; |
341 |
11 |
if (ServiceURLList == null) |
342 |
|
{ |
343 |
11 |
jalview.bin.Cache.log |
344 |
|
.debug("No service endpoints to use for service discovery."); |
345 |
11 |
return; |
346 |
|
} |
347 |
0 |
while (s_url < ServiceURLList.size()) |
348 |
|
{ |
349 |
0 |
if ((sh = getServices( |
350 |
|
(java.net.URL) ServiceURLList.get(s_url))) != null) |
351 |
|
{ |
352 |
|
|
353 |
0 |
buildServiceLists(sh, cat, sscat); |
354 |
|
} |
355 |
|
else |
356 |
|
{ |
357 |
0 |
jalview.bin.Cache.log.warn("No services at " |
358 |
|
+ (ServiceURLList.get(s_url)) |
359 |
|
+ " - check DISCOVERY_URLS property in .jalview_properties"); |
360 |
|
} |
361 |
0 |
s_url++; |
362 |
|
} |
363 |
|
|
364 |
|
|
365 |
|
|
366 |
|
|
367 |
|
|
368 |
0 |
Hashtable oldServices = services; |
369 |
|
|
370 |
0 |
services = sscat; |
371 |
0 |
serviceList = cat; |
372 |
0 |
changeSupport.firePropertyChange("services", oldServices, services); |
373 |
|
} |
374 |
|
|
375 |
|
|
376 |
|
|
377 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
378 |
11 |
@Override... |
379 |
|
public void run() |
380 |
|
{ |
381 |
11 |
final Discoverer discoverer = this; |
382 |
11 |
Thread discoverThread = new Thread() |
383 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
384 |
11 |
@Override... |
385 |
|
public void run() |
386 |
|
{ |
387 |
11 |
discoverer.doDiscovery(); |
388 |
11 |
discoverer.discoverServices(); |
389 |
|
} |
390 |
|
}; |
391 |
11 |
discoverThread.start(); |
392 |
|
} |
393 |
|
|
394 |
|
|
395 |
|
|
396 |
|
|
397 |
|
private static Hashtable serviceClientBindings; |
398 |
|
|
|
|
| 85.7% |
Uncovered Elements: 2 (14) |
Complexity: 3 |
Complexity Density: 0.3 |
|
399 |
1110 |
public static WS1Client getServiceClient(ServiceHandle sh)... |
400 |
|
{ |
401 |
1110 |
if (serviceClientBindings == null) |
402 |
|
{ |
403 |
|
|
404 |
1 |
serviceClientBindings = new Hashtable(); |
405 |
1 |
serviceClientBindings.put("MsaWS", new MsaWSClient()); |
406 |
1 |
serviceClientBindings.put("SecStrPred", new JPredClient()); |
407 |
1 |
serviceClientBindings.put("SeqSearch", new SeqSearchWSClient()); |
408 |
|
} |
409 |
1110 |
WS1Client instance = (WS1Client) serviceClientBindings |
410 |
|
.get(sh.getAbstractName()); |
411 |
1110 |
if (instance == null) |
412 |
|
{ |
413 |
0 |
System.err.println( |
414 |
|
"WARNING - POSSIBLE IMPLEMENTATION ERROR - cannot find WSClient implementation for " |
415 |
|
+ sh.getAbstractName()); |
416 |
|
} |
417 |
|
else |
418 |
|
{ |
419 |
1110 |
instance.serviceHandle = sh; |
420 |
|
} |
421 |
1110 |
return instance; |
422 |
|
} |
423 |
|
|
424 |
|
|
425 |
|
|
426 |
|
|
427 |
|
|
428 |
|
|
429 |
|
|
430 |
|
|
431 |
|
|
432 |
|
|
433 |
|
|
434 |
|
|
435 |
|
|
436 |
|
|
437 |
|
|
438 |
|
|
439 |
|
} |