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 = responseHelper.formatOkResponseWithJsonEntity(report);
}
} catch (final IndyWorkflowException e) {
logger.error(String.format("Failed to serialize tracking report for: %s. Reason: %s", id, e.getMessage()), e);
response = responseHelper.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 = responseHelper.formatOkResponseWithJsonEntity(report);
}
} catch (final IndyWorkflowException e) {
logger.error(String.format("Failed to serialize tracking report for: %s. Reason: %s", id, e.getMessage()), e);
response = responseHelper.formatResponse(e);
}
return response;
}
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 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 RetrievedPomInAlwaysOnTrackingReportTest method run.
@Test
public void run() throws Exception {
final String testRepo = "test";
final PomRef pom = loadPom("simple.pom", Collections.<String, String>emptyMap());
final String url = server.formatUrl(testRepo, pom.path);
server.expect(url, 200, pom.pom);
final HttpGet get = new HttpGet(url);
final CloseableHttpClient client = proxiedHttp();
CloseableHttpResponse response = null;
InputStream stream = null;
try {
response = client.execute(get, proxyContext(USER, PASS));
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
stream = response.getEntity().getContent();
final String resultingPom = IOUtils.toString(stream);
assertThat(resultingPom, notNullValue());
assertThat(resultingPom, equalTo(pom.pom));
} finally {
IOUtils.closeQuietly(stream);
HttpResources.cleanupResources(get, response, client);
}
assertThat(this.client.module(IndyFoloAdminClientModule.class).sealTrackingRecord(USER), equalTo(true));
final TrackedContentDTO content = this.client.module(IndyFoloAdminClientModule.class).getRawTrackingContent(USER);
assertThat(content, notNullValue());
final Set<TrackedContentEntryDTO> downloads = content.getDownloads();
assertThat(downloads, notNullValue());
// **/ Disabled behawior because it is affeecting auditing for folo records
// assertThat( downloads.size(), equalTo( 1 ) );
final TrackedContentEntryDTO entry = downloads.iterator().next();
assertThat(entry, notNullValue());
final String downloadPath = entry.getPath();
assertThat(downloadPath, notNullValue());
assertThat(downloadPath, equalTo("/test/" + pom.path));
// TODO: As new api format for "GET /folo/admin/track/record", these tests are deperacated, will keep for a while and remove later
// final String repoName = "httprox_127-0-0-1";
// final TrackedContentRecord record = this.client.module( IndyFoloAdminClientModule.class )
// .getRawTrackingRecord( USER );
// final Map<StoreKey, AffectedStoreRecord> affectedStores = record.getAffectedStores();
// assertThat( affectedStores, notNullValue() );
// assertThat( affectedStores.size(), equalTo( 1 ) );
// final AffectedStoreRecord storeRecord = affectedStores.get( new StoreKey( StoreType.remote, repoName ) );
// assertThat( storeRecord, notNullValue() );
//
// final Set<String> downloads = storeRecord.getDownloadedPaths();
// assertThat( downloads, notNullValue() );
// assertThat( downloads.size(), equalTo( 1 ) );
// assertThat( downloads.iterator()
// .next(), equalTo( "/test/" + pom.path ) );
}
Aggregations