use of org.commonjava.indy.folo.model.TrackingKey in project indy by Commonjava.
the class DeprecatedFoloContentAccessResource method doCreate.
@ApiOperation("Store and track file/artifact content under the given artifact store (type/name) and path.")
@ApiResponses({ @ApiResponse(code = 201, message = "Content was stored successfully"), @ApiResponse(code = 400, message = "No appropriate storage location was found in the specified store (this store, or a member if a group is specified).") })
@PUT
@Path("/{path: (.*)}")
public Response doCreate(@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);
EventMetadata metadata = new EventMetadata().set(TRACKING_KEY, tk).set(ACCESS_CHANNEL, AccessChannel.MAVEN_REPO);
final Supplier<URI> uriSupplier = () -> uriInfo.getBaseUriBuilder().path(getClass()).path(path).build(id, type, name);
final Consumer<Response.ResponseBuilder> deprecation = builder -> {
String alt = Paths.get("/api/folo/track/", id, MAVEN_PKG_KEY, type, name, path).toString();
responseHelper.markDeprecated(builder, alt);
};
return handler.doCreate(MAVEN_PKG_KEY, type, name, path, request, metadata, uriSupplier, deprecation);
}
use of org.commonjava.indy.folo.model.TrackingKey in project indy by Commonjava.
the class FoloRecordCacheTest method recordArtifactCreatesNewInProgressEntry.
@Test
public void recordArtifactCreatesNewInProgressEntry() throws Exception {
final TrackingKey key = newKey();
final long size = 123L;
assertThat(cache.hasRecord(key), equalTo(false));
cache.recordArtifact(new TrackedContentEntry(key, new StoreKey(StoreType.remote, "foo"), AccessChannel.MAVEN_REPO, "", "/path", StoreEffect.DOWNLOAD, size, "", "", ""));
assertThat(cache.hasRecord(key), equalTo(true));
assertThat(cache.hasInProgressRecord(key), equalTo(true));
assertThat(cache.hasSealedRecord(key), equalTo(false));
TrackedContent record = cache.seal(key);
assertThat(record, notNullValue());
assertThat(cache.hasRecord(key), equalTo(true));
assertThat(cache.hasInProgressRecord(key), equalTo(false));
assertThat(cache.hasSealedRecord(key), equalTo(true));
Set<TrackedContentEntry> downloads = cache.get(key).getDownloads();
assertThat(downloads, notNullValue());
assertThat(downloads.size(), equalTo(1));
TrackedContentEntry entry = downloads.iterator().next();
assertThat(entry.getSize(), equalTo(size));
}
use of org.commonjava.indy.folo.model.TrackingKey in project indy by Commonjava.
the class FoloRecordCacheTest method hasRecordReturnsFalseIfNoneExists.
@Test
public void hasRecordReturnsFalseIfNoneExists() throws Exception {
final TrackingKey key = newKey();
assertThat(cache.hasRecord(key), equalTo(false));
}
use of org.commonjava.indy.folo.model.TrackingKey in project indy by Commonjava.
the class FoloRecordCacheTest method getRecordReturnsNullIfNoneExists.
@Test
public void getRecordReturnsNullIfNoneExists() throws Exception {
final TrackingKey key = newKey();
assertThat(cache.get(key), nullValue());
}
use of org.commonjava.indy.folo.model.TrackingKey in project indy by Commonjava.
the class FoloRecordCacheTest method sealRemovesInProgressAndCreatesSealedRecord.
@Test
public void sealRemovesInProgressAndCreatesSealedRecord() 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, 124L, "", "", ""));
assertThat(cache.hasRecord(key), equalTo(true));
assertThat(cache.hasInProgressRecord(key), equalTo(true));
assertThat(cache.hasSealedRecord(key), equalTo(false));
TrackedContent record = cache.seal(key);
assertThat(record, notNullValue());
assertThat(cache.hasRecord(key), equalTo(true));
assertThat(cache.hasInProgressRecord(key), equalTo(false));
assertThat(cache.hasSealedRecord(key), equalTo(true));
}
Aggregations