Java Code Examples for org.sonatype.nexus.repository.view.Content#findAsset()
The following examples show how to use
org.sonatype.nexus.repository.view.Content#findAsset() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RProxyFacetImpl.java From nexus-repository-r with Eclipse Public License 1.0 | 6 votes |
@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); }
Example 2
Source File: OrientNpmProxyFacet.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@TransactionalTouchMetadata public void setCacheInfo(final Content content, final CacheInfo cacheInfo) throws IOException { 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 npm asset {}", content.getAttributes().require(Asset.class) ); return; } log.debug("Updating cacheInfo of {} to {}", asset, cacheInfo); CacheInfo.applyToAsset(asset, cacheInfo); tx.saveAsset(asset); }
Example 3
Source File: OrientPyPiProxyFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@TransactionalTouchMetadata protected void setCacheInfo(final Content content, final CacheInfo cacheInfo) throws IOException { 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 pypi asset {}", content.getAttributes().require(Asset.class) ); return; } log.debug("Updating cacheInfo of {} to {}", asset, cacheInfo); CacheInfo.applyToAsset(asset, cacheInfo); tx.saveAsset(asset); }
Example 4
Source File: RawContentFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Override @TransactionalTouchMetadata public void setCacheInfo(final String path, final Content content, final CacheInfo cacheInfo) throws IOException { StorageTx tx = UnitOfWork.currentTx(); Bucket bucket = tx.findBucket(getRepository()); // by EntityId Asset asset = Content.findAsset(tx, bucket, content); if (asset == null) { // by format coordinates Component component = tx.findComponentWithProperty(P_NAME, path, bucket); if (component != null) { asset = tx.firstAsset(component); } } if (asset == null) { log.debug("Attempting to set cache info for non-existent raw component {}", path); return; } log.debug("Updating cacheInfo of {} to {}", path, cacheInfo); CacheInfo.applyToAsset(asset, cacheInfo); tx.saveAsset(asset); }
Example 5
Source File: MavenProxyFacet.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Override @TransactionalTouchMetadata protected void indicateVerified(final Context context, final Content content, final CacheInfo cacheInfo) throws IOException { final StorageTx tx = UnitOfWork.currentTx(); final Bucket bucket = tx.findBucket(getRepository()); final MavenPath path = mavenPath(context); // by EntityId Asset asset = Content.findAsset(tx, bucket, content); if (asset == null) { // by format coordinates asset = findAsset(tx, bucket, path); } if (asset == null) { log.debug("Attempting to set cache info for non-existent maven asset {}", path.getPath()); return; } log.debug("Updating cacheInfo of {} to {}", path.getPath(), cacheInfo); CacheInfo.applyToAsset(asset, cacheInfo); tx.saveAsset(asset); }
Example 6
Source File: CocoapodsProxyFacet.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@TransactionalTouchMetadata public void setCacheInfo(final Content content, final CacheInfo cacheInfo) throws IOException { 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 Cocoapods asset {}", content.getAttributes().require(Asset.class) ); return; } log.debug("Updating cacheInfo of {} to {}", asset, cacheInfo); CacheInfo.applyToAsset(asset, cacheInfo); tx.saveAsset(asset); }
Example 7
Source File: ComposerContentFacetImpl.java From nexus-repository-composer with Eclipse Public License 1.0 | 5 votes |
@Override @TransactionalTouchMetadata public void setCacheInfo(final String path, final Content content, final CacheInfo cacheInfo) throws IOException { StorageTx tx = UnitOfWork.currentTx(); Bucket bucket = tx.findBucket(getRepository()); Asset asset = Content.findAsset(tx, bucket, content); if (asset == null) { log.debug("Attempting to set cache info for non-existent Composer asset {}", path); return; } CacheInfo.applyToAsset(asset, cacheInfo); tx.saveAsset(asset); }
Example 8
Source File: P2ProxyFacetImpl.java From nexus-repository-p2 with Eclipse Public License 1.0 | 5 votes |
@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 P2 asset {}", content.getAttributes().require(Asset.class) ); return; } log.debug("Updating cacheInfo of {} to {}", asset, cacheInfo); CacheInfo.applyToAsset(asset, cacheInfo); tx.saveAsset(asset); }
Example 9
Source File: HelmProxyFacetImpl.java From nexus-repository-helm with Eclipse Public License 1.0 | 5 votes |
@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 Helm asset {}", content.getAttributes().require(Asset.class) ); return; } log.debug("Updating cacheInfo of {} to {}", asset, cacheInfo); CacheInfo.applyToAsset(asset, cacheInfo); tx.saveAsset(asset); }
Example 10
Source File: AptProxyFacet.java From nexus-repository-apt with Eclipse Public License 1.0 | 5 votes |
@Transactional(retryOn = { ONeedRetryException.class }) protected void doIndicateVerified(Content content, CacheInfo cacheInfo, String assetPath) { StorageTx tx = UnitOfWork.currentTx(); Bucket bucket = tx.findBucket(getRepository()); Asset asset = Content.findAsset(tx, bucket, content); if (asset == null) { asset = tx.findAssetWithProperty(P_NAME, assetPath, bucket); } if (asset == null) { return; } CacheInfo.applyToAsset(asset, cacheInfo); tx.saveAsset(asset); }
Example 11
Source File: AptHostedFacet.java From nexus-repository-apt with Eclipse Public License 1.0 | 5 votes |
@TransactionalStoreBlob public Asset ingestAsset(ControlFile control, TempBlob body, long size, String contentType) throws IOException, PGPException { AptFacet aptFacet = getRepository().facet(AptFacet.class); StorageTx tx = UnitOfWork.currentTx(); Bucket bucket = tx.findBucket(getRepository()); String name = control.getField("Package").map(f -> f.value).get(); String version = control.getField("Version").map(f -> f.value).get(); String architecture = control.getField("Architecture").map(f -> f.value).get(); String assetPath = FacetHelper.buildAssetPath(name, version, architecture); Content content = aptFacet.put(assetPath, new StreamPayload(() -> body.get(), size, contentType)); Asset asset = Content.findAsset(tx, bucket, content); String indexSection = buildIndexSection(control, asset.size(), asset.getChecksums(FacetHelper.hashAlgorithms), assetPath); asset.formatAttributes().set(P_ARCHITECTURE, architecture); asset.formatAttributes().set(P_PACKAGE_NAME, name); asset.formatAttributes().set(P_PACKAGE_VERSION, version); asset.formatAttributes().set(P_INDEX_SECTION, indexSection); asset.formatAttributes().set(P_ASSET_KIND, "DEB"); tx.saveAsset(asset); List<AssetChange> changes = new ArrayList<>(); changes.add(new AssetChange(AssetAction.ADDED, asset)); for (Asset removed : selectOldPackagesToRemove(name, architecture)) { tx.deleteAsset(removed); changes.add(new AssetChange(AssetAction.REMOVED, removed)); } rebuildIndexesInTransaction(tx, changes.stream().toArray(AssetChange[]::new)); return asset; }
Example 12
Source File: CondaProxyFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@TransactionalTouchMetadata protected 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 Conda asset {}", content.getAttributes().require(Asset.class) ); return; } log.debug("Updating cacheInfo of {} to {}", asset, cacheInfo); CacheInfo.applyToAsset(asset, cacheInfo); tx.saveAsset(asset); }
Example 13
Source File: GolangProxyFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@TransactionalTouchMetadata public void setCacheInfo(final Content content, final CacheInfo cacheInfo) throws IOException { 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 go asset {}", content.getAttributes().require(Asset.class) ); return; } log.debug("Updating cacheInfo of {} to {}", asset, cacheInfo); CacheInfo.applyToAsset(asset, cacheInfo); tx.saveAsset(asset); }
Example 14
Source File: AptProxyFacet.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Transactional(retryOn = {ONeedRetryException.class}) protected void doIndicateVerified(final Content content, final CacheInfo cacheInfo, final String assetPath) { StorageTx tx = UnitOfWork.currentTx(); Bucket bucket = tx.findBucket(getRepository()); Asset asset = Content.findAsset(tx, bucket, content); if (asset == null) { asset = tx.findAssetWithProperty(P_NAME, assetPath, bucket); } if (asset == null) { return; } CacheInfo.applyToAsset(asset, cacheInfo); tx.saveAsset(asset); }
Example 15
Source File: AptHostedFacet.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@TransactionalStoreBlob protected Asset ingestAsset(final ControlFile control, final TempBlob body, final long size, final String contentType) throws IOException { AptFacet aptFacet = getRepository().facet(AptFacet.class); StorageTx tx = UnitOfWork.currentTx(); Bucket bucket = tx.findBucket(getRepository()); PackageInfo info = new PackageInfo(control); String name = info.getPackageName(); String version = info.getVersion(); String architecture = info.getArchitecture(); String assetPath = FacetHelper.buildAssetPath(name, version, architecture); Content content = aptFacet.put( assetPath, new StreamPayload(() -> body.get(), size, contentType), info); Asset asset = Content.findAsset(tx, bucket, content); String indexSection = buildIndexSection(control, asset.size(), asset.getChecksums(FacetHelper.hashAlgorithms), assetPath); asset.formatAttributes().set(P_ARCHITECTURE, architecture); asset.formatAttributes().set(P_PACKAGE_NAME, name); asset.formatAttributes().set(P_PACKAGE_VERSION, version); asset.formatAttributes().set(P_INDEX_SECTION, indexSection); asset.formatAttributes().set(P_ASSET_KIND, "DEB"); tx.saveAsset(asset); rebuildIndexes(singletonList(new AssetChange(AssetAction.ADDED, asset))); return asset; }