Search in sources :

Example 6 with Repository

use of org.sonatype.nexus.repository.Repository 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));
}
Also used : Response(org.sonatype.nexus.repository.view.Response) RPackagesUtils(org.sonatype.nexus.repository.r.internal.util.RPackagesUtils) CompressorException(org.apache.commons.compress.compressors.CompressorException) GroupFacet(org.sonatype.nexus.repository.group.GroupFacet) Context(org.sonatype.nexus.repository.view.Context) RException(org.sonatype.nexus.repository.r.internal.RException) HttpStatus(org.sonatype.nexus.repository.http.HttpStatus) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) IOException(java.io.IOException) HttpResponses(org.sonatype.nexus.repository.http.HttpResponses) CompressorStreamFactory(org.apache.commons.compress.compressors.CompressorStreamFactory) Singleton(javax.inject.Singleton) Collectors(java.util.stream.Collectors) GZIP(org.apache.commons.compress.compressors.CompressorStreamFactory.GZIP) List(java.util.List) Repository(org.sonatype.nexus.repository.Repository) GroupHandler(org.sonatype.nexus.repository.group.GroupHandler) Map(java.util.Map) Payload(org.sonatype.nexus.repository.view.Payload) Named(javax.inject.Named) Response(org.sonatype.nexus.repository.view.Response) Nonnull(javax.annotation.Nonnull) InputStream(java.io.InputStream) GroupFacet(org.sonatype.nexus.repository.group.GroupFacet) Repository(org.sonatype.nexus.repository.Repository) List(java.util.List) Map(java.util.Map)

Example 7 with Repository

use of org.sonatype.nexus.repository.Repository in project nexus-repository-r by sonatype-nexus-community.

the class RResourceIT method createProxy.

@Test
public void createProxy() throws Exception {
    AbstractRepositoryApiRequest request = createProxyRequest(true);
    Response response = post(getCreateRepositoryPathUrl(ProxyType.NAME), request);
    assertEquals(Status.CREATED.getStatusCode(), response.getStatus());
    Repository repository = repositoryManager.get(request.getName());
    assertNotNull(repository);
    assertEquals(RFormat.NAME, repository.getFormat().getValue());
    assertEquals(ProxyType.NAME, repository.getType().getValue());
    repositoryManager.delete(request.getName());
}
Also used : Response(javax.ws.rs.core.Response) Repository(org.sonatype.nexus.repository.Repository) AbstractRepositoryApiRequest(org.sonatype.nexus.repository.rest.api.model.AbstractRepositoryApiRequest) Test(org.junit.Test)

Example 8 with Repository

use of org.sonatype.nexus.repository.Repository in project nexus-repository-r by sonatype-nexus-community.

the class RResourceIT method updateHosted.

@Test
public void updateHosted() throws Exception {
    repos.createRHosted(HOSTED_NAME);
    AbstractRepositoryApiRequest request = createHostedRequest(false);
    Response response = put(getUpdateRepositoryPathUrl(HostedType.NAME, HOSTED_NAME), request);
    assertEquals(Status.NO_CONTENT.getStatusCode(), response.getStatus());
    Repository repository = repositoryManager.get(request.getName());
    assertNotNull(repository);
    assertThat(repository.getConfiguration().attributes("storage").get("strictContentTypeValidation"), is(false));
    repositoryManager.delete(HOSTED_NAME);
}
Also used : Response(javax.ws.rs.core.Response) Repository(org.sonatype.nexus.repository.Repository) AbstractRepositoryApiRequest(org.sonatype.nexus.repository.rest.api.model.AbstractRepositoryApiRequest) Test(org.junit.Test)

Aggregations

Repository (org.sonatype.nexus.repository.Repository)8 Test (org.junit.Test)5 Response (javax.ws.rs.core.Response)4 AbstractRepositoryApiRequest (org.sonatype.nexus.repository.rest.api.model.AbstractRepositoryApiRequest)4 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 Nonnull (javax.annotation.Nonnull)2 Named (javax.inject.Named)2 Singleton (javax.inject.Singleton)2 CompressorException (org.apache.commons.compress.compressors.CompressorException)2 CompressorStreamFactory (org.apache.commons.compress.compressors.CompressorStreamFactory)2 GZIP (org.apache.commons.compress.compressors.CompressorStreamFactory.GZIP)2 GroupFacet (org.sonatype.nexus.repository.group.GroupFacet)2 GroupHandler (org.sonatype.nexus.repository.group.GroupHandler)2 HttpResponses (org.sonatype.nexus.repository.http.HttpResponses)2 HttpStatus (org.sonatype.nexus.repository.http.HttpStatus)2