use of org.openforis.commons.versioning.Version in project collect by openforis.
the class CollectInfoService method latestRelease.
private Version latestRelease() {
try {
CloseableHttpClient client = HttpClients.createDefault();
HttpGet request = new HttpGet(LATEST_RELEASE_MAVEN_METADATA_URL);
request.setConfig(RequestConfig.custom().setConnectTimeout(RELEASE_FETCH_TIMEOUT).build());
CloseableHttpResponse response = client.execute(request);
try {
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(is);
doc.getDocumentElement().normalize();
Element versioningElement = (Element) doc.getElementsByTagName("versioning").item(0);
NodeList releaseNodeList = versioningElement.getElementsByTagName("release");
if (releaseNodeList.getLength() == 1) {
Node releaseNode = releaseNodeList.item(0).getFirstChild();
String release = releaseNode.getNodeValue();
return new Version(release);
}
} finally {
response.close();
}
} catch (Exception e) {
}
return null;
}
Aggregations