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();
}
}
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;
}
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;
}
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;
}
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));
}
Aggregations