use of org.commonjava.indy.promote.model.PathsPromoteRequest in project indy by Commonjava.
the class PromoteResource method promotePaths.
@ApiOperation("Promote paths from a source repository into a target repository/group (subject to validation).")
@ApiResponse(code = 200, message = "Promotion operation finished (consult response content for success/failure).", response = PathsPromoteResult.class)
@ApiImplicitParam(name = "body", paramType = "body", value = "JSON request specifying source and target, with other configuration options", allowMultiple = false, required = true, dataType = "org.commonjava.indy.promote.model.PathsPromoteRequest")
@Path("/paths/promote")
@POST
@Consumes(ApplicationContent.application_json)
public Response promotePaths(@Context final HttpServletRequest request, @Context final UriInfo uriInfo) {
PathsPromoteRequest req;
Response response;
try {
final String json = IOUtils.toString(request.getInputStream());
logger.info("Got promotion request:\n{}", json);
req = mapper.readValue(json, PathsPromoteRequest.class);
} catch (final IOException e) {
response = responseHelper.formatResponse(e, "Failed to read DTO from request body.");
return response;
}
try {
final String baseUrl = getBaseUrlByStoreKey(uriInfo, req.getSource());
final PathsPromoteResult result = manager.promotePaths(req, baseUrl);
response = responseHelper.formatOkResponseWithJsonEntity(result);
logger.info("Send promotion result:\n{}", response.getEntity());
} catch (PromotionException | IndyWorkflowException e) {
logger.error(e.getMessage(), e);
response = responseHelper.formatResponse(e);
}
return response;
}
use of org.commonjava.indy.promote.model.PathsPromoteRequest in project indy by Commonjava.
the class NPMVersionPatternRuleTest method run.
@Test
@Category(EventDependent.class)
public void run() throws Exception {
deployResource(INVALID_PKG, "npm-version-pattern/package-invalid.json");
deployResource(VALID_PKG, "npm-version-pattern/package-valid.json");
deployResource(SCOPED_INVALID_PKG, "npm-version-pattern/package-scoped-invalid.json");
deployResource(SCOPED_VALID_PKG, "npm-version-pattern/package-scoped-valid.json");
deployResource(REDHAT_SCOPED_INVALID_PKG, "npm-version-pattern/package-redhat-scoped-invalid.json");
deployResource(REDHAT_SCOPED_VALID_PKG, "npm-version-pattern/package-redhat-scoped-valid.json");
assertThat(client.content().exists(source.getKey(), INVALID_TAR), equalTo(true));
assertThat(client.content().exists(source.getKey(), SCOPED_INVALID_TAR), equalTo(true));
assertThat(client.content().exists(source.getKey(), INVALID_TAR), equalTo(true));
assertThat(client.content().exists(source.getKey(), VALID_TAR), equalTo(true));
assertThat(client.content().exists(source.getKey(), REDHAT_SCOPED_INVALID_TAR), equalTo(true));
assertThat(client.content().exists(source.getKey(), REDHAT_SCOPED_VALID_TAR), equalTo(true));
waitForEventPropagation();
Thread.sleep(30 * 1000);
PathsPromoteRequest request = new PathsPromoteRequest(source.getKey(), target.getKey(), INVALID_TAR, VALID_TAR, SCOPED_INVALID_TAR, SCOPED_VALID_TAR, REDHAT_SCOPED_INVALID_TAR, REDHAT_SCOPED_VALID_TAR);
check(request);
request = new PathsPromoteRequest(source.getKey(), target.getKey());
check(request);
}
Aggregations