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 jalview.bin.Cache; |
27 |
|
import jalview.ws.jws2.jabaws2.Jws2Instance; |
28 |
|
import jalview.ws.jws2.jabaws2.Jws2InstanceFactory; |
29 |
|
|
30 |
|
import java.io.IOException; |
31 |
|
import java.net.MalformedURLException; |
32 |
|
import java.net.URL; |
33 |
|
import java.util.HashSet; |
34 |
|
import java.util.Set; |
35 |
|
|
36 |
|
import compbio.data.msa.Category; |
37 |
|
import compbio.data.msa.JABAService; |
38 |
|
import compbio.ws.client.Jws2Client; |
39 |
|
import compbio.ws.client.Services; |
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 |
119 |
public boolean isRunning()... |
58 |
|
{ |
59 |
119 |
return running; |
60 |
|
} |
61 |
|
|
62 |
|
|
63 |
|
@param |
64 |
|
|
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
66 |
3 |
public void setQuit(boolean quit)... |
67 |
|
{ |
68 |
3 |
this.quit = quit; |
69 |
|
} |
70 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
71 |
11 |
public JabaWsServerQuery(Jws2Discoverer jws2Discoverer, String server)... |
72 |
|
{ |
73 |
11 |
this.jws2Discoverer = jws2Discoverer; |
74 |
11 |
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 |
11 |
@Override... |
93 |
|
public void run() |
94 |
|
{ |
95 |
11 |
running = true; |
96 |
11 |
try |
97 |
|
{ |
98 |
|
|
99 |
|
|
100 |
11 |
if (isValidUrl(jwsserver)) |
101 |
|
{ |
102 |
11 |
compbio.data.msa.RegistryWS registry = null; |
103 |
11 |
Set svccategories = null; |
104 |
11 |
boolean noservices = true; |
105 |
|
|
106 |
11 |
boolean jabasws2 = false; |
107 |
|
|
108 |
|
|
109 |
11 |
Set<Services> srv_set = new HashSet<Services>(); |
110 |
|
|
111 |
11 |
Set<Category> categories = Category.getCategories(); |
112 |
11 |
String svc_cat; |
113 |
|
|
114 |
11 |
try |
115 |
|
{ |
116 |
|
|
117 |
11 |
registry = Jws2Client.connectToRegistry(jwsserver); |
118 |
11 |
if (registry != null) |
119 |
|
{ |
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
11 |
jabasws2 = true; |
126 |
11 |
srv_set = registry.getSupportedServices(); |
127 |
|
|
128 |
|
|
129 |
11 |
System.out.println( |
130 |
|
"registry.getSupportedServices: " + srv_set.toString()); |
131 |
|
|
132 |
11 |
svccategories = registry.getServiceCategories(); |
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
} |
139 |
|
} catch (Exception ex) |
140 |
|
{ |
141 |
0 |
System.err.println("Exception whilst trying to get at registry:"); |
142 |
0 |
ex.printStackTrace(); |
143 |
|
|
144 |
|
|
145 |
0 |
System.err.println("JWS2 Discoverer: " + jwsserver |
146 |
|
+ " is a JABAWS1 server. Using hardwired list."); |
147 |
0 |
for (Services srv : JABAWS1SERVERS) |
148 |
|
{ |
149 |
0 |
srv_set.add(srv); |
150 |
|
} |
151 |
|
} |
152 |
|
|
153 |
11 |
for (Category cat : categories) |
154 |
|
{ |
155 |
38 |
for (Services srv : cat.getServices()) |
156 |
|
{ |
157 |
134 |
if (quit) |
158 |
|
{ |
159 |
2 |
running = false; |
160 |
2 |
return; |
161 |
|
} |
162 |
132 |
if (!srv_set.contains(srv)) |
163 |
|
{ |
164 |
0 |
continue; |
165 |
|
} |
166 |
132 |
JABAService service = null; |
167 |
132 |
try |
168 |
|
{ |
169 |
132 |
service = Jws2Client.connect(jwsserver, srv); |
170 |
|
} catch (Exception e) |
171 |
|
{ |
172 |
0 |
System.err.println("Jws2 Discoverer: Problem on " + jwsserver |
173 |
|
+ " with service " + srv + ":\n" + e.getMessage()); |
174 |
0 |
if (!(e instanceof javax.xml.ws.WebServiceException)) |
175 |
|
{ |
176 |
0 |
e.printStackTrace(); |
177 |
|
} |
178 |
|
|
179 |
0 |
jws2Discoverer.addInvalidServiceUrl(jwsserver); |
180 |
|
} |
181 |
132 |
; |
182 |
132 |
if (service != null |
183 |
|
&& !Jws2InstanceFactory.ignoreService(srv.toString())) |
184 |
|
{ |
185 |
132 |
noservices = false; |
186 |
132 |
Jws2Instance svc = null; |
187 |
132 |
if (registry != null) |
188 |
|
{ |
189 |
|
|
190 |
132 |
String description = registry.getServiceDescription(srv); |
191 |
|
|
192 |
132 |
svc = Jws2InstanceFactory.newJws2Instance(jwsserver, |
193 |
|
srv.toString(), cat.name, description, service); |
194 |
|
} |
195 |
132 |
if (svc == null) |
196 |
|
{ |
197 |
0 |
svc = Jws2InstanceFactory.newJws2Instance(jwsserver, |
198 |
|
srv.toString(), cat.name, |
199 |
|
"JABAWS 1 Alignment Service", service); |
200 |
|
} |
201 |
132 |
jws2Discoverer.addService(jwsserver, svc); |
202 |
|
} |
203 |
|
|
204 |
|
} |
205 |
|
} |
206 |
|
|
207 |
9 |
if (noservices) |
208 |
|
{ |
209 |
0 |
jws2Discoverer.addUrlwithnoservices(jwsserver); |
210 |
|
} |
211 |
|
} |
212 |
|
else |
213 |
|
{ |
214 |
0 |
jws2Discoverer.addInvalidServiceUrl(jwsserver); |
215 |
0 |
Cache.log.warn("Ignoring invalid Jws2 service url " + jwsserver); |
216 |
|
} |
217 |
|
} catch (Exception e) |
218 |
|
{ |
219 |
0 |
e.printStackTrace(); |
220 |
0 |
Cache.log.warn("Exception when discovering Jws2 services.", e); |
221 |
0 |
jws2Discoverer.addInvalidServiceUrl(jwsserver); |
222 |
|
} catch (Error e) |
223 |
|
{ |
224 |
0 |
Cache.log.error("Exception when discovering Jws2 services.", e); |
225 |
0 |
jws2Discoverer.addInvalidServiceUrl(jwsserver); |
226 |
|
} |
227 |
9 |
running = false; |
228 |
|
} |
229 |
|
|
230 |
|
|
231 |
|
|
232 |
|
|
233 |
|
@return |
234 |
|
|
|
|
| 61.5% |
Uncovered Elements: 5 (13) |
Complexity: 4 |
Complexity Density: 0.36 |
|
235 |
11 |
private boolean isValidUrl(String server)... |
236 |
|
{ |
237 |
|
|
238 |
11 |
boolean result = false; |
239 |
11 |
if (server != null) |
240 |
|
{ |
241 |
11 |
try |
242 |
|
{ |
243 |
11 |
URL url = new URL(server); |
244 |
11 |
url.openStream().close(); |
245 |
11 |
result = true; |
246 |
|
} catch (MalformedURLException e) |
247 |
|
{ |
248 |
0 |
System.err.println("Invalid server URL: " + server); |
249 |
0 |
result = false; |
250 |
|
} catch (IOException e) |
251 |
|
{ |
252 |
0 |
System.err.println("Error connecting to server: " + server + ": " |
253 |
|
+ e.toString()); |
254 |
0 |
result = false; |
255 |
|
} |
256 |
|
} |
257 |
11 |
return result; |
258 |
|
} |
259 |
|
|
260 |
|
} |