Search in sources :

Example 1 with KeyLastPart

use of com.artipie.asto.ext.KeyLastPart in project maven-adapter by artipie.

the class AstoMavenTest method addsMetadataChecksums.

@Test
void addsMetadataChecksums() {
    final String version = "0.1";
    new TestResource("maven-metadata.xml.example").saveTo(this.storage, new Key.From(AstoMavenTest.LGR_UPLOAD, version, PutMetadataSlice.SUB_META, "maven-metadata.xml"));
    new AstoMaven(this.storage).update(new Key.From(AstoMavenTest.LGR_UPLOAD, version), AstoMavenTest.LGR).toCompletableFuture().join();
    MatcherAssert.assertThat(this.storage.list(AstoMavenTest.LGR).join().stream().map(key -> new KeyLastPart(key).get()).filter(key -> key.contains("maven-metadata.xml")).toArray(String[]::new), Matchers.arrayContainingInAnyOrder("maven-metadata.xml", "maven-metadata.xml.sha1", "maven-metadata.xml.sha256", "maven-metadata.xml.sha512", "maven-metadata.xml.md5"));
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) MetadataXml(com.artipie.maven.MetadataXml) XhtmlMatchers(com.jcabi.matchers.XhtmlMatchers) AllOf(org.hamcrest.core.AllOf) Storage(com.artipie.asto.Storage) FileStorage(com.artipie.asto.fs.FileStorage) ListOf(org.cactoos.list.ListOf) IsEqual(org.hamcrest.core.IsEqual) TestResource(com.artipie.asto.test.TestResource) XMLDocument(com.jcabi.xml.XMLDocument) InMemoryStorage(com.artipie.asto.memory.InMemoryStorage) Predicate(java.util.function.Predicate) KeyLastPart(com.artipie.asto.ext.KeyLastPart) Matchers(org.hamcrest.Matchers) PutMetadataSlice(com.artipie.maven.http.PutMetadataSlice) Content(com.artipie.asto.Content) Key(com.artipie.asto.Key) BlockingStorage(com.artipie.asto.blocking.BlockingStorage) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) Test(org.junit.jupiter.api.Test) PublisherAs(com.artipie.asto.ext.PublisherAs) Stream(java.util.stream.Stream) MatcherAssert(org.hamcrest.MatcherAssert) Matcher(org.hamcrest.Matcher) Optional(java.util.Optional) XML(com.jcabi.xml.XML) KeyLastPart(com.artipie.asto.ext.KeyLastPart) TestResource(com.artipie.asto.test.TestResource) Key(com.artipie.asto.Key) Test(org.junit.jupiter.api.Test)

Example 2 with KeyLastPart

use of com.artipie.asto.ext.KeyLastPart in project maven-adapter by artipie.

the class LocalMavenSlice method response.

@Override
public Response response(final String line, final Iterable<Entry<String, String>> headers, final Publisher<ByteBuffer> body) {
    final RequestLineFrom rline = new RequestLineFrom(line);
    final Key key = new KeyFromPath(rline.uri().getPath());
    final Matcher match = LocalMavenSlice.PTN_ARTIFACT.matcher(new KeyLastPart(key).get());
    final Response response;
    if (match.matches()) {
        response = this.artifactResponse(rline.method(), key);
    } else {
        response = this.plainResponse(rline.method(), key);
    }
    return response;
}
Also used : Response(com.artipie.http.Response) AsyncResponse(com.artipie.http.async.AsyncResponse) KeyFromPath(com.artipie.http.slice.KeyFromPath) Matcher(java.util.regex.Matcher) KeyLastPart(com.artipie.asto.ext.KeyLastPart) RequestLineFrom(com.artipie.http.rq.RequestLineFrom) Key(com.artipie.asto.Key)

Aggregations

Key (com.artipie.asto.Key)2 KeyLastPart (com.artipie.asto.ext.KeyLastPart)2 Content (com.artipie.asto.Content)1 Storage (com.artipie.asto.Storage)1 BlockingStorage (com.artipie.asto.blocking.BlockingStorage)1 PublisherAs (com.artipie.asto.ext.PublisherAs)1 FileStorage (com.artipie.asto.fs.FileStorage)1 InMemoryStorage (com.artipie.asto.memory.InMemoryStorage)1 TestResource (com.artipie.asto.test.TestResource)1 Response (com.artipie.http.Response)1 AsyncResponse (com.artipie.http.async.AsyncResponse)1 RequestLineFrom (com.artipie.http.rq.RequestLineFrom)1 KeyFromPath (com.artipie.http.slice.KeyFromPath)1 MetadataXml (com.artipie.maven.MetadataXml)1 PutMetadataSlice (com.artipie.maven.http.PutMetadataSlice)1 XhtmlMatchers (com.jcabi.matchers.XhtmlMatchers)1 XML (com.jcabi.xml.XML)1 XMLDocument (com.jcabi.xml.XMLDocument)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Optional (java.util.Optional)1