in src/main/java/org/apache/sling/cli/impl/nexus/RepositoryService.java [170:205]
public Set<Artifact> getArtifacts(StagingRepository repository) throws IOException {
Set<Artifact> artifacts = new HashSet<>();
try (CloseableHttpClient client = httpClientFactory.newClient()) {
HttpGet get =
newGet("/service/local/lucene/search?g=org.apache.sling&repositoryId=" +
repository.getRepositoryId());
try (CloseableHttpResponse response = client.execute(get)) {
try (InputStream content = response.getEntity().getContent();
InputStreamReader reader = new InputStreamReader(content)) {
JsonParser parser = new JsonParser();
JsonObject json = parser.parse(reader).getAsJsonObject();
JsonArray data = json.get("data").getAsJsonArray();
for (JsonElement dataElement : data) {
JsonObject dataElementJson = dataElement.getAsJsonObject();
String groupId = dataElementJson.get("groupId").getAsString();
String artifactId = dataElementJson.get("artifactId").getAsString();
String version = dataElementJson.get("version").getAsString();
JsonArray artifactLinksArray =
dataElementJson.get("artifactHits").getAsJsonArray().get(0).getAsJsonObject().get("artifactLinks")
.getAsJsonArray();
for (JsonElement artifactLinkElement : artifactLinksArray) {
JsonObject artifactLinkJson = artifactLinkElement.getAsJsonObject();
String type = artifactLinkJson.get("extension").getAsString();
String classifier = null;
if (artifactLinkJson.has("classifier")) {
classifier = artifactLinkJson.get("classifier").getAsString();
}
artifacts.add(new Artifact(repository, groupId, artifactId, version, classifier, type));
}
}
}
}
}
return artifacts;
}