use of org.sonatype.nexus.repository.storage.StorageTx in project nexus-repository-r by sonatype-nexus-community.
the class RHostedFacetImpl method getStoredContent.
@Override
@TransactionalTouchBlob
public Content getStoredContent(final String contentPath) {
checkNotNull(contentPath);
StorageTx tx = UnitOfWork.currentTx();
Asset asset = findAsset(tx, tx.findBucket(getRepository()), contentPath);
if (asset == null) {
return null;
}
if (asset.markAsDownloaded()) {
tx.saveAsset(asset);
}
return toContent(asset, tx.requireBlob(asset.requireBlobRef()));
}
use of org.sonatype.nexus.repository.storage.StorageTx in project nexus-repository-r by sonatype-nexus-community.
the class RHostedFacetImpl method buildAndPutPackagesGz.
@Override
@TransactionalTouchMetadata
public Content buildAndPutPackagesGz(final String basePath) throws IOException {
checkNotNull(basePath);
StorageTx tx = UnitOfWork.currentTx();
RPackagesBuilder packagesBuilder = new RPackagesBuilder();
Iterable<Asset> archiveAssets = browseAllAssetsByKind(tx, tx.findBucket(getRepository()), ARCHIVE);
// packageInfoBuilder doesn't support multithreading
StreamSupport.stream(archiveAssets.spliterator(), false).filter(asset -> basePath.equals(getBasePath(asset.name()))).forEach(packagesBuilder::append);
byte[] packagesBytes = packagesBuilder.buildPackagesGz();
StorageFacet storageFacet = getRepository().facet(StorageFacet.class);
try (InputStream is = new ByteArrayInputStream(packagesBytes)) {
TempBlob tempPackagesGz = storageFacet.createTempBlob(is, RFacetUtils.HASH_ALGORITHMS);
return doPutPackagesGz(tx, basePath, tempPackagesGz);
}
}
use of org.sonatype.nexus.repository.storage.StorageTx in project nexus-repository-r by sonatype-nexus-community.
the class RProxyFacetImpl method getAsset.
@TransactionalTouchBlob
protected Content getAsset(final String name) {
StorageTx tx = UnitOfWork.currentTx();
Asset asset = findAsset(tx, tx.findBucket(getRepository()), name);
if (asset == null) {
return null;
}
if (asset.markAsDownloaded()) {
tx.saveAsset(asset);
}
return toContent(asset, tx.requireBlob(asset.requireBlobRef()));
}
use of org.sonatype.nexus.repository.storage.StorageTx in project nexus-repository-r by sonatype-nexus-community.
the class RProxyFacetImpl method setCacheInfo.
@TransactionalTouchMetadata
public void setCacheInfo(final Content content, final CacheInfo cacheInfo) {
StorageTx tx = UnitOfWork.currentTx();
Asset asset = Content.findAsset(tx, tx.findBucket(getRepository()), content);
if (asset == null) {
log.debug("Attempting to set cache info for non-existent R asset {}", content.getAttributes().require(Asset.class));
return;
}
log.debug("Updating cacheInfo of {} to {}", asset, cacheInfo);
CacheInfo.applyToAsset(asset, cacheInfo);
tx.saveAsset(asset);
}
use of org.sonatype.nexus.repository.storage.StorageTx in project nexus-repository-r by sonatype-nexus-community.
the class RProxyFacetImpl method getAsset.
@TransactionalTouchBlob
protected Content getAsset(final String name) {
StorageTx tx = UnitOfWork.currentTx();
Asset asset = findAsset(tx, tx.findBucket(getRepository()), name);
if (asset == null) {
return null;
}
if (asset.markAsDownloaded()) {
tx.saveAsset(asset);
}
return toContent(asset, tx.requireBlob(asset.requireBlobRef()));
}
Aggregations