Search in sources :

Example 1 with ReplicationDTO

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;
}
Also used : Response(javax.ws.rs.core.Response) ReplicationDTO(org.commonjava.indy.model.core.dto.ReplicationDTO) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) IOException(java.io.IOException) StoreKey(org.commonjava.indy.model.core.StoreKey) LinkedHashMap(java.util.LinkedHashMap) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

ApiImplicitParams (io.swagger.annotations.ApiImplicitParams)1 ApiOperation (io.swagger.annotations.ApiOperation)1 IOException (java.io.IOException)1 LinkedHashMap (java.util.LinkedHashMap)1 POST (javax.ws.rs.POST)1 Produces (javax.ws.rs.Produces)1 Response (javax.ws.rs.core.Response)1 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)1 StoreKey (org.commonjava.indy.model.core.StoreKey)1 ReplicationDTO (org.commonjava.indy.model.core.dto.ReplicationDTO)1