1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.ws.rest; |
22 |
|
|
23 |
|
import jalview.datamodel.SequenceI; |
24 |
|
import jalview.io.packed.DataProvider.JvDataType; |
25 |
|
import jalview.util.StringUtils; |
26 |
|
import jalview.ws.rest.params.Alignment; |
27 |
|
import jalview.ws.rest.params.AnnotationFile; |
28 |
|
import jalview.ws.rest.params.SeqGroupIndexVector; |
29 |
|
|
30 |
|
import java.net.URL; |
31 |
|
import java.util.ArrayList; |
32 |
|
import java.util.HashMap; |
33 |
|
import java.util.Hashtable; |
34 |
|
import java.util.List; |
35 |
|
import java.util.Map; |
36 |
|
import java.util.NoSuchElementException; |
37 |
|
import java.util.StringTokenizer; |
38 |
|
import java.util.regex.Matcher; |
39 |
|
import java.util.regex.Pattern; |
40 |
|
|
|
|
| 0% |
Uncovered Elements: 400 (400) |
Complexity: 113 |
Complexity Density: 0.45 |
|
41 |
|
public class RestServiceDescription |
42 |
|
{ |
43 |
|
private static final Pattern PARAM_ENCODED_URL_PATTERN = Pattern |
44 |
|
.compile("([?&])([A-Za-z0-9_]+)=\\$([^$]+)\\$"); |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
49 |
0 |
public RestServiceDescription()... |
50 |
|
{ |
51 |
|
|
52 |
|
} |
53 |
|
|
54 |
|
|
55 |
|
@param |
56 |
|
@param |
57 |
|
@param |
58 |
|
@param |
59 |
|
@param |
60 |
|
@param |
61 |
|
@param |
62 |
|
|
|
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 7 |
Complexity Density: 0.58 |
|
63 |
0 |
public RestServiceDescription(String action, String description,... |
64 |
|
String name, String postUrl, String urlSuffix, |
65 |
|
Map<String, InputType> inputParams, boolean hseparable, |
66 |
|
boolean vseparable, char gapCharacter) |
67 |
|
{ |
68 |
0 |
super(); |
69 |
0 |
this.details = new UIinfo(); |
70 |
0 |
details.Action = action == null ? "" : action; |
71 |
0 |
details.description = description == null ? "" : description; |
72 |
0 |
details.Name = name == null ? "" : name; |
73 |
0 |
this.postUrl = postUrl == null ? "" : postUrl; |
74 |
0 |
this.urlSuffix = urlSuffix == null ? "" : urlSuffix; |
75 |
0 |
if (inputParams != null) |
76 |
|
{ |
77 |
0 |
this.inputParams = inputParams; |
78 |
|
} |
79 |
0 |
this.hseparable = hseparable; |
80 |
0 |
this.vseparable = vseparable; |
81 |
0 |
this.gapCharacter = gapCharacter; |
82 |
|
} |
83 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 3 |
Complexity Density: 0.27 |
|
84 |
0 |
@Override... |
85 |
|
public boolean equals(Object o) |
86 |
|
{ |
87 |
0 |
if (o == null || !(o instanceof RestServiceDescription)) |
88 |
|
{ |
89 |
0 |
return false; |
90 |
|
} |
91 |
0 |
RestServiceDescription other = (RestServiceDescription) o; |
92 |
0 |
boolean diff = (gapCharacter != other.gapCharacter); |
93 |
0 |
diff |= vseparable != other.vseparable; |
94 |
0 |
diff |= hseparable != other.hseparable; |
95 |
0 |
diff |= !(urlSuffix == null && other.urlSuffix == null |
96 |
|
|| (urlSuffix != null && other.urlSuffix != null |
97 |
|
&& urlSuffix.equals(other.urlSuffix))); |
98 |
|
|
99 |
|
|
100 |
|
|
101 |
0 |
diff |= !details.Name.equals(other.details.Name); |
102 |
0 |
diff |= !details.Action.equals(other.details.Action); |
103 |
0 |
diff |= !details.description.equals(other.details.description); |
104 |
0 |
return !diff; |
105 |
|
} |
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 6 |
Complexity Density: 1 |
|
111 |
|
public class UIinfo |
112 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
113 |
0 |
public String getAction()... |
114 |
|
{ |
115 |
0 |
return Action; |
116 |
|
} |
117 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
118 |
0 |
public void setAction(String action)... |
119 |
|
{ |
120 |
0 |
Action = action; |
121 |
|
} |
122 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
123 |
0 |
public String getName()... |
124 |
|
{ |
125 |
0 |
return Name; |
126 |
|
} |
127 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
128 |
0 |
public void setName(String name)... |
129 |
|
{ |
130 |
0 |
Name = name; |
131 |
|
} |
132 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
133 |
0 |
public String getDescription()... |
134 |
|
{ |
135 |
0 |
return description; |
136 |
|
} |
137 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
138 |
0 |
public void setDescription(String description)... |
139 |
|
{ |
140 |
0 |
this.description = description; |
141 |
|
} |
142 |
|
|
143 |
|
String Action; |
144 |
|
|
145 |
|
String Name; |
146 |
|
|
147 |
|
String description; |
148 |
|
} |
149 |
|
|
150 |
|
public UIinfo details = new UIinfo(); |
151 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
152 |
0 |
public String getAction()... |
153 |
|
{ |
154 |
0 |
return details.getAction(); |
155 |
|
} |
156 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
157 |
0 |
public void setAction(String action)... |
158 |
|
{ |
159 |
0 |
details.setAction(action); |
160 |
|
} |
161 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
162 |
0 |
public String getName()... |
163 |
|
{ |
164 |
0 |
return details.getName(); |
165 |
|
} |
166 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
167 |
0 |
public void setName(String name)... |
168 |
|
{ |
169 |
0 |
details.setName(name); |
170 |
|
} |
171 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
172 |
0 |
public String getDescription()... |
173 |
|
{ |
174 |
0 |
return details.getDescription(); |
175 |
|
} |
176 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
177 |
0 |
public void setDescription(String description)... |
178 |
|
{ |
179 |
0 |
details.setDescription(description); |
180 |
|
} |
181 |
|
|
182 |
|
|
183 |
|
|
184 |
|
|
185 |
|
String postUrl; |
186 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
187 |
0 |
public String getPostUrl()... |
188 |
|
{ |
189 |
0 |
return postUrl; |
190 |
|
} |
191 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
192 |
0 |
public void setPostUrl(String postUrl)... |
193 |
|
{ |
194 |
0 |
this.postUrl = postUrl; |
195 |
|
} |
196 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
197 |
0 |
public String getUrlSuffix()... |
198 |
|
{ |
199 |
0 |
return urlSuffix; |
200 |
|
} |
201 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
202 |
0 |
public void setUrlSuffix(String urlSuffix)... |
203 |
|
{ |
204 |
0 |
this.urlSuffix = urlSuffix; |
205 |
|
} |
206 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
207 |
0 |
public Map<String, InputType> getInputParams()... |
208 |
|
{ |
209 |
0 |
return inputParams; |
210 |
|
} |
211 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
212 |
0 |
public void setInputParams(Map<String, InputType> inputParams)... |
213 |
|
{ |
214 |
0 |
this.inputParams = inputParams; |
215 |
|
} |
216 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
217 |
0 |
public void setHseparable(boolean hseparable)... |
218 |
|
{ |
219 |
0 |
this.hseparable = hseparable; |
220 |
|
} |
221 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
222 |
0 |
public void setVseparable(boolean vseparable)... |
223 |
|
{ |
224 |
0 |
this.vseparable = vseparable; |
225 |
|
} |
226 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
227 |
0 |
public void setGapCharacter(char gapCharacter)... |
228 |
|
{ |
229 |
0 |
this.gapCharacter = gapCharacter; |
230 |
|
} |
231 |
|
|
232 |
|
|
233 |
|
|
234 |
|
|
235 |
|
|
236 |
|
String urlSuffix; |
237 |
|
|
238 |
|
|
239 |
|
|
240 |
|
|
241 |
|
Map<String, InputType> inputParams = new HashMap<String, InputType>(); |
242 |
|
|
243 |
|
|
244 |
|
|
245 |
|
|
246 |
|
|
247 |
|
@param |
248 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
249 |
0 |
public void setInputParam(InputType it)... |
250 |
|
{ |
251 |
0 |
inputParams.put(it.token, it); |
252 |
|
} |
253 |
|
|
254 |
|
|
255 |
|
|
256 |
|
|
257 |
|
@param |
258 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
259 |
0 |
public void removeInputParam(InputType it)... |
260 |
|
{ |
261 |
0 |
inputParams.remove(it.token); |
262 |
|
} |
263 |
|
|
264 |
|
|
265 |
|
|
266 |
|
|
267 |
|
boolean aligndata; |
268 |
|
|
269 |
|
|
270 |
|
|
271 |
|
|
272 |
|
boolean annotdata; |
273 |
|
|
274 |
|
|
275 |
|
|
276 |
|
|
277 |
|
boolean partitiondata; |
278 |
|
|
279 |
|
|
280 |
|
|
281 |
|
|
282 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
283 |
0 |
public void setInvolvesFlags()... |
284 |
|
{ |
285 |
0 |
aligndata = inputInvolves(Alignment.class); |
286 |
0 |
annotdata = inputInvolves(AnnotationFile.class); |
287 |
0 |
partitiondata = inputInvolves(SeqGroupIndexVector.class); |
288 |
|
} |
289 |
|
|
290 |
|
|
291 |
|
|
292 |
|
|
293 |
|
|
294 |
|
|
295 |
|
|
296 |
|
|
297 |
|
|
298 |
|
|
299 |
|
|
300 |
|
|
301 |
|
@author |
302 |
|
|
303 |
|
|
304 |
|
|
305 |
|
private String invalidMessage = null; |
306 |
|
|
307 |
|
|
308 |
|
|
309 |
|
|
310 |
|
|
311 |
|
|
312 |
|
|
313 |
|
|
314 |
|
@param |
315 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
316 |
0 |
public RestServiceDescription(String link)... |
317 |
|
{ |
318 |
0 |
StringBuffer warnings = new StringBuffer(); |
319 |
0 |
if (!configureFromEncodedString(link, warnings)) |
320 |
|
{ |
321 |
0 |
if (warnings.length() > 0) |
322 |
|
{ |
323 |
0 |
invalidMessage = warnings.toString(); |
324 |
|
} |
325 |
|
} |
326 |
|
} |
327 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
328 |
0 |
public RestServiceDescription(RestServiceDescription toedit)... |
329 |
|
{ |
330 |
|
|
331 |
|
|
332 |
0 |
this(toedit.toString()); |
333 |
|
|
334 |
|
|
335 |
|
|
336 |
|
|
337 |
|
|
338 |
|
|
339 |
|
|
340 |
|
|
341 |
|
|
342 |
|
|
343 |
|
|
344 |
|
|
345 |
|
} |
346 |
|
|
347 |
|
|
348 |
|
@return |
349 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
350 |
0 |
public String getInvalidMessage()... |
351 |
|
{ |
352 |
0 |
return invalidMessage; |
353 |
|
} |
354 |
|
|
355 |
|
|
356 |
|
|
357 |
|
|
358 |
|
@return |
359 |
|
|
360 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
361 |
0 |
public boolean isValid()... |
362 |
|
{ |
363 |
0 |
return invalidMessage == null; |
364 |
|
} |
365 |
|
|
366 |
|
|
367 |
|
|
368 |
|
|
369 |
|
|
370 |
|
@param |
371 |
|
|
372 |
|
|
373 |
|
|
|
|
| 0% |
Uncovered Elements: 44 (44) |
Complexity: 13 |
Complexity Density: 0.5 |
|
374 |
0 |
private boolean configureFromServiceInputProperties(String propList,... |
375 |
|
StringBuffer warnings) |
376 |
|
{ |
377 |
0 |
String[] props = StringUtils.separatorListToArray(propList, ","); |
378 |
0 |
if (props == null) |
379 |
|
{ |
380 |
0 |
return true; |
381 |
|
} |
382 |
0 |
; |
383 |
0 |
boolean valid = true; |
384 |
0 |
String val = null; |
385 |
0 |
int l = warnings.length(); |
386 |
0 |
int i; |
387 |
0 |
for (String prop : props) |
388 |
|
{ |
389 |
0 |
if ((i = prop.indexOf("=")) > -1) |
390 |
|
{ |
391 |
0 |
val = prop.substring(i + 1); |
392 |
0 |
if (val.startsWith("\'") && val.endsWith("\'")) |
393 |
|
{ |
394 |
0 |
val = val.substring(1, val.length() - 1); |
395 |
|
} |
396 |
0 |
prop = prop.substring(0, i); |
397 |
|
} |
398 |
|
|
399 |
0 |
if (prop.equals("hseparable")) |
400 |
|
{ |
401 |
0 |
hseparable = true; |
402 |
|
} |
403 |
0 |
if (prop.equals("vseparable")) |
404 |
|
{ |
405 |
0 |
vseparable = true; |
406 |
|
} |
407 |
0 |
if (prop.equals("gapCharacter")) |
408 |
|
{ |
409 |
0 |
if (val == null || val.length() == 0 || val.length() > 1) |
410 |
|
{ |
411 |
0 |
valid = false; |
412 |
0 |
warnings.append((warnings.length() > 0 ? "\n" : "") |
413 |
|
+ ("Invalid service property: gapCharacter=' ' (single character) - was given '" |
414 |
|
+ val + "'")); |
415 |
|
} |
416 |
|
else |
417 |
|
{ |
418 |
0 |
gapCharacter = val.charAt(0); |
419 |
|
} |
420 |
|
} |
421 |
0 |
if (prop.equals("returns")) |
422 |
|
{ |
423 |
0 |
_configureOutputFormatFrom(val, warnings); |
424 |
|
} |
425 |
|
} |
426 |
|
|
427 |
0 |
return valid && (l == warnings.length()); |
428 |
|
} |
429 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
430 |
0 |
private String _genOutputFormatString()... |
431 |
|
{ |
432 |
0 |
String buff = ""; |
433 |
0 |
if (resultData == null) |
434 |
|
{ |
435 |
0 |
return ""; |
436 |
|
} |
437 |
0 |
for (JvDataType type : resultData) |
438 |
|
{ |
439 |
0 |
if (buff.length() > 0) |
440 |
|
{ |
441 |
0 |
buff += ";"; |
442 |
|
} |
443 |
0 |
buff += type.toString(); |
444 |
|
} |
445 |
0 |
return buff; |
446 |
|
} |
447 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 4 |
Complexity Density: 0.27 |
|
448 |
0 |
private void _configureOutputFormatFrom(String outstring,... |
449 |
|
StringBuffer warnings) |
450 |
|
{ |
451 |
0 |
if (outstring.indexOf(";") == -1) |
452 |
|
{ |
453 |
|
|
454 |
0 |
outstring = outstring + ";"; |
455 |
|
} |
456 |
0 |
StringTokenizer st = new StringTokenizer(outstring, ";"); |
457 |
0 |
String tok = ""; |
458 |
0 |
resultData = new ArrayList<JvDataType>(); |
459 |
0 |
while (st.hasMoreTokens()) |
460 |
|
{ |
461 |
0 |
try |
462 |
|
{ |
463 |
0 |
resultData.add(JvDataType.valueOf(tok = st.nextToken())); |
464 |
|
} catch (NoSuchElementException x) |
465 |
|
{ |
466 |
0 |
warnings.append( |
467 |
|
"Invalid result type: '" + tok + "' (must be one of: "); |
468 |
0 |
String sep = ""; |
469 |
0 |
for (JvDataType vl : JvDataType.values()) |
470 |
|
{ |
471 |
0 |
warnings.append(sep); |
472 |
0 |
warnings.append(vl.toString()); |
473 |
0 |
sep = " ,"; |
474 |
|
} |
475 |
0 |
warnings.append(" separated by semi-colons)\n"); |
476 |
|
} |
477 |
|
} |
478 |
|
} |
479 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 3 |
Complexity Density: 0.3 |
|
480 |
0 |
private String getServiceIOProperties()... |
481 |
|
{ |
482 |
0 |
ArrayList<String> vls = new ArrayList<String>(); |
483 |
0 |
if (isHseparable()) |
484 |
|
{ |
485 |
0 |
vls.add("hseparable"); |
486 |
|
} |
487 |
0 |
; |
488 |
0 |
if (isVseparable()) |
489 |
|
{ |
490 |
0 |
vls.add("vseparable"); |
491 |
|
} |
492 |
0 |
; |
493 |
0 |
vls.add(new String("gapCharacter='" + gapCharacter + "'")); |
494 |
0 |
vls.add(new String("returns='" + _genOutputFormatString() + "'")); |
495 |
0 |
return StringUtils.arrayToSeparatorList(vls.toArray(new String[0]), |
496 |
|
","); |
497 |
|
} |
498 |
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 4 |
Complexity Density: 0.24 |
|
499 |
0 |
public String toString()... |
500 |
|
{ |
501 |
0 |
StringBuffer result = new StringBuffer(); |
502 |
0 |
result.append("|"); |
503 |
0 |
result.append(details.Name); |
504 |
0 |
result.append('|'); |
505 |
0 |
result.append(details.Action); |
506 |
0 |
result.append('|'); |
507 |
0 |
if (details.description != null) |
508 |
|
{ |
509 |
0 |
result.append(details.description); |
510 |
|
} |
511 |
0 |
; |
512 |
|
|
513 |
0 |
result.append('|'); |
514 |
0 |
result.append(getServiceIOProperties()); |
515 |
|
|
516 |
0 |
if (urlSuffix != null && urlSuffix.length() > 0) |
517 |
|
{ |
518 |
0 |
result.append('|'); |
519 |
0 |
result.append(urlSuffix); |
520 |
|
} |
521 |
0 |
result.append('|'); |
522 |
0 |
result.append(getInputParamEncodedUrl()); |
523 |
0 |
return result.toString(); |
524 |
|
} |
525 |
|
|
526 |
|
|
527 |
|
|
528 |
|
|
529 |
|
|
530 |
|
|
531 |
|
@param |
532 |
|
@param |
533 |
|
|
534 |
|
@return |
535 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
536 |
0 |
public boolean configureFromEncodedString(String encoding,... |
537 |
|
StringBuffer warnings) |
538 |
|
{ |
539 |
0 |
String[] list = StringUtils.separatorListToArray(encoding, "|"); |
540 |
|
|
541 |
0 |
int nextpos = parseServiceList(list, warnings, 0); |
542 |
0 |
if (nextpos > 0) |
543 |
|
{ |
544 |
0 |
return true; |
545 |
|
} |
546 |
0 |
return false; |
547 |
|
} |
548 |
|
|
549 |
|
|
550 |
|
|
551 |
|
|
552 |
|
|
553 |
|
|
554 |
|
|
555 |
|
|
556 |
|
@param |
557 |
|
@param |
558 |
|
@param |
559 |
|
@return |
560 |
|
|
|
|
| 0% |
Uncovered Elements: 24 (24) |
Complexity: 10 |
Complexity Density: 0.62 |
|
561 |
0 |
protected int parseServiceList(String[] list, StringBuffer warnings,... |
562 |
|
int p) |
563 |
|
{ |
564 |
0 |
boolean invalid = false; |
565 |
|
|
566 |
0 |
while (list[p] != null && list[p].trim().length() == 0) |
567 |
|
{ |
568 |
0 |
p++; |
569 |
|
} |
570 |
0 |
details.Name = list[p]; |
571 |
0 |
details.Action = list[p + 1]; |
572 |
0 |
details.description = list[p + 2]; |
573 |
0 |
invalid |= !configureFromServiceInputProperties(list[p + 3], warnings); |
574 |
0 |
if (list.length - p > 5 && list[p + 5] != null |
575 |
|
&& list[p + 5].trim().length() > 5) |
576 |
|
{ |
577 |
0 |
urlSuffix = list[p + 4]; |
578 |
0 |
invalid |= !configureFromInputParamEncodedUrl(list[p + 5], warnings); |
579 |
0 |
p += 6; |
580 |
|
} |
581 |
|
else |
582 |
|
{ |
583 |
0 |
if (list.length - p > 4 && list[p + 4] != null |
584 |
|
&& list[p + 4].trim().length() > 5) |
585 |
|
{ |
586 |
0 |
urlSuffix = null; |
587 |
0 |
invalid |= !configureFromInputParamEncodedUrl(list[p + 4], |
588 |
|
warnings); |
589 |
0 |
p += 5; |
590 |
|
} |
591 |
|
} |
592 |
0 |
return invalid ? -1 : p; |
593 |
|
} |
594 |
|
|
595 |
|
|
596 |
|
@return |
597 |
|
|
598 |
|
|
|
|
| 0% |
Uncovered Elements: 42 (42) |
Complexity: 9 |
Complexity Density: 0.32 |
|
599 |
0 |
private String getInputParamEncodedUrl()... |
600 |
|
{ |
601 |
0 |
StringBuffer url = new StringBuffer(); |
602 |
0 |
if (postUrl == null || postUrl.length() < 5) |
603 |
|
{ |
604 |
0 |
return ""; |
605 |
|
} |
606 |
|
|
607 |
0 |
url.append(postUrl); |
608 |
0 |
char appendChar = (postUrl.indexOf("?") > -1) ? '&' : '?'; |
609 |
0 |
boolean consts = true; |
610 |
0 |
do |
611 |
|
{ |
612 |
0 |
for (Map.Entry<String, InputType> param : inputParams.entrySet()) |
613 |
|
{ |
614 |
0 |
List<String> vals = param.getValue().getURLEncodedParameter(); |
615 |
0 |
if (param.getValue().isConstant()) |
616 |
|
{ |
617 |
0 |
if (consts) |
618 |
|
{ |
619 |
0 |
url.append(appendChar); |
620 |
0 |
appendChar = '&'; |
621 |
0 |
url.append(param.getValue().token); |
622 |
0 |
if (vals.size() == 1) |
623 |
|
{ |
624 |
0 |
url.append("="); |
625 |
0 |
url.append(vals.get(0)); |
626 |
|
} |
627 |
|
} |
628 |
|
} |
629 |
|
else |
630 |
|
{ |
631 |
0 |
if (!consts) |
632 |
|
{ |
633 |
0 |
url.append(appendChar); |
634 |
0 |
appendChar = '&'; |
635 |
0 |
url.append(param.getValue().token); |
636 |
0 |
url.append("="); |
637 |
|
|
638 |
|
|
639 |
0 |
url.append("$"); |
640 |
0 |
url.append(param.getValue().getURLtokenPrefix()); |
641 |
0 |
url.append(":"); |
642 |
0 |
url.append(StringUtils.arrayToSeparatorList( |
643 |
|
vals.toArray(new String[0]), ",")); |
644 |
0 |
url.append("$"); |
645 |
|
} |
646 |
|
} |
647 |
|
|
648 |
|
} |
649 |
|
|
650 |
? |
} while (!(consts = !consts)); |
651 |
0 |
return url.toString(); |
652 |
|
} |
653 |
|
|
654 |
|
|
655 |
|
|
656 |
|
|
657 |
|
|
658 |
|
@param |
659 |
|
@param |
660 |
|
|
661 |
|
@return |
662 |
|
|
|
|
| 0% |
Uncovered Elements: 35 (35) |
Complexity: 6 |
Complexity Density: 0.22 |
|
663 |
0 |
private boolean configureFromInputParamEncodedUrl(String ipurl,... |
664 |
|
StringBuffer warnings) |
665 |
|
{ |
666 |
0 |
boolean valid = true; |
667 |
0 |
int lastp = 0; |
668 |
0 |
String url = new String(); |
669 |
0 |
Matcher prms = PARAM_ENCODED_URL_PATTERN.matcher(ipurl); |
670 |
0 |
Map<String, InputType> iparams = new Hashtable<String, InputType>(); |
671 |
0 |
InputType jinput; |
672 |
0 |
while (prms.find()) |
673 |
|
{ |
674 |
0 |
if (lastp < prms.start(0)) |
675 |
|
{ |
676 |
0 |
url += ipurl.substring(lastp, prms.start(0)); |
677 |
0 |
lastp = prms.end(0) + 1; |
678 |
|
} |
679 |
0 |
String sep = prms.group(1); |
680 |
0 |
String tok = prms.group(2); |
681 |
0 |
String iprm = prms.group(3); |
682 |
0 |
int colon = iprm.indexOf(":"); |
683 |
0 |
String iprmparams = ""; |
684 |
0 |
if (colon > -1) |
685 |
|
{ |
686 |
0 |
iprmparams = iprm.substring(colon + 1); |
687 |
0 |
iprm = iprm.substring(0, colon); |
688 |
|
} |
689 |
0 |
valid = parseTypeString(prms.group(0), tok, iprm, iprmparams, iparams, |
690 |
|
warnings); |
691 |
|
} |
692 |
0 |
if (valid) |
693 |
|
{ |
694 |
0 |
try |
695 |
|
{ |
696 |
0 |
URL u = new URL(url); |
697 |
0 |
postUrl = url; |
698 |
0 |
inputParams = iparams; |
699 |
|
} catch (Exception e) |
700 |
|
{ |
701 |
0 |
warnings.append("Failed to parse '" + url + "' as a URL.\n"); |
702 |
0 |
valid = false; |
703 |
|
} |
704 |
|
} |
705 |
0 |
return valid; |
706 |
|
} |
707 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
708 |
0 |
public static Class[] getInputTypes()... |
709 |
|
{ |
710 |
|
|
711 |
0 |
return new Class[] { jalview.ws.rest.params.Alignment.class, |
712 |
|
jalview.ws.rest.params.AnnotationFile.class, |
713 |
|
SeqGroupIndexVector.class, jalview.ws.rest.params.SeqIdVector.class, |
714 |
|
jalview.ws.rest.params.SeqVector.class, |
715 |
|
jalview.ws.rest.params.Tree.class }; |
716 |
|
} |
717 |
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 4 |
Complexity Density: 0.22 |
|
718 |
0 |
public static boolean parseTypeString(String fullstring, String tok,... |
719 |
|
String iprm, String iprmparams, Map<String, InputType> iparams, |
720 |
|
StringBuffer warnings) |
721 |
|
{ |
722 |
0 |
boolean valid = true; |
723 |
0 |
InputType jinput; |
724 |
0 |
for (Class type : getInputTypes()) |
725 |
|
{ |
726 |
0 |
try |
727 |
|
{ |
728 |
0 |
jinput = (InputType) (type.getConstructor().newInstance()); |
729 |
0 |
if (iprm.equalsIgnoreCase(jinput.getURLtokenPrefix())) |
730 |
|
{ |
731 |
0 |
ArrayList<String> al = new ArrayList<String>(); |
732 |
0 |
for (String prprm : StringUtils.separatorListToArray(iprmparams, |
733 |
|
",")) |
734 |
|
{ |
735 |
|
|
736 |
|
|
737 |
0 |
al.add(prprm.trim()); |
738 |
|
} |
739 |
0 |
if (!jinput.configureFromURLtokenString(al, warnings)) |
740 |
|
{ |
741 |
0 |
valid = false; |
742 |
0 |
warnings.append("Failed to parse '" + fullstring + "' as a " |
743 |
|
+ jinput.getURLtokenPrefix() + " input tag.\n"); |
744 |
|
} |
745 |
|
else |
746 |
|
{ |
747 |
0 |
jinput.token = tok; |
748 |
0 |
iparams.put(tok, jinput); |
749 |
0 |
valid = true; |
750 |
|
} |
751 |
0 |
break; |
752 |
|
} |
753 |
|
|
754 |
|
} catch (Throwable thr) |
755 |
|
{ |
756 |
|
} |
757 |
0 |
; |
758 |
|
} |
759 |
0 |
return valid; |
760 |
|
} |
761 |
|
|
762 |
|
|
763 |
|
|
764 |
|
|
765 |
|
|
766 |
|
|
767 |
|
@param |
768 |
|
@return |
769 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
770 |
0 |
public static String[][] formStrings(SequenceI[] seqs)... |
771 |
|
{ |
772 |
0 |
String[][] idset = new String[2][seqs.length]; |
773 |
0 |
for (int i = 0; i < seqs.length; i++) |
774 |
|
{ |
775 |
0 |
idset[0][i] = seqs[i].getName(); |
776 |
0 |
idset[1][i] = seqs[i].getSequenceAsString(); |
777 |
|
} |
778 |
0 |
return idset; |
779 |
|
} |
780 |
|
|
781 |
|
|
782 |
|
|
783 |
|
|
784 |
|
|
785 |
|
boolean hseparable = false; |
786 |
|
|
787 |
|
boolean vseparable = false; |
788 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
789 |
0 |
public boolean isHseparable()... |
790 |
|
{ |
791 |
0 |
return hseparable; |
792 |
|
} |
793 |
|
|
794 |
|
|
795 |
|
|
796 |
|
@return |
797 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
798 |
0 |
public boolean isVseparable()... |
799 |
|
{ |
800 |
0 |
return vseparable; |
801 |
|
} |
802 |
|
|
803 |
|
|
804 |
|
|
805 |
|
|
806 |
|
@param |
807 |
|
|
808 |
|
@return |
809 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
810 |
0 |
public boolean inputInvolves(Class<?> class1)... |
811 |
|
{ |
812 |
0 |
assert (InputType.class.isAssignableFrom(class1)); |
813 |
0 |
for (InputType val : inputParams.values()) |
814 |
|
{ |
815 |
0 |
if (class1.isAssignableFrom(val.getClass())) |
816 |
|
{ |
817 |
0 |
return true; |
818 |
|
} |
819 |
|
} |
820 |
0 |
return false; |
821 |
|
} |
822 |
|
|
823 |
|
char gapCharacter = '-'; |
824 |
|
|
825 |
|
|
826 |
|
|
827 |
|
@return |
828 |
|
|
829 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
830 |
0 |
public char getGapCharacter()... |
831 |
|
{ |
832 |
0 |
return gapCharacter; |
833 |
|
} |
834 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
835 |
0 |
public String getDecoratedResultUrl(String jobId)... |
836 |
|
{ |
837 |
|
|
838 |
0 |
return jobId + urlSuffix; |
839 |
|
} |
840 |
|
|
841 |
|
private List<JvDataType> resultData = new ArrayList<JvDataType>(); |
842 |
|
|
843 |
|
|
844 |
|
|
845 |
|
|
846 |
|
|
847 |
|
|
848 |
|
|
849 |
|
@param |
850 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
851 |
0 |
public void addResultDatatype(JvDataType dt)... |
852 |
|
{ |
853 |
0 |
if (resultData == null) |
854 |
|
{ |
855 |
0 |
resultData = new ArrayList<JvDataType>(); |
856 |
|
} |
857 |
0 |
resultData.add(dt); |
858 |
|
} |
859 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
860 |
0 |
public boolean removeRsultDatatype(JvDataType dt)... |
861 |
|
{ |
862 |
0 |
if (resultData != null) |
863 |
|
{ |
864 |
0 |
return resultData.remove(dt); |
865 |
|
} |
866 |
0 |
return false; |
867 |
|
} |
868 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
869 |
0 |
public List<JvDataType> getResultDataTypes()... |
870 |
|
{ |
871 |
0 |
return resultData; |
872 |
|
} |
873 |
|
|
874 |
|
|
875 |
|
|
876 |
|
|
877 |
|
@param |
878 |
|
@return |
879 |
|
@throws |
880 |
|
|
881 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 5 |
Complexity Density: 0.45 |
|
882 |
0 |
public static List<RestServiceDescription> parseDescriptions(... |
883 |
|
String services) throws Exception |
884 |
|
{ |
885 |
0 |
String[] list = StringUtils.separatorListToArray(services, "|"); |
886 |
0 |
List<RestServiceDescription> svcparsed = new ArrayList<RestServiceDescription>(); |
887 |
0 |
int p = 0, lastp = 0; |
888 |
0 |
StringBuffer warnings = new StringBuffer(); |
889 |
0 |
do |
890 |
|
{ |
891 |
0 |
RestServiceDescription rsd = new RestServiceDescription(); |
892 |
0 |
p = rsd.parseServiceList(list, warnings, lastp = p); |
893 |
0 |
if (p > lastp && rsd.isValid()) |
894 |
|
{ |
895 |
0 |
svcparsed.add(rsd); |
896 |
|
} |
897 |
|
else |
898 |
|
{ |
899 |
0 |
throw new Exception( |
900 |
|
"Failed to parse user defined RSBS services from :" |
901 |
|
+ services |
902 |
|
+ "\nFirst error was encountered at token " + lastp |
903 |
|
+ " starting " + list[lastp] + ":\n" |
904 |
|
+ rsd.getInvalidMessage()); |
905 |
|
} |
906 |
0 |
} while (p < lastp && p < list.length - 1); |
907 |
0 |
return svcparsed; |
908 |
|
} |
909 |
|
|
910 |
|
} |