use of org.commonjava.maven.galley.event.EventMetadata in project indy by Commonjava.
the class MavenContentFilteringTransferDecoratorTest method snapshotListingNotInWhenSnapshotsNotAllowedWithNoVersionPath.
@Test
public void snapshotListingNotInWhenSnapshotsNotAllowedWithNoVersionPath() throws Exception {
final String fname = "commons-codec/commons-codec/";
final SimpleHttpLocation location = new SimpleHttpLocation("test", "http://test", false, true, false, false, null);
final ConcreteResource resource = new ConcreteResource(location, fname);
final Transfer transfer = new Transfer(resource, null, null, null);
String[] listing = Arrays.asList("1.0/", "1.0-SNAPSHOT/", "1.1/", "1.1-SNAPSHOT/").toArray(new String[4]);
MavenContentsFilteringTransferDecorator decorator = new MavenContentsFilteringTransferDecorator();
listing = decorator.decorateListing(transfer, listing, new EventMetadata());
System.out.println(Arrays.asList(listing));
assertThat(listing, CoreMatchers.notNullValue());
assertThat(listing.length, equalTo(2));
assertThat(Arrays.asList(listing).contains("1.0-SNAPSHOT/"), equalTo(false));
assertThat(Arrays.asList(listing).contains("1.1-SNAPSHOT/"), equalTo(false));
}
use of org.commonjava.maven.galley.event.EventMetadata in project indy by Commonjava.
the class MavenContentFilteringTransferDecoratorTest method getTestHttpTransfer.
private Transfer getTestHttpTransfer(final String path, final String content) throws Exception {
fixture.expect("GET", fixture.formatUrl(path), 200, content);
final String baseUri = fixture.getBaseUri();
final SimpleHttpLocation location = new SimpleHttpLocation("test", baseUri, false, true, true, true, null);
final Transfer transfer = fixture.getTransfer(new ConcreteResource(location, path));
final String url = fixture.formatUrl(path);
assertThat(transfer.exists(), equalTo(false));
HttpDownload dl = new HttpDownload(url, location, transfer, new HashMap<>(), new EventMetadata(), fixture.getHttp().getHttp(), new ObjectMapper(), true, metricRegistry, metricConfig);
return dl.call().getTransfer();
}
use of org.commonjava.maven.galley.event.EventMetadata in project indy by Commonjava.
the class MavenContentFilteringTransferDecoratorTest method snapshotListingNotInWhenSnapshotsNotAllowedWithVersionPath.
@Test
public void snapshotListingNotInWhenSnapshotsNotAllowedWithVersionPath() throws Exception {
final String fname = "commons-codec/commons-codec/1.1-SNAPSHOT/";
final SimpleHttpLocation location = new SimpleHttpLocation("test", "http://test", false, true, false, false, null);
final ConcreteResource resource = new ConcreteResource(location, fname);
final Transfer transfer = new Transfer(resource, null, null, null);
String[] listing = Arrays.asList("commons-codec-1.1-SNAPSHOT.jar", "commons-codec-1.1-SNAPSHOT-source.jar", "maven-metadata.xml").toArray(new String[4]);
MavenContentsFilteringTransferDecorator decorator = new MavenContentsFilteringTransferDecorator();
listing = decorator.decorateListing(transfer, listing, new EventMetadata());
assertThat(listing, CoreMatchers.notNullValue());
assertThat(listing.length, equalTo(0));
}
use of org.commonjava.maven.galley.event.EventMetadata in project indy by Commonjava.
the class NPMPackageMaskingTransferDecoratorTest method testDecorator2.
@Test
public void testDecorator2() throws Exception {
String path = "package.json";
KeyedLocation location = new GroupLocation(PKG_TYPE_NPM, "test");
File file = new File(temp.newFolder(location.getName()), path);
IOUtils.copy(getResourceAsStream("metadata/package-tar-fs.json"), new FileOutputStream(file));
ConcreteResource resource = new ConcreteResource(location, path);
TestCacheProvider provider = new TestCacheProvider(temp.getRoot(), new TestFileEventManager(), new TransferDecoratorManager(new NPMPackageMaskingTransferDecorator()));
Transfer transfer = provider.getTransfer(resource);
InputStream stream = transfer.openInputStream(false, new EventMetadata().set(ENTRY_POINT_BASE_URI, "http://localhost/api/content/npm"));
String ret = IOUtils.toString(stream);
String expected = IOUtils.toString(getResourceAsStream("metadata/package-tar-fs-decorated.json"));
assertEquals(expected, ret);
}
use of org.commonjava.maven.galley.event.EventMetadata in project indy by Commonjava.
the class NPMContentAccessResource method doGet.
@Override
@ApiOperation("Retrieve root listing under the given artifact store (type/name).")
@ApiResponses({ @ApiResponse(code = 200, response = String.class, message = "Rendered root content listing"), @ApiResponse(code = 200, response = StreamingOutput.class, message = "Content stream") })
@GET
@Path("/")
public Response doGet(@ApiParam(allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String type, @ApiParam(required = true) @PathParam("name") final String name, @Context final UriInfo uriInfo, @Context final HttpServletRequest request) {
EventMetadata eventMetadata = new EventMetadata();
eventMetadata.set(STORAGE_PATH, "");
final String baseUri = uriInfo.getBaseUriBuilder().path(NPM_CONTENT_REST_BASE_PATH).build().toString();
return handler.doGet(NPM_PKG_KEY, type, name, "", baseUri, request, eventMetadata);
}
Aggregations