use of org.sonatype.nexus.repository.view.Context in project nexus-repository-r by sonatype-nexus-community.
the class PackagesGroupHandler method doGet.
@Override
protected Response doGet(@Nonnull final Context context, @Nonnull final GroupHandler.DispatchedRepositories dispatched) throws Exception {
GroupFacet groupFacet = context.getRepository().facet(GroupFacet.class);
Map<Repository, Response> responses = getAll(context, groupFacet.members(), dispatched);
List<Response> successfulResponses = responses.values().stream().filter(response -> response.getStatus().getCode() == HttpStatus.OK && response.getPayload() != null).collect(Collectors.toList());
if (successfulResponses.isEmpty()) {
return notFoundResponse(context);
}
if (successfulResponses.size() == 1) {
return successfulResponses.get(0);
}
List<List<Map<String, String>>> parts = successfulResponses.stream().map(this::parseResponse).collect(Collectors.toList());
List<Map<String, String>> merged = RPackagesUtils.merge(parts);
return HttpResponses.ok(RPackagesUtils.buildPackages(merged));
}
use of org.sonatype.nexus.repository.view.Context in project nexus-repository-r by sonatype-nexus-community.
the class PackagesGroupHandler method doGet.
@Override
protected Response doGet(@Nonnull final Context context, @Nonnull final GroupHandler.DispatchedRepositories dispatched) throws Exception {
GroupFacet groupFacet = context.getRepository().facet(GroupFacet.class);
Map<Repository, Response> responses = getAll(context, groupFacet.members(), dispatched);
List<Response> successfulResponses = responses.values().stream().filter(response -> response.getStatus().getCode() == HttpStatus.OK && response.getPayload() != null).collect(Collectors.toList());
if (successfulResponses.isEmpty()) {
return notFoundResponse(context);
}
if (successfulResponses.size() == 1) {
return successfulResponses.get(0);
}
List<List<Map<String, String>>> parts = successfulResponses.stream().map(this::parseResponse).collect(Collectors.toList());
List<Map<String, String>> merged = RPackagesUtils.merge(parts);
return HttpResponses.ok(RPackagesUtils.buildPackages(merged));
}
Aggregations