use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class StoreFileAndVerifyExistenceInGroupTest method storeFileInConstituentAndVerifyExistenceInGroup.
@Test
public void storeFileInConstituentAndVerifyExistenceInGroup() throws Exception {
final Group g = client.stores().load(group, PUBLIC, Group.class);
System.out.printf("\n\nGroup constituents are:\n %s\n\n", StringUtils.join(g.getConstituents(), "\n "));
assertThat(g.getConstituents().contains(new StoreKey(hosted, STORE)), equalTo(true));
final InputStream stream = new ByteArrayInputStream(("This is a test: " + System.nanoTime()).getBytes());
final String path = "/path/to/foo.class";
assertThat(client.content().exists(hosted, STORE, path), equalTo(false));
client.content().store(hosted, STORE, path, stream);
assertThat(client.content().exists(group, PUBLIC, path), equalTo(true));
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class StoreThenGetUnSuffixedDirAndDownloadTest method run.
@Test
public void run() throws Exception {
final String content = "This is a test: " + System.nanoTime();
final InputStream stream = new ByteArrayInputStream(content.getBytes());
final String dirPath = "/org/foo/bar/1";
final String path = dirPath + "/bar-1.pom";
assertThat(client.content().exists(hosted, STORE, path), equalTo(false));
client.content().store(hosted, STORE, path, stream);
assertThat(client.content().exists(hosted, STORE, path), equalTo(true));
try (InputStream htmlIn = client.content().get(new StoreKey(hosted, STORE), dirPath)) {
assertThat(htmlIn, notNullValue());
String html = IOUtils.toString(htmlIn);
assertThat(html.contains("<html>"), equalTo(true));
assertThat(html.contains("bar-1.pom"), equalTo(true));
}
assertThat(client.content().exists(hosted, STORE, path), equalTo(true));
final URL url = new URL(client.content().contentUrl(hosted, STORE, path));
final InputStream is = url.openStream();
final String result = IOUtils.toString(is);
is.close();
assertThat(result, equalTo(content));
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class RemoteRepoTimeoutDisablesStoreAndShowsInDisabledTimeoutsMapTest method assertResult.
@Override
protected void assertResult(RemoteRepository remoteRepo) throws Exception {
assertThat(remoteRepo.isDisabled(), equalTo(true));
Map<StoreKey, Date> storeTimeouts = client.schedules().getDisabledStoreTimeouts();
Date timeout = storeTimeouts.get(new StoreKey(remote, remoteRepo.getName()));
assertThat(timeout, notNullValue());
assertThat(timeout.after(new Date()), equalTo(true));
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class NfcResource method getStore.
@Path("/{packageType}/{type: (hosted|group|remote)}/{name}")
@ApiOperation("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 getStore(@ApiParam(name = "packageType", required = true, value = "The type of package (eg. maven, npm, generic-http)") @PathParam("packageType") final String packageType, @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);
final StoreKey key = new StoreKey(packageType, type, name);
try {
final NotFoundCacheDTO dto = controller.getMissing(key);
response = formatOkResponseWithJsonEntity(dto, serializer);
} catch (final IndyWorkflowException e) {
response = formatResponse(e);
}
return response;
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class NfcResource method deprecatedClearStore.
@Path("/{type: (hosted|group|remote)}/{name}{path: (/.+)?}")
@ApiOperation("[Deprecated] Clear all not-found cache entries for a particular store (or optionally, a subpath within a store)")
@DELETE
@Deprecated
public Response deprecatedClearStore(@ApiParam(allowableValues = "hosted,group,remote", name = "type", required = true, value = "The type of store") @PathParam("type") final String t, @ApiParam(name = "name", required = true, value = "The name of the store") @PathParam("name") final String name, @ApiParam(name = "path", required = false, value = "The sub-path to clear") @PathParam("path") final String p) {
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 {
if (isNotEmpty(p)) {
controller.clear(key);
} else {
controller.clear(key, p);
}
response = markDeprecated(Response.ok(), altPath).build();
} catch (final IndyWorkflowException e) {
response = formatResponse(e, (rb) -> markDeprecated(rb, altPath));
}
return response;
}
Aggregations