use of org.commonjava.indy.pkg.maven.model.MavenPackageTypeDescriptor.MAVEN_PKG_KEY in project indy by Commonjava.
the class NfcResource method deprecatedGetStore.
@Path("/{type: (hosted|group|remote)}/{name}")
@ApiOperation("[Deprecated] Retrieve all not-found cache entries currently tracked for a given store")
@ApiResponses({ @ApiResponse(code = 200, response = NotFoundCacheDTO.class, message = "The not-found cache for the specified artifact store") })
@GET
@Produces(ApplicationContent.application_json)
public Response deprecatedGetStore(@ApiParam(allowableValues = "hosted,group,remote", name = "type", required = true, value = "The type of store") @PathParam("type") final String t, @ApiParam(name = "name", value = "The name of the store") @PathParam("name") final String name) {
Response response;
final StoreType type = StoreType.get(t);
String altPath = Paths.get("/api/nfc", MAVEN_PKG_KEY, type.singularEndpointName(), name).toString();
final StoreKey key = new StoreKey(type, name);
try {
final NotFoundCacheDTO dto = controller.getMissing(key);
response = formatOkResponseWithJsonEntity(dto, serializer, rb -> markDeprecated(rb, altPath));
} catch (final IndyWorkflowException e) {
response = formatResponse(e, (rb) -> markDeprecated(rb, altPath));
}
return response;
}
use of org.commonjava.indy.pkg.maven.model.MavenPackageTypeDescriptor.MAVEN_PKG_KEY 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.pkg.maven.model.MavenPackageTypeDescriptor.MAVEN_PKG_KEY 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);
}
use of org.commonjava.indy.pkg.maven.model.MavenPackageTypeDescriptor.MAVEN_PKG_KEY in project indy by Commonjava.
the class ContentIndexDirLvWithArtifactsTest method test.
@Test
public void test() throws Exception {
final String remoteName1 = newName();
RemoteRepository remote1 = new RemoteRepository(MAVEN_PKG_KEY, remoteName1, server.formatUrl(remoteName1));
remote1 = client.stores().create(remote1, name.getMethodName(), RemoteRepository.class);
final String remoteName2 = newName();
RemoteRepository remote2 = new RemoteRepository(MAVEN_PKG_KEY, remoteName2, server.formatUrl(remoteName2));
remote2 = client.stores().create(remote2, name.getMethodName(), RemoteRepository.class);
final String groupName = newName();
Group group = new Group(MAVEN_PKG_KEY, groupName, remote1.getKey(), remote2.getKey());
group = client.stores().create(group, name.getMethodName(), Group.class);
server.expect(server.formatUrl(remoteName2, PATH_JAR), 200, PATH_JAR_CONTENT);
server.expect(server.formatUrl(remoteName2, PATH_POM), 200, PATH_POM_CONTENT);
final String CHECKSUM_CONTENT = newName();
for (String checksumPath : PATHS_CHECKSUM) {
server.expect(server.formatUrl(remoteName2, checksumPath), 200, CHECKSUM_CONTENT);
}
try (InputStream s = client.content().get(group.getKey(), PATH_JAR)) {
assertThat(IOUtils.toString(s), equalTo(PATH_JAR_CONTENT));
}
try (InputStream s = client.content().get(group.getKey(), PATH_JAR)) {
assertThat(IOUtils.toString(s), equalTo(PATH_JAR_CONTENT));
}
for (String checksumPath : PATHS_CHECKSUM) {
try (InputStream s = client.content().get(group.getKey(), checksumPath)) {
assertThat(IOUtils.toString(s), equalTo(CHECKSUM_CONTENT));
}
}
AdvancedCache<IndexedStorePath, IndexedStorePath> advancedCache = (AdvancedCache) contentIndex.execute(c -> c);
System.out.println("[Content index DEBUG]: cached isps: " + advancedCache.keySet());
for (IndexedStorePath value : advancedCache.values()) {
boolean match = remote2.getKey().equals(value.getOriginStoreKey()) || remote2.getKey().equals(value.getStoreKey());
assertThat(match, equalTo(true));
}
System.out.println("[Content index DEBUG]: cache size:" + advancedCache.size());
assertTrue(advancedCache.size() <= 2);
System.out.println("[Content index DEBUG]: cache hit:" + advancedCache.getStats().getHits());
assertTrue(advancedCache.getStats().getHits() >= 7);
System.out.println("[Content index DEBUG]: cache misses:" + advancedCache.getStats().getMisses());
}
use of org.commonjava.indy.pkg.maven.model.MavenPackageTypeDescriptor.MAVEN_PKG_KEY in project indy by Commonjava.
the class ContentIndexRemoteRepoUsageTest method bypassNotIndexedContentWithAuthoritativeIndex.
@Test
public void bypassNotIndexedContentWithAuthoritativeIndex() throws Exception {
final String repoName = newName();
RemoteRepository repo = new RemoteRepository(MAVEN_PKG_KEY, repoName, server.formatUrl(repoName));
repo = client.stores().create(repo, name.getMethodName(), RemoteRepository.class);
server.expect(server.formatUrl(repoName, FIRST_PATH), 200, FIRST_PATH_CONTENT);
StoreKey indexedStoreKey = indexManager.getIndexedStoreKey(repo.getKey(), FIRST_PATH);
logger.info("\n\n\nBEFORE: Indexed path entry: " + indexedStoreKey + "\n\n\n\n");
assertThat(indexedStoreKey, nullValue());
Long hits = cacheHandle.executeCache((cache) -> cache.getAdvancedCache().getStats().getHits());
assertThat(hits == 0, equalTo(true));
try (InputStream first = client.content().get(repo.getKey(), FIRST_PATH)) {
assertThat(IOUtils.toString(first), equalTo(FIRST_PATH_CONTENT));
}
indexedStoreKey = indexManager.getIndexedStoreKey(repo.getKey(), FIRST_PATH);
logger.info("\n\n\nAFTER 1: Indexed path entry: " + indexedStoreKey + "\n\n\n\n");
assertThat(indexedStoreKey, notNullValue());
hits = cacheHandle.executeCache((cache) -> cache.getAdvancedCache().getStats().getHits());
assertThat(hits >= 1, equalTo(true));
try (InputStream first = client.content().get(repo.getKey(), FIRST_PATH)) {
assertThat(IOUtils.toString(first), equalTo(FIRST_PATH_CONTENT));
}
StoreKey indexedStoreKey2 = indexManager.getIndexedStoreKey(repo.getKey(), FIRST_PATH);
logger.info("\n\n\nAFTER 2: Indexed path entry: " + indexedStoreKey2 + "\n\n\n\n");
hits = cacheHandle.executeCache((cache) -> cache.getAdvancedCache().getStats().getHits());
assertThat(hits >= 2, equalTo(true));
// object equality should work since we haven't persisted this anywhere yet.
assertThat(indexedStoreKey == indexedStoreKey2, equalTo(true));
}
Aggregations