| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.ext.ensembl; |
| 22 |
|
|
| 23 |
|
import java.io.BufferedReader; |
| 24 |
|
import java.io.DataOutputStream; |
| 25 |
|
import java.io.IOException; |
| 26 |
|
import java.io.InputStream; |
| 27 |
|
import java.net.HttpURLConnection; |
| 28 |
|
import java.net.MalformedURLException; |
| 29 |
|
import java.net.ProtocolException; |
| 30 |
|
import java.net.URL; |
| 31 |
|
import java.util.HashMap; |
| 32 |
|
import java.util.List; |
| 33 |
|
import java.util.Map; |
| 34 |
|
|
| 35 |
|
import javax.ws.rs.HttpMethod; |
| 36 |
|
|
| 37 |
|
import org.json.simple.parser.ParseException; |
| 38 |
|
|
| 39 |
|
import jalview.util.HttpUtils; |
| 40 |
|
import jalview.util.Platform; |
| 41 |
|
import jalview.util.StringUtils; |
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
|
|
| 46 |
|
@author |
| 47 |
|
|
| |
|
| 7.1% |
Uncovered Elements: 197 (212) |
Complexity: 56 |
Complexity Density: 0.39 |
|
| 48 |
|
abstract class EnsemblRestClient extends EnsemblSequenceFetcher |
| 49 |
|
{ |
| 50 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 51 |
7 |
static... |
| 52 |
|
{ |
| 53 |
7 |
Platform.addJ2SDirectDatabaseCall("http://rest.ensembl"); |
| 54 |
7 |
Platform.addJ2SDirectDatabaseCall("https://rest.ensembl"); |
| 55 |
|
} |
| 56 |
|
|
| 57 |
|
private static final int DEFAULT_READ_TIMEOUT = 5 * 60 * 1000; |
| 58 |
|
|
| 59 |
|
private static final int CONNECT_TIMEOUT_MS = 10 * 1000; |
| 60 |
|
|
| 61 |
|
private static final int MAX_RETRIES = 3; |
| 62 |
|
|
| 63 |
|
private static final int HTTP_OK = 200; |
| 64 |
|
|
| 65 |
|
private static final int HTTP_OVERLOAD = 429; |
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
@see |
| 71 |
|
@see |
| 72 |
|
|
| 73 |
|
private static final String LATEST_ENSEMBLGENOMES_REST_VERSION = "15.8"; |
| 74 |
|
|
| 75 |
|
private static final String LATEST_ENSEMBL_REST_VERSION = "15.8"; |
| 76 |
|
|
| 77 |
|
private static final String REST_CHANGE_LOG = "https://github.com/Ensembl/ensembl-rest/wiki/Change-log"; |
| 78 |
|
|
| 79 |
|
private static Map<String, EnsemblData> domainData; |
| 80 |
|
|
| 81 |
|
private final static long AVAILABILITY_RETEST_INTERVAL = 10000L; |
| 82 |
|
|
| 83 |
|
private final static long VERSION_RETEST_INTERVAL = 1000L * 3600; |
| 84 |
|
|
| 85 |
|
protected static final String CONTENT_TYPE_JSON = "?content-type=application/json"; |
| 86 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 87 |
7 |
static... |
| 88 |
|
{ |
| 89 |
7 |
domainData = new HashMap<>(); |
| 90 |
7 |
domainData.put(DEFAULT_ENSEMBL_BASEURL, new EnsemblData( |
| 91 |
|
DEFAULT_ENSEMBL_BASEURL, LATEST_ENSEMBL_REST_VERSION)); |
| 92 |
7 |
domainData.put(DEFAULT_ENSEMBL_GENOMES_BASEURL, |
| 93 |
|
new EnsemblData(DEFAULT_ENSEMBL_GENOMES_BASEURL, |
| 94 |
|
LATEST_ENSEMBLGENOMES_REST_VERSION)); |
| 95 |
|
} |
| 96 |
|
|
| 97 |
|
protected volatile boolean inProgress = false; |
| 98 |
|
|
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| |
|
| 55.6% |
Uncovered Elements: 4 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 102 |
49 |
public EnsemblRestClient()... |
| 103 |
|
{ |
| 104 |
49 |
super(); |
| 105 |
|
|
| 106 |
|
|
| 107 |
|
|
| 108 |
|
|
| 109 |
49 |
if (!domainData.containsKey(ensemblDomain)) |
| 110 |
|
{ |
| 111 |
0 |
domainData.put(ensemblDomain, |
| 112 |
|
new EnsemblData(ensemblDomain, LATEST_ENSEMBL_REST_VERSION)); |
| 113 |
|
} |
| 114 |
49 |
if (!domainData.containsKey(ensemblGenomesDomain)) |
| 115 |
|
{ |
| 116 |
0 |
domainData.put(ensemblGenomesDomain, new EnsemblData( |
| 117 |
|
ensemblGenomesDomain, LATEST_ENSEMBLGENOMES_REST_VERSION)); |
| 118 |
|
} |
| 119 |
|
} |
| 120 |
|
|
| 121 |
|
|
| 122 |
|
|
| 123 |
|
|
| 124 |
|
@param |
| 125 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 126 |
1 |
public EnsemblRestClient(String d)... |
| 127 |
|
{ |
| 128 |
1 |
setDomain(d); |
| 129 |
|
} |
| 130 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 131 |
0 |
@Override... |
| 132 |
|
public boolean queryInProgress() |
| 133 |
|
{ |
| 134 |
0 |
return inProgress; |
| 135 |
|
} |
| 136 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 137 |
0 |
@Override... |
| 138 |
|
public StringBuffer getRawRecords() |
| 139 |
|
{ |
| 140 |
0 |
return null; |
| 141 |
|
} |
| 142 |
|
|
| 143 |
|
|
| 144 |
|
|
| 145 |
|
|
| 146 |
|
@param |
| 147 |
|
@return |
| 148 |
|
@throws |
| 149 |
|
|
| 150 |
|
protected abstract URL getUrl(List<String> ids) |
| 151 |
|
throws MalformedURLException; |
| 152 |
|
|
| 153 |
|
|
| 154 |
|
|
| 155 |
|
|
| 156 |
|
@return |
| 157 |
|
|
| 158 |
|
protected abstract boolean useGetRequest(); |
| 159 |
|
|
| 160 |
|
|
| 161 |
|
|
| 162 |
|
|
| 163 |
|
|
| 164 |
|
@return |
| 165 |
|
@see |
| 166 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 167 |
0 |
protected String getRequestMimeType()... |
| 168 |
|
{ |
| 169 |
0 |
return "application/json"; |
| 170 |
|
} |
| 171 |
|
|
| 172 |
|
|
| 173 |
|
|
| 174 |
|
|
| 175 |
|
|
| 176 |
|
@return |
| 177 |
|
@see |
| 178 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 179 |
0 |
protected String getResponseMimeType()... |
| 180 |
|
{ |
| 181 |
0 |
return "application/json"; |
| 182 |
|
} |
| 183 |
|
|
| 184 |
|
|
| 185 |
|
|
| 186 |
|
|
| 187 |
|
|
| 188 |
|
@see |
| 189 |
|
@return |
| 190 |
|
|
| |
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 5 |
Complexity Density: 0.38 |
|
| 191 |
0 |
@SuppressWarnings("unchecked")... |
| 192 |
|
boolean checkEnsembl() |
| 193 |
|
{ |
| 194 |
0 |
BufferedReader br = null; |
| 195 |
0 |
String pingUrl = getDomain() + "/info/ping" + CONTENT_TYPE_JSON; |
| 196 |
0 |
try |
| 197 |
|
{ |
| 198 |
|
|
| 199 |
|
|
| 200 |
|
|
| 201 |
|
|
| 202 |
|
|
| 203 |
|
|
| 204 |
|
|
| 205 |
0 |
Map<String, Object> val = (Map<String, Object>) getJSON( |
| 206 |
|
new URL(pingUrl), null, 2 * 1000, MODE_MAP, null); |
| 207 |
0 |
if (val == null) |
| 208 |
|
{ |
| 209 |
0 |
return false; |
| 210 |
|
} |
| 211 |
0 |
String pingString = val.get("ping").toString(); |
| 212 |
0 |
return pingString != null; |
| 213 |
|
} catch (Throwable t) |
| 214 |
|
{ |
| 215 |
0 |
jalview.bin.Console.errPrintln( |
| 216 |
|
"Error connecting to " + pingUrl + ": " + t.getMessage()); |
| 217 |
|
} finally |
| 218 |
|
{ |
| 219 |
0 |
if (br != null) |
| 220 |
|
{ |
| 221 |
0 |
try |
| 222 |
|
{ |
| 223 |
0 |
br.close(); |
| 224 |
|
} catch (IOException e) |
| 225 |
|
{ |
| 226 |
|
|
| 227 |
|
} |
| 228 |
|
} |
| 229 |
|
} |
| 230 |
0 |
return false; |
| 231 |
|
} |
| 232 |
|
|
| 233 |
|
protected final static int MODE_ARRAY = 0; |
| 234 |
|
|
| 235 |
|
protected final static int MODE_MAP = 1; |
| 236 |
|
|
| 237 |
|
protected final static int MODE_ITERATOR = 2; |
| 238 |
|
|
| 239 |
|
|
| 240 |
|
|
| 241 |
|
|
| 242 |
|
|
| 243 |
|
|
| 244 |
|
|
| 245 |
|
|
| 246 |
|
|
| 247 |
|
|
| 248 |
|
|
| 249 |
|
|
| 250 |
|
|
| 251 |
|
|
| 252 |
|
|
| 253 |
|
|
| 254 |
|
|
| 255 |
|
|
| 256 |
|
|
| 257 |
|
|
| 258 |
|
|
| 259 |
|
|
| 260 |
|
|
| 261 |
|
|
| 262 |
|
|
| 263 |
|
|
| 264 |
|
|
| 265 |
|
|
| 266 |
|
|
| 267 |
|
|
| 268 |
|
|
| 269 |
|
|
| 270 |
|
|
| 271 |
|
|
| 272 |
|
|
| 273 |
|
|
| 274 |
|
@param |
| 275 |
|
@param |
| 276 |
|
|
| 277 |
|
@param |
| 278 |
|
|
| 279 |
|
@return |
| 280 |
|
@throws |
| 281 |
|
@throws |
| 282 |
|
|
| |
|
| 0% |
Uncovered Elements: 27 (27) |
Complexity: 5 |
Complexity Density: 0.26 |
|
| 283 |
0 |
private Object getJSON(URL url, List<String> ids, int readTimeout)... |
| 284 |
|
throws IOException, ParseException |
| 285 |
|
{ |
| 286 |
|
|
| 287 |
0 |
if (readTimeout < 0) |
| 288 |
|
{ |
| 289 |
0 |
readTimeout = DEFAULT_READ_TIMEOUT; |
| 290 |
|
} |
| 291 |
0 |
int retriesLeft = MAX_RETRIES; |
| 292 |
0 |
HttpURLConnection connection = null; |
| 293 |
0 |
int responseCode = 0; |
| 294 |
|
|
| 295 |
0 |
Platform.setAjaxJSON(url); |
| 296 |
|
|
| 297 |
0 |
while (retriesLeft > 0) |
| 298 |
|
{ |
| 299 |
0 |
connection = tryConnection(url, ids, readTimeout); |
| 300 |
0 |
responseCode = connection.getResponseCode(); |
| 301 |
0 |
if (responseCode == HTTP_OVERLOAD) |
| 302 |
|
{ |
| 303 |
0 |
retriesLeft--; |
| 304 |
0 |
checkRetryAfter(connection); |
| 305 |
|
} |
| 306 |
|
else |
| 307 |
|
{ |
| 308 |
0 |
retriesLeft = 0; |
| 309 |
|
} |
| 310 |
|
} |
| 311 |
0 |
if (responseCode != HTTP_OK) |
| 312 |
|
{ |
| 313 |
|
|
| 314 |
|
|
| 315 |
|
|
| 316 |
|
|
| 317 |
0 |
jalview.bin.Console.errPrintln("Response code " + responseCode); |
| 318 |
|
|
| 319 |
|
|
| 320 |
0 |
return null; |
| 321 |
|
} |
| 322 |
|
|
| 323 |
0 |
InputStream response = connection.getInputStream(); |
| 324 |
|
|
| 325 |
|
|
| 326 |
0 |
Object ret = Platform.parseJSON(response); |
| 327 |
|
|
| 328 |
|
|
| 329 |
|
|
| 330 |
0 |
return ret; |
| 331 |
|
} |
| 332 |
|
|
| 333 |
|
|
| 334 |
|
@param |
| 335 |
|
@param |
| 336 |
|
@param |
| 337 |
|
@return |
| 338 |
|
@throws |
| 339 |
|
@throws |
| 340 |
|
|
| |
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 3 |
Complexity Density: 0.23 |
|
| 341 |
0 |
protected HttpURLConnection tryConnection(URL url, List<String> ids,... |
| 342 |
|
int readTimeout) throws IOException, ProtocolException |
| 343 |
|
{ |
| 344 |
|
|
| 345 |
|
|
| 346 |
0 |
HttpURLConnection connection = (HttpURLConnection) HttpUtils |
| 347 |
|
.openConnection(url); |
| 348 |
|
|
| 349 |
|
|
| 350 |
|
|
| 351 |
|
|
| 352 |
|
|
| 353 |
0 |
boolean multipleIds = ids != null && ids.size() > 1; |
| 354 |
0 |
connection.setRequestMethod( |
| 355 |
0 |
multipleIds ? HttpMethod.POST : HttpMethod.GET); |
| 356 |
0 |
connection.setRequestProperty("Content-Type", getRequestMimeType()); |
| 357 |
0 |
connection.setRequestProperty("Accept", getResponseMimeType()); |
| 358 |
|
|
| 359 |
0 |
connection.setDoInput(true); |
| 360 |
0 |
connection.setDoOutput(multipleIds); |
| 361 |
|
|
| 362 |
0 |
connection.setUseCaches(false); |
| 363 |
0 |
connection.setConnectTimeout(CONNECT_TIMEOUT_MS); |
| 364 |
0 |
connection.setReadTimeout(readTimeout); |
| 365 |
|
|
| 366 |
0 |
if (multipleIds) |
| 367 |
|
{ |
| 368 |
0 |
writePostBody(connection, ids); |
| 369 |
|
} |
| 370 |
0 |
return connection; |
| 371 |
|
} |
| 372 |
|
|
| 373 |
|
|
| 374 |
|
|
| 375 |
|
|
| 376 |
|
|
| 377 |
|
@see |
| 378 |
|
@param |
| 379 |
|
|
| |
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 5 |
Complexity Density: 0.62 |
|
| 380 |
0 |
void checkRetryAfter(HttpURLConnection connection)... |
| 381 |
|
{ |
| 382 |
0 |
String retryDelay = connection.getHeaderField("Retry-After"); |
| 383 |
|
|
| 384 |
|
|
| 385 |
|
|
| 386 |
|
|
| 387 |
0 |
if (retryDelay != null) |
| 388 |
|
{ |
| 389 |
0 |
try |
| 390 |
|
{ |
| 391 |
0 |
int retrySecs = Integer.valueOf(retryDelay); |
| 392 |
0 |
if (retrySecs > 0 && retrySecs < 10) |
| 393 |
|
{ |
| 394 |
0 |
jalview.bin.Console.errPrintln( |
| 395 |
|
"Ensembl REST service rate limit exceeded, waiting " |
| 396 |
|
+ retryDelay + " seconds before retrying"); |
| 397 |
0 |
Thread.sleep(1000 * retrySecs); |
| 398 |
|
} |
| 399 |
|
} catch (NumberFormatException | InterruptedException e) |
| 400 |
|
{ |
| 401 |
0 |
jalview.bin.Console.errPrintln( |
| 402 |
|
"Error handling Retry-After: " + e.getMessage()); |
| 403 |
|
} |
| 404 |
|
} |
| 405 |
|
} |
| 406 |
|
|
| 407 |
|
|
| 408 |
|
|
| 409 |
|
|
| 410 |
|
|
| 411 |
|
|
| 412 |
|
|
| 413 |
|
@return |
| 414 |
|
|
| |
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.33 |
|
| 415 |
0 |
protected boolean isEnsemblAvailable()... |
| 416 |
|
{ |
| 417 |
0 |
EnsemblData info = domainData.get(getDomain()); |
| 418 |
|
|
| 419 |
0 |
long now = System.currentTimeMillis(); |
| 420 |
|
|
| 421 |
|
|
| 422 |
|
|
| 423 |
|
|
| 424 |
0 |
boolean retestAvailability = (now |
| 425 |
|
- info.lastAvailableCheckTime) > AVAILABILITY_RETEST_INTERVAL; |
| 426 |
0 |
if (!info.restAvailable || retestAvailability) |
| 427 |
|
{ |
| 428 |
0 |
info.restAvailable = checkEnsembl(); |
| 429 |
0 |
info.lastAvailableCheckTime = now; |
| 430 |
|
} |
| 431 |
|
|
| 432 |
|
|
| 433 |
|
|
| 434 |
|
|
| 435 |
0 |
boolean refetchVersion = (now |
| 436 |
|
- info.lastVersionCheckTime) > VERSION_RETEST_INTERVAL; |
| 437 |
0 |
if (refetchVersion) |
| 438 |
|
{ |
| 439 |
0 |
checkEnsemblRestVersion(); |
| 440 |
0 |
checkEnsemblDataVersion(); |
| 441 |
0 |
info.lastVersionCheckTime = now; |
| 442 |
|
} |
| 443 |
|
|
| 444 |
0 |
return info.restAvailable; |
| 445 |
|
} |
| 446 |
|
|
| 447 |
|
|
| 448 |
|
|
| 449 |
|
|
| 450 |
|
|
| 451 |
|
@param |
| 452 |
|
@param |
| 453 |
|
@throws |
| 454 |
|
|
| |
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 3 |
Complexity Density: 0.16 |
|
| 455 |
0 |
protected void writePostBody(HttpURLConnection connection,... |
| 456 |
|
List<String> ids) throws IOException |
| 457 |
|
{ |
| 458 |
0 |
boolean first; |
| 459 |
0 |
StringBuilder postBody = new StringBuilder(64); |
| 460 |
0 |
postBody.append("{\"ids\":["); |
| 461 |
0 |
first = true; |
| 462 |
0 |
for (int i = 0, n = ids.size(); i < n; i++) |
| 463 |
|
{ |
| 464 |
0 |
String id = ids.get(i); |
| 465 |
0 |
if (!first) |
| 466 |
|
{ |
| 467 |
0 |
postBody.append(","); |
| 468 |
|
} |
| 469 |
0 |
first = false; |
| 470 |
0 |
postBody.append("\""); |
| 471 |
0 |
postBody.append(id.trim()); |
| 472 |
0 |
postBody.append("\""); |
| 473 |
|
} |
| 474 |
0 |
postBody.append("]}"); |
| 475 |
0 |
byte[] thepostbody = postBody.toString().getBytes(); |
| 476 |
0 |
connection.setRequestProperty("Content-Length", |
| 477 |
|
Integer.toString(thepostbody.length)); |
| 478 |
0 |
DataOutputStream wr = new DataOutputStream( |
| 479 |
|
connection.getOutputStream()); |
| 480 |
0 |
wr.write(thepostbody); |
| 481 |
0 |
wr.flush(); |
| 482 |
0 |
wr.close(); |
| 483 |
|
} |
| 484 |
|
|
| 485 |
|
|
| 486 |
|
|
| 487 |
|
|
| 488 |
|
|
| 489 |
|
@param |
| 490 |
|
|
| 491 |
|
@param |
| 492 |
|
|
| 493 |
|
@param |
| 494 |
|
|
| 495 |
|
@param |
| 496 |
|
|
| 497 |
|
@param |
| 498 |
|
|
| 499 |
|
@return |
| 500 |
|
@throws |
| 501 |
|
@throws |
| 502 |
|
|
| 503 |
|
@author |
| 504 |
|
|
| |
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 9 |
Complexity Density: 0.6 |
|
| 505 |
0 |
@SuppressWarnings("unchecked")... |
| 506 |
|
protected Object getJSON(URL url, List<String> ids, int msDelay, int mode, |
| 507 |
|
String mapKey) throws IOException, ParseException |
| 508 |
|
{ |
| 509 |
0 |
if (url == null) |
| 510 |
|
{ |
| 511 |
0 |
url = getUrl(ids); |
| 512 |
|
} |
| 513 |
|
|
| 514 |
0 |
Object json = (url == null ? null : getJSON(url, ids, msDelay)); |
| 515 |
|
|
| 516 |
0 |
if (json != null && mapKey != null) |
| 517 |
|
{ |
| 518 |
0 |
json = ((Map<String, Object>) json).get(mapKey); |
| 519 |
|
} |
| 520 |
0 |
if (json == null) |
| 521 |
|
{ |
| 522 |
0 |
return null; |
| 523 |
|
} |
| 524 |
0 |
switch (mode) |
| 525 |
|
{ |
| 526 |
0 |
case MODE_ARRAY: |
| 527 |
0 |
case MODE_MAP: |
| 528 |
0 |
break; |
| 529 |
0 |
case MODE_ITERATOR: |
| 530 |
0 |
json = ((List<Object>) json).iterator(); |
| 531 |
0 |
break; |
| 532 |
|
} |
| 533 |
0 |
return json; |
| 534 |
|
} |
| 535 |
|
|
| 536 |
|
|
| 537 |
|
|
| 538 |
|
|
| 539 |
|
@return |
| 540 |
|
|
| |
|
| 0% |
Uncovered Elements: 25 (25) |
Complexity: 6 |
Complexity Density: 0.32 |
|
| 541 |
0 |
@SuppressWarnings("unchecked")... |
| 542 |
|
private void checkEnsemblRestVersion() |
| 543 |
|
{ |
| 544 |
0 |
EnsemblData info = domainData.get(getDomain()); |
| 545 |
|
|
| 546 |
0 |
try |
| 547 |
|
{ |
| 548 |
0 |
Map<String, Object> val = (Map<String, Object>) getJSON( |
| 549 |
|
new URL(getDomain() + "/info/rest" + CONTENT_TYPE_JSON), null, |
| 550 |
|
-1, MODE_MAP, null); |
| 551 |
0 |
if (val == null) |
| 552 |
|
{ |
| 553 |
0 |
return; |
| 554 |
|
} |
| 555 |
0 |
String version = val.get("release").toString(); |
| 556 |
0 |
String majorVersion = version.substring(0, version.indexOf(".")); |
| 557 |
0 |
String expected = info.expectedRestVersion; |
| 558 |
0 |
String expectedMajorVersion = expected.substring(0, |
| 559 |
|
expected.indexOf(".")); |
| 560 |
0 |
info.restMajorVersionMismatch = false; |
| 561 |
0 |
try |
| 562 |
|
{ |
| 563 |
|
|
| 564 |
|
|
| 565 |
|
|
| 566 |
|
|
| 567 |
0 |
if (Float.valueOf(majorVersion) > Float |
| 568 |
|
.valueOf(expectedMajorVersion)) |
| 569 |
|
{ |
| 570 |
0 |
info.restMajorVersionMismatch = true; |
| 571 |
|
} |
| 572 |
|
} catch (NumberFormatException e) |
| 573 |
|
{ |
| 574 |
0 |
jalview.bin.Console |
| 575 |
|
.errPrintln("Error in REST version: " + e.toString()); |
| 576 |
|
} |
| 577 |
|
|
| 578 |
|
|
| 579 |
|
|
| 580 |
|
|
| 581 |
|
|
| 582 |
|
|
| 583 |
0 |
boolean laterVersion = StringUtils.compareVersions(version, |
| 584 |
|
expected) == 1; |
| 585 |
0 |
if (laterVersion) |
| 586 |
|
{ |
| 587 |
0 |
jalview.bin.Console.errPrintln(String.format( |
| 588 |
|
"EnsemblRestClient expected %s REST version %s but found %s, see %s", |
| 589 |
|
getDbSource(), expected, version, REST_CHANGE_LOG)); |
| 590 |
|
} |
| 591 |
0 |
info.restVersion = version; |
| 592 |
|
} catch (Throwable t) |
| 593 |
|
{ |
| 594 |
0 |
jalview.bin.Console.errPrintln( |
| 595 |
|
"Error checking Ensembl REST version: " + t.getMessage()); |
| 596 |
|
} |
| 597 |
|
} |
| 598 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 599 |
0 |
public boolean isRestMajorVersionMismatch()... |
| 600 |
|
{ |
| 601 |
0 |
return domainData.get(getDomain()).restMajorVersionMismatch; |
| 602 |
|
} |
| 603 |
|
|
| 604 |
|
|
| 605 |
|
|
| 606 |
|
|
| 607 |
|
@return |
| 608 |
|
|
| |
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.38 |
|
| 609 |
0 |
@SuppressWarnings("unchecked")... |
| 610 |
|
private void checkEnsemblDataVersion() |
| 611 |
|
{ |
| 612 |
0 |
Map<String, Object> val; |
| 613 |
0 |
try |
| 614 |
|
{ |
| 615 |
0 |
val = (Map<String, Object>) getJSON( |
| 616 |
|
new URL(getDomain() + "/info/data" + CONTENT_TYPE_JSON), null, |
| 617 |
|
-1, MODE_MAP, null); |
| 618 |
0 |
if (val == null) |
| 619 |
|
{ |
| 620 |
0 |
return; |
| 621 |
|
} |
| 622 |
0 |
List<Object> versions = (List<Object>) val.get("releases"); |
| 623 |
0 |
domainData.get(getDomain()).dataVersion = versions.get(0).toString(); |
| 624 |
|
} catch (Throwable e) |
| 625 |
|
{ |
| 626 |
0 |
jalview.bin.Console.errPrintln( |
| 627 |
|
"Error checking Ensembl data version: " + e.getMessage()); |
| 628 |
|
} |
| 629 |
|
} |
| 630 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 631 |
0 |
public String getEnsemblDataVersion()... |
| 632 |
|
{ |
| 633 |
0 |
return domainData.get(getDomain()).dataVersion; |
| 634 |
|
} |
| 635 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 636 |
0 |
@Override... |
| 637 |
|
public String getDbVersion() |
| 638 |
|
{ |
| 639 |
0 |
return getEnsemblDataVersion(); |
| 640 |
|
} |
| 641 |
|
|
| 642 |
|
} |