+ /**
+ * Fetches and checks Ensembl's REST version number
+ *
+ * @return
+ */
+ private void checkEnsemblRestVersion()
+ {
+ EnsemblInfo info = domainData.get(getDomain());
+
+ JSONParser jp = new JSONParser();
+ URL url = null;
+ try
+ {
+ url = new URL(getDomain()
+ + "/info/rest?content-type=application/json");
+ BufferedReader br = getHttpResponse(url, null);
+ JSONObject val = (JSONObject) jp.parse(br);
+ String version = val.get("release").toString();
+ String majorVersion = version.substring(0, version.indexOf("."));
+ String expected = info.expectedRestVersion;
+ String expectedMajorVersion = expected.substring(0,
+ expected.indexOf("."));
+ info.restMajorVersionMismatch = false;
+ try
+ {
+ /*
+ * if actual REST major version is ahead of what we expect,
+ * record this in case we want to warn the user
+ */
+ if (Float.valueOf(majorVersion) > Float
+ .valueOf(expectedMajorVersion))
+ {
+ info.restMajorVersionMismatch = true;
+ }
+ } catch (NumberFormatException e)
+ {
+ System.err.println("Error in REST version: " + e.toString());
+ }
+
+ /*
+ * check if REST version is later than what Jalview has tested against,
+ * if so warn; we don't worry if it is earlier (this indicates Jalview has
+ * been tested in advance against the next pending REST version)
+ */
+ boolean laterVersion = StringUtils.compareVersions(version, expected) == 1;
+ if (laterVersion)
+ {
+ System.err
+ .println(String
+ .format("EnsemblRestClient expected %s REST version %s but found %s, see %s",
+ getDbSource(), expected, version,
+ REST_CHANGE_LOG));
+ }
+ info.restVersion = version;
+ } catch (Throwable t)
+ {
+ System.err.println("Error checking Ensembl REST version: "
+ + t.getMessage());
+ }
+ }
+
+ public boolean isRestMajorVersionMismatch()
+ {
+ return domainData.get(getDomain()).restMajorVersionMismatch;
+ }
+
+ /**
+ * Fetches and checks Ensembl's data version number
+ *
+ * @return
+ */
+ private void checkEnsemblDataVersion()
+ {
+ JSONParser jp = new JSONParser();
+ URL url = null;
+ try
+ {
+ url = new URL(getDomain()
+ + "/info/data?content-type=application/json");
+ BufferedReader br = getHttpResponse(url, null);
+ JSONObject val = (JSONObject) jp.parse(br);
+ JSONArray versions = (JSONArray) val.get("releases");
+ domainData.get(getDomain()).dataVersion = versions.get(0).toString();
+ } catch (Throwable t)
+ {
+ System.err.println("Error checking Ensembl data version: "
+ + t.getMessage());
+ }
+ }
+
+ public String getEnsemblDataVersion()
+ {
+ return domainData.get(getDomain()).dataVersion;
+ }
+
+ @Override
+ public String getDbVersion()
+ {
+ return getEnsemblDataVersion();
+ }
+