Search in sources :

Example 1 with DateHelper

use of org.sonatype.nexus.common.time.DateHelper 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)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)1 ZoneOffset (java.time.ZoneOffset)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Collections.emptyMap (java.util.Collections.emptyMap)1 Date (java.util.Date)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 Nonnull (javax.annotation.Nonnull)1 Named (javax.inject.Named)1 Singleton (javax.inject.Singleton)1 IOUtils (org.apache.commons.io.IOUtils)1