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);
}
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);
}
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();
}
}
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();
}
}
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();
}
}
Aggregations