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