Search in sources :

Example 1 with MavenPath

use of org.sonatype.nexus.repository.maven.MavenPath in project nexus-public by sonatype.

the class DataStoreMavenTestHelper method read.

@Override
public Payload read(final Repository repository, final String path) throws IOException {
    MavenContentFacet mavenFacet = repository.facet(MavenContentFacet.class);
    Optional<MavenMetadataRebuildFacet> metadataRebuildFacet = repository.optionalFacet(MavenMetadataRebuildFacet.class);
    if (metadataRebuildFacet.isPresent()) {
        metadataRebuildFacet.get().maybeRebuildMavenMetadata(prependIfMissing(path, ASSET_PATH_PREFIX), false, true);
    }
    MavenPath mavenPath = mavenFacet.getMavenPathParser().parsePath(path);
    return mavenFacet.get(mavenPath).orElse(null);
}
Also used : MavenMetadataRebuildFacet(org.sonatype.nexus.repository.maven.MavenMetadataRebuildFacet) MavenPath(org.sonatype.nexus.repository.maven.MavenPath) MavenContentFacet(org.sonatype.nexus.content.maven.MavenContentFacet)

Example 2 with MavenPath

use of org.sonatype.nexus.repository.maven.MavenPath in project nexus-public by sonatype.

the class DataStoreMavenTestHelper method getLastDownloadedTime.

@Override
public DateTime getLastDownloadedTime(final Repository repository, final String assetPath) throws IOException {
    MavenContentFacet mavenContentFacet = repository.facet(MavenContentFacet.class);
    MavenPath mavenPath = mavenContentFacet.getMavenPathParser().parsePath(assetPath);
    return mavenContentFacet.get(mavenPath).map(Content::getAttributes).map(attributes -> attributes.get(Asset.class)).map(Asset::lastDownloaded).filter(Optional::isPresent).map(Optional::get).map(DateHelper::toDateTime).orElse(null);
}
Also used : FluentComponent(org.sonatype.nexus.repository.content.fluent.FluentComponent) MD5(org.sonatype.nexus.common.hash.HashAlgorithm.MD5) Date(java.util.Date) StringUtils.prependIfMissing(org.apache.commons.lang3.StringUtils.prependIfMissing) EntityId(org.sonatype.nexus.common.entity.EntityId) FluentAsset(org.sonatype.nexus.repository.content.fluent.FluentAsset) Singleton(javax.inject.Singleton) ArrayList(java.util.ArrayList) DateHelper(org.sonatype.nexus.common.time.DateHelper) ImmutableList(com.google.common.collect.ImmutableList) SHA1(org.sonatype.nexus.common.hash.HashAlgorithm.SHA1) Repository(org.sonatype.nexus.repository.Repository) TempBlob(org.sonatype.nexus.repository.view.payloads.TempBlob) Map(java.util.Map) Payload(org.sonatype.nexus.repository.view.Payload) InternalIds(org.sonatype.nexus.repository.content.store.InternalIds) Matchers.hasSize(org.hamcrest.Matchers.hasSize) ZoneOffset(java.time.ZoneOffset) Named(javax.inject.Named) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Nonnull(javax.annotation.Nonnull) MavenPath(org.sonatype.nexus.repository.maven.MavenPath) Collections.emptyMap(java.util.Collections.emptyMap) Continuations.streamOf(org.sonatype.nexus.common.entity.Continuations.streamOf) ContentFacet(org.sonatype.nexus.repository.content.facet.ContentFacet) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Collection(java.util.Collection) Continuations.iterableOf(org.sonatype.nexus.common.entity.Continuations.iterableOf) DateTime(org.joda.time.DateTime) ContentMaintenanceFacet(org.sonatype.nexus.repository.content.maintenance.ContentMaintenanceFacet) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Asset(org.sonatype.nexus.repository.content.Asset) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) MavenContentFacet(org.sonatype.nexus.content.maven.MavenContentFacet) Content(org.sonatype.nexus.repository.view.Content) MavenPathParser(org.sonatype.nexus.repository.maven.MavenPathParser) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) Stream(java.util.stream.Stream) HashType(org.sonatype.nexus.repository.maven.MavenPath.HashType) AssetBlob(org.sonatype.nexus.repository.content.AssetBlob) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Optional(java.util.Optional) MavenMetadataRebuildFacet(org.sonatype.nexus.repository.maven.MavenMetadataRebuildFacet) Collections(java.util.Collections) InputStream(java.io.InputStream) MavenPath(org.sonatype.nexus.repository.maven.MavenPath) Optional(java.util.Optional) Content(org.sonatype.nexus.repository.view.Content) FluentAsset(org.sonatype.nexus.repository.content.fluent.FluentAsset) Asset(org.sonatype.nexus.repository.content.Asset) MavenContentFacet(org.sonatype.nexus.content.maven.MavenContentFacet)

Example 3 with MavenPath

use of org.sonatype.nexus.repository.maven.MavenPath in project nexus-public by sonatype.

the class OrientMavenTestHelper method write.

@Override
public void write(final Repository repository, final String path, final Payload payload) throws IOException {
    OrientMavenFacet mavenFacet = repository.facet(OrientMavenFacet.class);
    MavenPath mavenPath = mavenFacet.getMavenPathParser().parsePath(path);
    UnitOfWork.begin(repository.facet(StorageFacet.class).txSupplier());
    try {
        mavenFacet.put(mavenPath, payload);
    } finally {
        UnitOfWork.end();
    }
}
Also used : MavenPath(org.sonatype.nexus.repository.maven.MavenPath) OrientMavenFacet(org.sonatype.nexus.orient.maven.OrientMavenFacet)

Example 4 with MavenPath

use of org.sonatype.nexus.repository.maven.MavenPath in project nexus-public by sonatype.

the class OrientMavenTestHelper method read.

@Override
public Payload read(final Repository repository, final String path) throws IOException {
    OrientMavenFacet mavenFacet = repository.facet(OrientMavenFacet.class);
    MavenPath mavenPath = mavenFacet.getMavenPathParser().parsePath(path);
    UnitOfWork.begin(repository.facet(StorageFacet.class).txSupplier());
    try {
        return mavenFacet.get(mavenPath);
    } finally {
        UnitOfWork.end();
    }
}
Also used : MavenPath(org.sonatype.nexus.repository.maven.MavenPath) OrientMavenFacet(org.sonatype.nexus.orient.maven.OrientMavenFacet)

Example 5 with MavenPath

use of org.sonatype.nexus.repository.maven.MavenPath in project nexus-public by sonatype.

the class OrientMavenTestHelper method getLastDownloadedTime.

@Override
public DateTime getLastDownloadedTime(final Repository repository, final String assetPath) {
    MavenFacet mavenFacet = repository.facet(MavenFacet.class);
    MavenPath mavenPath = mavenFacet.getMavenPathParser().parsePath(assetPath);
    try (StorageTx tx = repository.facet(StorageFacet.class).txSupplier().get()) {
        tx.begin();
        Asset asset = tx.findAssetWithProperty(P_NAME, mavenPath.getPath(), tx.findBucket(repository));
        return asset.lastDownloaded();
    }
}
Also used : MavenPath(org.sonatype.nexus.repository.maven.MavenPath) StorageTx(org.sonatype.nexus.repository.storage.StorageTx) Asset(org.sonatype.nexus.repository.storage.Asset) MavenFacet(org.sonatype.nexus.repository.maven.MavenFacet) OrientMavenFacet(org.sonatype.nexus.orient.maven.OrientMavenFacet)

Aggregations

MavenPath (org.sonatype.nexus.repository.maven.MavenPath)81 Test (org.junit.Test)32 OrientMavenFacet (org.sonatype.nexus.orient.maven.OrientMavenFacet)15 MavenContentFacet (org.sonatype.nexus.content.maven.MavenContentFacet)14 Repository (org.sonatype.nexus.repository.Repository)9 ComponentUpload (org.sonatype.nexus.repository.upload.ComponentUpload)9 Content (org.sonatype.nexus.repository.view.Content)9 IOException (java.io.IOException)8 HashType (org.sonatype.nexus.repository.maven.MavenPath.HashType)8 AssetUpload (org.sonatype.nexus.repository.upload.AssetUpload)8 Payload (org.sonatype.nexus.repository.view.Payload)8 TempBlob (org.sonatype.nexus.repository.view.payloads.TempBlob)8 Nonnull (javax.annotation.Nonnull)7 Asset (org.sonatype.nexus.repository.storage.Asset)7 StorageTx (org.sonatype.nexus.repository.storage.StorageTx)7 PartPayload (org.sonatype.nexus.repository.view.PartPayload)7 Map (java.util.Map)5 UploadResponse (org.sonatype.nexus.repository.upload.UploadResponse)5 ArrayList (java.util.ArrayList)4 Coordinates (org.sonatype.nexus.repository.maven.MavenPath.Coordinates)4