org.sonatype.nexus.repository.group.GroupHandler Java Examples

The following examples show how to use org.sonatype.nexus.repository.group.GroupHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ComposerGroupMergingHandler.java    From nexus-repository-composer with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected final Response doGet(@Nonnull final Context context,
                               @Nonnull final GroupHandler.DispatchedRepositories dispatched)
    throws Exception
{
  Repository repository = context.getRepository();
  GroupFacet groupFacet = repository.facet(GroupFacet.class);

  makeUnconditional(context.getRequest());
  Map<Repository, Response> responses;
  try {
    responses = getAll(context, groupFacet.members(), dispatched);
  }
  finally {
    makeConditional(context.getRequest());
  }

  List<Payload> payloads = responses.values().stream()
      .filter(response -> response.getStatus().getCode() == HttpStatus.OK && response.getPayload() != null)
      .map(Response::getPayload)
      .collect(Collectors.toList());
  if (payloads.isEmpty()) {
    return notFoundResponse(context);
  }
  return HttpResponses.ok(merge(repository, payloads));
}
 
Example #2
Source File: PackagesGroupHandler.java    From nexus-repository-r with Eclipse Public License 1.0 6 votes vote down vote up
@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));
}
 
Example #3
Source File: OrientPyPiIndexGroupHandler.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Response doGet(@Nonnull final Context context,
                         @Nonnull final GroupHandler.DispatchedRepositories dispatched)
    throws Exception
{
  checkNotNull(context);
  checkNotNull(dispatched);

  String name;
  AssetKind assetKind = context.getAttributes().get(AssetKind.class);
  if (ROOT_INDEX.equals(assetKind)) {
    name = INDEX_PATH_PREFIX;
  }
  else {
    name = name(context.getAttributes().require(TokenMatcher.State.class));
  }

  OrientPyPiGroupFacet groupFacet = context.getRepository().facet(OrientPyPiGroupFacet.class);
  Content content = groupFacet.getFromCache(name, assetKind);

  Map<Repository, Response> memberResponses = getAll(context, groupFacet.members(), dispatched);

  if (groupFacet.isStale(name, content, memberResponses)) {
    return HttpResponses.ok(
        groupFacet.buildIndexRoot(
            name, assetKind, lazyMergeResult(name, assetKind, memberResponses)));
  }

  return HttpResponses.ok(content);
}