use of org.commonjava.indy.folo.model.TrackingKey in project indy by Commonjava.
the class ProxyResponseHelper method createEventMetadata.
private EventMetadata createEventMetadata(final boolean writeBody, final UserPass proxyUserPass, final String path, final ArtifactStore store) throws IndyWorkflowException {
final EventMetadata eventMetadata = new EventMetadata();
if (writeBody) {
TrackingKey tk = getTrackingKey(proxyUserPass);
if (tk != null) {
logger.debug("TRACKING {} in {} (KEY: {})", path, store, tk);
eventMetadata.set(FoloConstants.TRACKING_KEY, tk);
eventMetadata.set(FoloConstants.ACCESS_CHANNEL, AccessChannel.GENERIC_PROXY);
} else {
logger.debug("NOT TRACKING: {} in {}", path, store);
}
} else {
logger.debug("NOT TRACKING non-body request: {} in {}", path, store);
}
eventMetadata.setPackageType(PKG_TYPE_GENERIC_HTTP);
return eventMetadata;
}
use of org.commonjava.indy.folo.model.TrackingKey in project indy by Commonjava.
the class FoloMavenContentAccessResource method doGet.
@ApiOperation("Retrieve and track file/artifact content under the given artifact store (type/name) and path.")
@ApiResponses({ @ApiResponse(code = 404, message = "Content is not available"), @ApiResponse(code = 200, response = String.class, message = "Rendered content listing (when path ends with '/index.html' or '/')"), @ApiResponse(code = 200, response = StreamingOutput.class, message = "Content stream") })
@GET
@Path("/{path: (.*)}")
public Response doGet(@ApiParam("User-assigned tracking session key") @PathParam("id") final String id, @ApiParam(allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String type, @PathParam("name") final String name, @PathParam("path") final String path, @Context final HttpServletRequest request, @Context final UriInfo uriInfo) {
final TrackingKey tk = new TrackingKey(id);
final String baseUri = uriInfo.getBaseUriBuilder().path(BASE_PATH).path(id).build().toString();
EventMetadata metadata = new EventMetadata().set(TRACKING_KEY, tk).set(ACCESS_CHANNEL, AccessChannel.NATIVE);
RequestContextHelper.setContext(CONTENT_TRACKING_ID, id);
return handler.doGet(PKG_TYPE_MAVEN, type, name, path, baseUri, request, metadata);
}
use of org.commonjava.indy.folo.model.TrackingKey in project indy by Commonjava.
the class FoloMavenContentAccessResource method doHead.
@ApiOperation("Store and track file/artifact content under the given artifact store (type/name) and path.")
@ApiResponses({ @ApiResponse(code = 404, message = "Content is not available"), @ApiResponse(code = 200, message = "Header metadata for content (or rendered listing when path ends with '/index.html' or '/'") })
@HEAD
@Path("/{path: (.*)}")
public Response doHead(@ApiParam("User-assigned tracking session key") @PathParam("id") final String id, @ApiParam(allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String type, @PathParam("name") final String name, @PathParam("path") final String path, @QueryParam(CHECK_CACHE_ONLY) final Boolean cacheOnly, @Context final HttpServletRequest request, @Context final UriInfo uriInfo) {
final TrackingKey tk = new TrackingKey(id);
final String baseUri = uriInfo.getBaseUriBuilder().path(BASE_PATH).path(id).build().toString();
EventMetadata metadata = new EventMetadata().set(TRACKING_KEY, tk).set(ACCESS_CHANNEL, AccessChannel.NATIVE);
RequestContextHelper.setContext(CONTENT_TRACKING_ID, id);
return handler.doHead(PKG_TYPE_MAVEN, type, name, path, cacheOnly, baseUri, request, metadata);
}
use of org.commonjava.indy.folo.model.TrackingKey in project indy by Commonjava.
the class FoloRecordCacheTest method clearRecordDeletesRecord.
@Test
public void clearRecordDeletesRecord() throws Exception {
final TrackingKey key = newKey();
assertThat(cache.hasRecord(key), equalTo(false));
cache.recordArtifact(new TrackedContentEntry(key, new StoreKey(StoreType.remote, "foo"), AccessChannel.MAVEN_REPO, "", "/path", StoreEffect.DOWNLOAD, 127L, "", "", ""));
TrackedContent record = cache.seal(key);
assertThat(record, notNullValue());
assertThat(cache.hasRecord(key), equalTo(true));
cache.delete(key);
assertThat(cache.hasRecord(key), equalTo(false));
assertThat(cache.get(key), nullValue());
}
use of org.commonjava.indy.folo.model.TrackingKey in project indy by Commonjava.
the class TrackingKey2StringMapperTest method testMapper.
@Test
public void testMapper() throws IOException {
TrackingKey2StringMapper mapper = new TrackingKey2StringMapper();
TrackingKey key = new TrackingKey(TEST_ID);
Assert.assertTrue(mapper.isSupportedType(TrackingKey.class));
Assert.assertFalse(mapper.isSupportedType(Object.class));
Assert.assertFalse(mapper.isSupportedType(TrackedContent.class));
Assert.assertTrue(mapper.isSupportedType(WrappedByteArray.class));
Object genKey = mapper.getKeyMapping(TEST_ID);
Assert.assertEquals(key, genKey);
String genId = mapper.getStringMapping(key);
Assert.assertEquals(TEST_ID, genId);
WrappedByteArray array = bytesOfTrackingKey(key);
genId = mapper.getStringMapping(array);
Assert.assertEquals(TEST_ID, genId);
}
Aggregations