use of org.commonjava.indy.folo.model.TrackingKey in project indy by Commonjava.
the class FoloTrackingAdjustListener method handlePathsPromoteComplete.
private void handlePathsPromoteComplete(PathsPromoteResult promoteResult) {
String error = promoteResult.getError();
if (error != null) {
logger.trace("Error in promoteResult, skip adjust");
return;
}
Set<String> paths = promoteResult.getCompletedPaths();
if (paths.isEmpty()) {
logger.trace("No completedPaths, skip adjust");
return;
}
PathsPromoteRequest req = promoteResult.getRequest();
StoreKey source = req.getSource();
StoreKey target = req.getTarget();
TrackingKey trackingKey = getTrackingKey(source);
if (trackingKey == null) {
logger.trace("No tracking key found to: {}", source);
return;
}
// Get the sealed record, client MUST seal the record before promote
TrackedContent trackedContent = recordManager.get(trackingKey);
if (trackedContent == null) {
logger.trace("No sealed record found, trackingKey: {}", trackingKey);
return;
}
adjustTrackedContent(trackedContent, source, target);
recordManager.replaceTrackingRecord(trackedContent);
}
use of org.commonjava.indy.folo.model.TrackingKey in project indy by Commonjava.
the class TrackedContentDTOTest method jsonRoundTrip_DownloadsNoUploads.
@Test
public void jsonRoundTrip_DownloadsNoUploads() throws IOException {
Set<TrackedContentEntryDTO> downloads = setOf(new TrackedContentEntryDTO(new StoreKey(StoreType.remote, "foo"), AccessChannel.MAVEN_REPO, "/path/to/my.pom"), new TrackedContentEntryDTO(new StoreKey(StoreType.remote, "foo2"), AccessChannel.MAVEN_REPO, "/path/to/another/file.pom"));
TrackedContentDTO in = new TrackedContentDTO(new TrackingKey("key"), Collections.emptySet(), downloads);
assertRoundTrip(in, (out) -> {
assertNullOrEmpty(out.getUploads());
assertContents(out.getDownloads(), in.getDownloads());
});
}
use of org.commonjava.indy.folo.model.TrackingKey in project indy by Commonjava.
the class TrackedContentDTOTest method jsonRoundTrip_Empty.
@Test
public void jsonRoundTrip_Empty() throws IOException {
TrackedContentDTO in = new TrackedContentDTO(new TrackingKey("foo"), Collections.emptySet(), Collections.emptySet());
assertRoundTrip(in, (out) -> {
});
}
use of org.commonjava.indy.folo.model.TrackingKey in project indy by Commonjava.
the class DeprecatedFoloContentAccessResource 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.MAVEN_REPO);
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.doHead(MAVEN_PKG_KEY, type, name, path, cacheOnly, baseUri, request, metadata, deprecation);
}
use of org.commonjava.indy.folo.model.TrackingKey in project indy by Commonjava.
the class DeprecatedFoloContentAccessResource 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.MAVEN_REPO);
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.doGet(MAVEN_PKG_KEY, type, name, path, baseUri, request, metadata, deprecation);
}
Aggregations