use of org.sonatype.nexus.repository.transaction.TransactionalTouchBlob 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.transaction.TransactionalTouchBlob 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.transaction.TransactionalTouchBlob 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.transaction.TransactionalTouchBlob in project nexus-repository-r by sonatype-nexus-community.
the class RHostedFacetImpl method getArchive.
@Override
@TransactionalTouchBlob
public Content getArchive(final String archivePath) {
checkNotNull(archivePath);
StorageTx tx = UnitOfWork.currentTx();
Asset asset = findAsset(tx, tx.findBucket(getRepository()), archivePath);
if (asset == null) {
return null;
}
if (asset.markAsDownloaded()) {
tx.saveAsset(asset);
}
return toContent(asset, tx.requireBlob(asset.requireBlobRef()));
}
use of org.sonatype.nexus.repository.transaction.TransactionalTouchBlob in project nexus-repository-r by sonatype-nexus-community.
the class RRestoreFacetImpl method restore.
@Override
@TransactionalTouchBlob
public void restore(final AssetBlob assetBlob, final String path) throws IOException {
StorageTx tx = UnitOfWork.currentTx();
RFacet facet = facet(RFacet.class);
Asset asset;
if (componentRequired(path)) {
Map<String, String> attributes;
try (InputStream is = assetBlob.getBlob().getInputStream()) {
attributes = extractDescriptionFromArchive(path, is);
}
Component component = facet.findOrCreateComponent(tx, path, attributes);
asset = facet.findOrCreateAsset(tx, component, path, attributes);
} else {
asset = facet.findOrCreateAsset(tx, path);
}
tx.attachBlob(asset, assetBlob);
Content.applyToAsset(asset, Content.maintainLastModified(asset, new AttributesMap()));
tx.saveAsset(asset);
}
Aggregations