Search in sources :

Example 11 with TrackedContentDTO

use of org.commonjava.indy.folo.dto.TrackedContentDTO in project indy by Commonjava.

the class FoloAdminResource method sealRecord.

@ApiOperation("Seal the tracking record for the specified key, to prevent further content logging")
@ApiResponses({ @ApiResponse(code = 404, message = "No such tracking record exists."), @ApiResponse(code = 200, message = "Tracking record", response = TrackedContentDTO.class) })
@Path("/{id}/record")
@POST
public Response sealRecord(@ApiParam("User-assigned tracking session key") @PathParam("id") final String id, @Context final UriInfo uriInfo) {
    final String baseUrl = uriInfo.getBaseUriBuilder().path("api").build().toString();
    TrackedContentDTO record = controller.seal(id, baseUrl);
    if (record == null) {
        return Response.status(Status.NOT_FOUND).build();
    } else {
        return Response.ok().build();
    }
}
Also used : TrackedContentDTO(org.commonjava.indy.folo.dto.TrackedContentDTO) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 12 with TrackedContentDTO

use of org.commonjava.indy.folo.dto.TrackedContentDTO in project indy by Commonjava.

the class FoloAdminResource method getReport.

@ApiOperation("Alias of /{id}/record, returns the tracking record for the specified key")
@ApiResponses({ @ApiResponse(code = 404, message = "No such tracking record exists."), @ApiResponse(code = 200, message = "Tracking record", response = TrackedContentDTO.class) })
@Path("/{id}/report")
@GET
public Response getReport(@ApiParam("User-assigned tracking session key") @PathParam("id") final String id, @Context final UriInfo uriInfo) {
    Response response;
    try {
        final String baseUrl = uriInfo.getBaseUriBuilder().path("api").build().toString();
        final TrackedContentDTO report = controller.renderReport(id, baseUrl);
        if (report == null) {
            response = Response.status(Status.NOT_FOUND).build();
        } else {
            response = formatOkResponseWithJsonEntity(report, objectMapper);
        }
    } catch (final IndyWorkflowException e) {
        logger.error(String.format("Failed to serialize tracking report for: %s. Reason: %s", id, e.getMessage()), e);
        response = formatResponse(e);
    }
    return response;
}
Also used : ResponseUtils.formatResponse(org.commonjava.indy.bind.jaxrs.util.ResponseUtils.formatResponse) Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.annotations.ApiResponse) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) TrackedContentDTO(org.commonjava.indy.folo.dto.TrackedContentDTO) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 13 with TrackedContentDTO

use of org.commonjava.indy.folo.dto.TrackedContentDTO in project indy by Commonjava.

the class FoloAdminResource method recalculateRecord.

@ApiOperation("Recalculate sizes and checksums for every file listed in a tracking record.")
@ApiResponses({ @ApiResponse(code = 200, response = TrackedContentDTO.class, message = "Recalculated tracking report"), @ApiResponse(code = 404, message = "No such tracking record can be found") })
@GET
@Path("/{id}/record/recalculate")
public Response recalculateRecord(@ApiParam("User-assigned tracking session key") @PathParam("id") String id, @Context final UriInfo uriInfo) {
    Response response;
    try {
        final String baseUrl = uriInfo.getBaseUriBuilder().path("api").build().toString();
        final TrackedContentDTO report = controller.recalculateRecord(id, baseUrl);
        if (report == null) {
            response = Response.status(Status.NOT_FOUND).build();
        } else {
            response = formatOkResponseWithJsonEntity(report, objectMapper);
        }
    } catch (final IndyWorkflowException e) {
        logger.error(String.format("Failed to serialize tracking report for: %s. Reason: %s", id, e.getMessage()), e);
        response = formatResponse(e);
    }
    return response;
}
Also used : ResponseUtils.formatResponse(org.commonjava.indy.bind.jaxrs.util.ResponseUtils.formatResponse) Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.annotations.ApiResponse) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) TrackedContentDTO(org.commonjava.indy.folo.dto.TrackedContentDTO) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 14 with TrackedContentDTO

use of org.commonjava.indy.folo.dto.TrackedContentDTO in project indy by Commonjava.

the class FoloAdminController method renderReport.

public TrackedContentDTO renderReport(final String id, final String apiBaseUrl) throws IndyWorkflowException {
    final TrackingKey tk = new TrackingKey(id);
    logger.debug("Retrieving tracking record for: {}", tk);
    final TrackedContentDTO record = constructContentDTO(recordManager.get(tk), apiBaseUrl);
    logger.debug("Got: {}", record);
    return record;
}
Also used : TrackingKey(org.commonjava.indy.folo.model.TrackingKey) TrackedContentDTO(org.commonjava.indy.folo.dto.TrackedContentDTO)

Example 15 with TrackedContentDTO

use of org.commonjava.indy.folo.dto.TrackedContentDTO in project indy by Commonjava.

the class PullReportWithoutContentAccess404Test method run.

@Test
public void run() throws Exception {
    final String trackingId = newName();
    boolean success = client.module(IndyFoloAdminClientModule.class).sealTrackingRecord(trackingId);
    assertThat(success, equalTo(true));
    final TrackedContentDTO report = client.module(IndyFoloAdminClientModule.class).getTrackingReport(trackingId);
    assertThat(report, notNullValue());
    Set<TrackedContentEntryDTO> downloads = report.getDownloads();
    assertThat(downloads == null || downloads.isEmpty(), equalTo(true));
    Set<TrackedContentEntryDTO> uploads = report.getUploads();
    assertThat(uploads == null || uploads.isEmpty(), equalTo(true));
}
Also used : IndyFoloAdminClientModule(org.commonjava.indy.folo.client.IndyFoloAdminClientModule) TrackedContentEntryDTO(org.commonjava.indy.folo.dto.TrackedContentEntryDTO) TrackedContentDTO(org.commonjava.indy.folo.dto.TrackedContentDTO) Test(org.junit.Test)

Aggregations

TrackedContentDTO (org.commonjava.indy.folo.dto.TrackedContentDTO)24 TrackedContentEntryDTO (org.commonjava.indy.folo.dto.TrackedContentEntryDTO)18 IndyFoloAdminClientModule (org.commonjava.indy.folo.client.IndyFoloAdminClientModule)17 Test (org.junit.Test)15 InputStream (java.io.InputStream)13 IndyFoloContentClientModule (org.commonjava.indy.folo.client.IndyFoloContentClientModule)11 ByteArrayInputStream (java.io.ByteArrayInputStream)10 StoreKey (org.commonjava.indy.model.core.StoreKey)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 RemoteRepository (org.commonjava.indy.model.core.RemoteRepository)6 ApiOperation (io.swagger.annotations.ApiOperation)4 ApiResponses (io.swagger.annotations.ApiResponses)4 Path (javax.ws.rs.Path)4 ApiResponse (io.swagger.annotations.ApiResponse)3 GET (javax.ws.rs.GET)3 Response (javax.ws.rs.core.Response)3 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)3 ResponseUtils.formatResponse (org.commonjava.indy.bind.jaxrs.util.ResponseUtils.formatResponse)3 BytemanTest (org.commonjava.indy.ftest.core.category.BytemanTest)3 BMRules (org.jboss.byteman.contrib.bmunit.BMRules)3