use of org.commonjava.indy.model.core.dto.ReplicationDTO in project indy by Commonjava.
the class ReplicationHandler method replicate.
@ApiOperation("Replicate the stores of a remote Indy")
@ApiImplicitParams({ @ApiImplicitParam(paramType = "body", name = "body", dataType = "org.commonjava.indy.model.core.dto.ReplicationDTO", required = true, value = "The configuration determining how replication should be handled, and what remote site to replicate.") })
@POST
@Produces(ApplicationContent.application_json)
public Response replicate(@Context final HttpServletRequest request, @Context final SecurityContext securityContext) {
Response response;
try {
String user = securityManager.getUser(securityContext, request);
ReplicationDTO dto = serializer.readValue(request.getInputStream(), ReplicationDTO.class);
final Set<StoreKey> replicated = controller.replicate(dto, user);
final Map<String, Object> params = new LinkedHashMap<String, Object>();
params.put("replicationCount", replicated.size());
params.put("items", replicated);
response = responseHelper.formatOkResponseWithJsonEntity(params);
} catch (final IndyWorkflowException | IOException e) {
logger.error(String.format("Replication failed: %s", e.getMessage()), e);
response = responseHelper.formatResponse(e);
}
return response;
}
Aggregations