use of org.sonatype.nexus.repository.storage.Asset 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.Asset 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.Asset in project nexus-repository-r by sonatype-nexus-community.
the class RBrowseNodeGeneratorTest method shouldComputeAssetAndComponentPathWithoutNameDuplication.
@Test
public void shouldComputeAssetAndComponentPathWithoutNameDuplication() {
final String commonPath = "src/contrib/Archive/ggplot2";
final String lastSegment = "ggplot2_0.9.0.tar.gz";
final String assetPath = commonPath + "/" + lastSegment;
final String componentName = "ggplot2";
final String componentVersion = "0.9.0";
// Browse path should not have name duplicates
final String componentBrowsePath = commonPath + "/" + componentVersion;
final String assetBrowsePath = componentBrowsePath + "/" + lastSegment;
Component component = createComponent(componentName, commonPath, componentVersion);
Asset asset = createAsset(assetPath);
List<BrowsePaths> pathsAsset = generator.computeAssetPaths(asset, component);
List<BrowsePaths> pathsComponent = generator.computeComponentPaths(asset, component);
assertPaths(Arrays.asList(assetBrowsePath.split("/")), pathsAsset);
assertPaths(Arrays.asList(componentBrowsePath.split("/")), pathsComponent, true);
}
use of org.sonatype.nexus.repository.storage.Asset in project nexus-repository-r by sonatype-nexus-community.
the class RFacetImpl method findOrCreateAsset.
@Override
public Asset findOrCreateAsset(final StorageTx tx, final String path) {
Bucket bucket = tx.findBucket(getRepository());
Asset asset = findAsset(tx, bucket, path);
if (asset == null) {
asset = tx.createAsset(bucket, getRepository().getFormat());
asset.name(path);
asset.formatAttributes().set(P_ASSET_KIND, getAssetKind(path).name());
tx.saveAsset(asset);
}
return asset;
}
use of org.sonatype.nexus.repository.storage.Asset in project nexus-repository-r by sonatype-nexus-community.
the class RUploadHandlerTest method mockAsset.
private static Asset mockAsset(final String name) {
Asset asset = mock(Asset.class);
when(asset.componentId()).thenReturn(new DetachedEntityId(NU_ID));
when(asset.name()).thenReturn(name);
return asset;
}
Aggregations