@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); }
@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); }
@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 Helm asset {}", content.getAttributes().require(Asset.class) ); return; } log.debug("Updating cacheInfo of {} to {}", asset, cacheInfo); CacheInfo.applyToAsset(asset, cacheInfo); tx.saveAsset(asset); }
@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); }
@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); }
@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); }
@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; }