Search in sources :

Example 66 with EventMetadata

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));
}
Also used : SimpleHttpLocation(org.commonjava.maven.galley.transport.htcli.model.SimpleHttpLocation) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) Transfer(org.commonjava.maven.galley.model.Transfer) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Test(org.junit.Test)

Example 67 with EventMetadata

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();
}
Also used : SimpleHttpLocation(org.commonjava.maven.galley.transport.htcli.model.SimpleHttpLocation) HttpDownload(org.commonjava.maven.galley.transport.htcli.internal.HttpDownload) Transfer(org.commonjava.maven.galley.model.Transfer) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) EventMetadata(org.commonjava.maven.galley.event.EventMetadata)

Example 68 with EventMetadata

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));
}
Also used : SimpleHttpLocation(org.commonjava.maven.galley.transport.htcli.model.SimpleHttpLocation) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) Transfer(org.commonjava.maven.galley.model.Transfer) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Test(org.junit.Test)

Example 69 with EventMetadata

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);
}
Also used : KeyedLocation(org.commonjava.indy.model.galley.KeyedLocation) InputStream(java.io.InputStream) TestFileEventManager(org.commonjava.indy.test.fixture.core.TestFileEventManager) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) GroupLocation(org.commonjava.indy.model.galley.GroupLocation) FileOutputStream(java.io.FileOutputStream) TransferDecoratorManager(org.commonjava.maven.galley.io.TransferDecoratorManager) ConcreteResource(org.commonjava.maven.galley.model.ConcreteResource) TestCacheProvider(org.commonjava.indy.test.fixture.core.TestCacheProvider) Transfer(org.commonjava.maven.galley.model.Transfer) File(java.io.File) Test(org.junit.Test)

Example 70 with EventMetadata

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);
}
Also used : EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

EventMetadata (org.commonjava.maven.galley.event.EventMetadata)154 Transfer (org.commonjava.maven.galley.model.Transfer)65 ChangeSummary (org.commonjava.indy.audit.ChangeSummary)49 Test (org.junit.Test)47 IndyDataException (org.commonjava.indy.data.IndyDataException)44 StoreKey (org.commonjava.indy.model.core.StoreKey)40 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)38 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)37 RemoteRepository (org.commonjava.indy.model.core.RemoteRepository)35 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)28 Group (org.commonjava.indy.model.core.Group)26 ApiOperation (io.swagger.annotations.ApiOperation)23 Path (javax.ws.rs.Path)23 Logger (org.slf4j.Logger)23 ApiResponses (io.swagger.annotations.ApiResponses)22 IOException (java.io.IOException)21 InputStream (java.io.InputStream)20 HostedRepository (org.commonjava.indy.model.core.HostedRepository)20 KeyedLocation (org.commonjava.indy.model.galley.KeyedLocation)20 ArrayList (java.util.ArrayList)18