use of org.sonatype.nexus.repository.Repository in project nexus-repository-r by sonatype-nexus-community.
the class RRestoreBlobStrategy method canAttemptRestore.
@Override
protected boolean canAttemptRestore(@Nonnull final RRestoreBlobData rRestoreBlobData) {
Repository repository = getRepository(rRestoreBlobData);
Optional<RRestoreFacet> rRestoreFacetFacet = repository.optionalFacet(RRestoreFacet.class);
if (!rRestoreFacetFacet.isPresent()) {
log.warn("Skipping as R Restore Facet not found on repository: {}", repository.getName());
return false;
}
return true;
}
use of org.sonatype.nexus.repository.Repository in project nexus-repository-r by sonatype-nexus-community.
the class RResourceIT method updateProxy.
@Test
public void updateProxy() throws Exception {
repos.createRProxy(PROXY_NAME, REMOTE_URL);
AbstractRepositoryApiRequest request = createProxyRequest(false);
Response response = put(getUpdateRepositoryPathUrl(ProxyType.NAME, PROXY_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(PROXY_NAME);
}
use of org.sonatype.nexus.repository.Repository in project nexus-repository-r by sonatype-nexus-community.
the class RResourceIT method createHosted.
@Test
public void createHosted() throws Exception {
AbstractRepositoryApiRequest request = createHostedRequest(true);
Response response = post(getCreateRepositoryPathUrl(HostedType.NAME), request);
assertEquals(Status.CREATED.getStatusCode(), response.getStatus());
Repository repository = repositoryManager.get(request.getName());
assertNotNull(repository);
assertEquals(RFormat.NAME, repository.getFormat().getValue());
assertEquals(HostedType.NAME, repository.getType().getValue());
repositoryManager.delete(request.getName());
}
use of org.sonatype.nexus.repository.Repository in project nexus-repository-r by sonatype-nexus-community.
the class RRoutingRuleIT method testBlockedRoutingRule.
@Test
public void testBlockedRoutingRule() throws Exception {
String packageFileName = "agricolae_1.0-1.tar.gz";
String allowedPackagePath = "bin/macosx/el-capitan/contrib/1.0/agricolae_1.0-1.tar.gz";
String blockedPackagePath = "bin/macosx/el-capitan/contrib/1.1/agricolae_1.0-1.tar.gz";
configureProxyBehaviour(allowedPackagePath, packageFileName);
configureProxyBehaviour(blockedPackagePath, packageFileName);
EntityId routingRuleId = createBlockedRoutingRule("r-blocking-rule", ".*/1.1/.*");
Repository proxyRepo = repos.createRProxy("test-r-blocking-proxy", proxyServer.getUrl().toString());
RClient client = rClient(proxyRepo);
attachRuleToRepository(proxyRepo, routingRuleId);
assertGetResponseStatus(client, proxyRepo, blockedPackagePath, 403);
assertGetResponseStatus(client, proxyRepo, allowedPackagePath, 200);
assertNoRequests(blockedPackagePath);
}
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));
}
Aggregations