in src/main/java/org/apache/sling/maven/bundlesupport/FsMountMojo.java [341:368]
private String getBundleInstalledVersion(
CloseableHttpClient httpClient, final String bundleSymbolicName, final URI consoleTargetUrl)
throws IOException {
final URI getUrl = consoleTargetUrl.resolve("bundles/" + bundleSymbolicName + ".json");
getLog().debug("Get bundle data via request to " + getUrl);
final HttpGet get = new HttpGet(getUrl);
try {
final String jsonText = httpClient.execute(get, new BasicHttpClientResponseHandler());
JsonObject response = JsonSupport.parseObject(jsonText);
JsonArray data = response.getJsonArray("data");
if (!data.isEmpty()) {
JsonObject bundleData = data.getJsonObject(0);
return bundleData.getString("version");
}
} catch (JsonException ex) {
throw new IOException("Reading bundle data from " + getUrl + " failed, cause: " + ex.getMessage(), ex);
} catch (HttpResponseException e) {
// accept 404 response
if (e.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
return null;
}
throw e;
}
// no version detected, bundle is not installed
return null;
}