org.sonatype.nexus.repository.transaction.TransactionalTouchBlob Java Examples
The following examples show how to use
org.sonatype.nexus.repository.transaction.TransactionalTouchBlob.
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: ConanProxyFacet.java From nexus-repository-conan with Eclipse Public License 1.0 | 6 votes |
@TransactionalTouchBlob @Nullable protected String getUrlForConanManifest(final ConanCoords coords) { String downloadUrlsAssetPath = OrientConanProxyHelper.getProxyAssetPath(coords, DOWNLOAD_URL); StorageTx tx = UnitOfWork.currentTx(); Asset downloadUrlAsset = findAsset(tx, tx.findBucket(getRepository()), downloadUrlsAssetPath); if (downloadUrlAsset == null) { // NEXUS-22735. Looks like it was search request. So let's look up conanmanifest url from digest String digestAssetPath = OrientConanProxyHelper.getProxyAssetPath(coords, DIGEST); Asset digest = findAsset(tx, tx.findBucket(getRepository()), digestAssetPath); if (digest == null) { throw new IllegalStateException("DIGEST not found"); } return conanUrlIndexer.findUrl(tx.requireBlob(digest.blobRef()).getInputStream(), CONAN_MANIFEST.getFilename()); } return conanUrlIndexer.findUrl(tx.requireBlob(downloadUrlAsset.blobRef()).getInputStream(), CONAN_MANIFEST.getFilename()); }
Example #2
Source File: OrientNpmHostedFacet.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@TransactionalTouchBlob protected void upgradeRevisionOnPackageRoot(final Asset packageRootAsset, final String revision) { StorageTx tx = UnitOfWork.currentTx(); NpmPackageId packageId = NpmPackageId.parse(packageRootAsset.name()); Asset asset = findPackageRootAsset(tx, tx.findBucket(getRepository()), packageId); if (asset == null) { log.error("Failed to update revision on package root. Asset for id '{}' didn't exist", packageId.id()); return; } // if there is a transaction failure and we fail to upgrade the package root with _rev // then the user who fetched the package root will not be able to run a delete command try { NestedAttributesMap packageRoot = NpmFacetUtils.loadPackageRoot(tx, asset); packageRoot.set(META_REV, revision); savePackageRoot(UnitOfWork.currentTx(), packageRootAsset, packageRoot); } catch (IOException e) { log.warn("Failed to update revision in package root. Revision '{}' was not set" + " and might cause delete for that revision to fail for Asset {}", revision, packageRootAsset, e); } }
Example #3
Source File: OrientNpmHostedFacet.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Nullable @Override @TransactionalTouchBlob public Content getPackage(final NpmPackageId packageId) throws IOException { checkNotNull(packageId); log.debug("Getting package: {}", packageId); StorageTx tx = UnitOfWork.currentTx(); Asset packageRootAsset = findPackageRootAsset(tx, tx.findBucket(getRepository()), packageId); if (packageRootAsset == null) { return null; } return toContent(getRepository(), packageRootAsset) .fieldMatchers(asList( missingRevFieldMatcher(() -> generateNewRevId(packageRootAsset)), rewriteTarballUrlMatcher(getRepository().getName(), packageId.id()))) .packageId(packageRootAsset.name()); }
Example #4
Source File: OrientNpmProxyFacet.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@TransactionalTouchBlob protected NestedAttributesMap retrievePackageVersionTx(final NpmPackageId packageId, final String tarballName) throws IOException { StorageTx tx = UnitOfWork.currentTx(); // get the asset as we need the original tarball url Asset asset = findPackageRootAsset(packageId); if (asset == null) { throw new NonResolvableTarballNameException("Could not find package " + packageId); } NestedAttributesMap packageRoot = NpmFacetUtils.loadPackageRoot(tx, asset); NestedAttributesMap packageVersion = NpmMetadataUtils.selectVersionByTarballName(packageRoot, tarballName); if (packageVersion == null) { throw new NonResolvableTarballNameException("Could not find package " + packageId + " version for " + tarballName); } return packageVersion; }
Example #5
Source File: OrientNpmHostedFacet.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Nullable @Override @TransactionalTouchBlob public Content getDistTags(final NpmPackageId packageId) { checkNotNull(packageId); log.debug("Getting package: {}", packageId); StorageTx tx = UnitOfWork.currentTx(); Asset packageRootAsset = findPackageRootAsset(tx, tx.findBucket(getRepository()), packageId); if (packageRootAsset == null) { return null; } try { final NestedAttributesMap packageRoot = NpmFacetUtils.loadPackageRoot(tx, packageRootAsset); final NestedAttributesMap distTags = packageRoot.child(DIST_TAGS); return NpmFacetUtils.distTagsToContent(distTags); } catch (IOException e) { log.info("Unable to obtain dist-tags for {}", packageId.id(), e); } return null; }
Example #6
Source File: ConanHostedMetadataFacetSupport.java From nexus-repository-conan with Eclipse Public License 1.0 | 6 votes |
@Nullable @TransactionalTouchBlob public String getHash(final String path) { checkNotNull(path); StorageTx tx = UnitOfWork.currentTx(); Asset asset = findAsset(tx, tx.findBucket(getRepository()), path); if (asset == null) { return null; } HashCode checksum = asset.getChecksum(HashAlgorithm.MD5); if (checksum == null) { return null; } return checksum.toString(); }
Example #7
Source File: ConanHostedFacet.java From nexus-repository-conan with Eclipse Public License 1.0 | 6 votes |
@Nullable @TransactionalTouchBlob protected Content doGet(final String path) { checkNotNull(path); StorageTx tx = UnitOfWork.currentTx(); Asset asset = findAsset(tx, tx.findBucket(getRepository()), path); if (asset == null) { return null; } if (asset.markAsDownloaded()) { tx.saveAsset(asset); } return toContent(asset, tx.requireBlob(asset.requireBlobRef())); }
Example #8
Source File: RRestoreFacetImpl.java From nexus-repository-r with Eclipse Public License 1.0 | 6 votes |
@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); }
Example #9
Source File: ComposerContentFacetImpl.java From nexus-repository-composer with Eclipse Public License 1.0 | 6 votes |
@Nullable @Override @TransactionalTouchBlob public Content get(final String path) throws IOException { StorageTx tx = UnitOfWork.currentTx(); final Asset asset = findAsset(tx, path); if (asset == null) { return null; } if (asset.markAsDownloaded()) { tx.saveAsset(asset); } final Blob blob = tx.requireBlob(asset.requireBlobRef()); return toContent(asset, blob); }
Example #10
Source File: NpmRestoreBlobStrategy.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@TransactionalTouchBlob @Override protected boolean assetExists(@Nonnull final NpmRestoreBlobData data) { NpmFacet facet = data.getBlobData().getRepository().facet(NpmFacet.class); Asset asset; switch (data.getType()) { case REPOSITORY_ROOT: asset = facet.findRepositoryRootAsset(); break; case TARBALL: asset = facet.findTarballAsset(data.getPackageId(), data.getTarballName()); break; case PACKAGE_ROOT: asset = facet.findPackageRootAsset(data.getPackageId()); break; default: // all the cases are covered throw new IllegalStateException("Unexpected case encountered"); } return asset != null; }
Example #11
Source File: HelmHostedFacetImpl.java From nexus-repository-helm with Eclipse Public License 1.0 | 6 votes |
@Nullable @Override @TransactionalTouchBlob public Content get(final String path) { checkNotNull(path); StorageTx tx = UnitOfWork.currentTx(); Optional<Asset> assetOpt = helmFacet.findAsset(tx, path); if (!assetOpt.isPresent()) { return null; } Asset asset = assetOpt.get(); if (asset.markAsDownloaded()) { tx.saveAsset(asset); } return helmFacet.toContent(asset, tx.requireBlob(asset.requireBlobRef())); }
Example #12
Source File: GolangHostedFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@TransactionalTouchBlob protected Payload getZip(final String path) { StorageTx tx = UnitOfWork.currentTx(); Asset asset = golangDataAccess.findAsset(tx, tx.findBucket(getRepository()), path); if (asset == null) { log.warn("Unable to find {} for extraction", path); return null; } return golangDataAccess.getBlobAsPayload(tx, asset); }
Example #13
Source File: CocoapodsFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Override @Nullable @TransactionalTouchBlob public Content get(final String path) { final StorageTx tx = UnitOfWork.currentTx(); final Asset asset = tx.findAssetWithProperty(P_NAME, path, tx.findBucket(getRepository())); if (asset == null) { return null; } Content content = new Content(new BlobPayload(tx.requireBlob(asset.requireBlobRef()), asset.requireContentType())); Content.extractFromAsset(asset, HASH_ALGORITHMS, content.getAttributes()); return content; }
Example #14
Source File: AptFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Override @Nullable @TransactionalTouchBlob public Content get(final String path) throws IOException { final StorageTx tx = UnitOfWork.currentTx(); final Asset asset = tx.findAssetWithProperty(P_NAME, path, tx.findBucket(getRepository())); if (asset == null) { return null; } return FacetHelper.toContent(asset, tx.requireBlob(asset.requireBlobRef())); }
Example #15
Source File: OrientNpmHostedFacet.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Nullable @Override @TransactionalTouchBlob public Content getTarball(final NpmPackageId packageId, final String tarballName) throws IOException { checkNotNull(packageId); checkNotNull(tarballName); StorageTx tx = UnitOfWork.currentTx(); return NpmFacetUtils.getTarballContent(tx, tx.findBucket(getRepository()), packageId, tarballName); }
Example #16
Source File: OrientNpmGroupFacet.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Nullable @TransactionalTouchBlob protected Asset getPackageRootAssetFromCache(final Context context) throws IOException { checkNotNull(context); StorageTx tx = UnitOfWork.currentTx(); return findPackageRootAsset(tx, tx.findBucket(getRepository()), packageId(matcherState(context))); }
Example #17
Source File: OrientPyPiHostedFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Override @TransactionalTouchBlob public Content getPackage(final String packagePath) { checkNotNull(packagePath); StorageTx tx = UnitOfWork.currentTx(); Asset asset = findAsset(tx, tx.findBucket(getRepository()), packagePath); if (asset == null) { return null; } Content content = toContent(asset, tx.requireBlob(asset.requireBlobRef())); mayAddEtag(content.getAttributes(), asset.getChecksum(HashAlgorithm.SHA1)); return content; }
Example #18
Source File: OrientPyPiProxyFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@TransactionalTouchBlob protected Content getAsset(final String name) { StorageTx tx = UnitOfWork.currentTx(); Asset asset = findAsset(tx, tx.findBucket(getRepository()), name); if (asset == null) { return null; } return toContent(asset, tx.requireBlob(asset.requireBlobRef())); }
Example #19
Source File: GolangHostedFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Nullable @TransactionalTouchBlob @Override public Content getMod(final String path) { checkNotNull(path); return doGet(path); }
Example #20
Source File: OrientPyPiGroupFacet.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@TransactionalTouchBlob public Content getFromCache(final String name, final AssetKind assetKind) { checkArgument(INDEX.equals(assetKind) || ROOT_INDEX.equals(assetKind), "Only index files are cached"); final StorageTx tx = UnitOfWork.currentTx(); final Bucket bucket = tx.findBucket(getRepository()); Asset asset = findAsset(tx, bucket, name); if (asset == null) { return null; } return toContent(asset, tx.requireBlob(asset.blobRef())); }
Example #21
Source File: OrientPyPiGroupFacet.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@TransactionalTouchBlob protected Asset getAsset(final StorageTx tx, final String name) { final Bucket bucket = tx.findBucket(getRepository()); Asset assets = findAsset(tx, bucket, name); if (assets == null) { assets = tx.createAsset(bucket, getRepository().getFormat()).name(name); assets.formatAttributes().set(P_ASSET_KIND, INDEX); } return assets; }
Example #22
Source File: P2RestoreFacetImpl.java From nexus-repository-p2 with Eclipse Public License 1.0 | 5 votes |
@Override @TransactionalTouchBlob public void restore(final AssetBlob assetBlob, final String path) { StorageTx tx = UnitOfWork.currentTx(); P2Facet facet = facet(P2Facet.class); Asset asset; if (componentRequired(path)) { P2Attributes attributes = P2Attributes.builder().build(); try { attributes = getComponentAttributes(assetBlob.getBlob(), path); } catch (IOException e) { log.error("Exception of extracting components attributes from blob {}", assetBlob); } Component component = facet.findOrCreateComponent(tx, 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); }
Example #23
Source File: RawContentFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Nullable @Override @TransactionalTouchBlob public Content get(final String path) { StorageTx tx = UnitOfWork.currentTx(); final Asset asset = findAsset(tx, path); if (asset == null) { return null; } final Blob blob = tx.requireBlob(asset.requireBlobRef()); return toContent(asset, blob); }
Example #24
Source File: GolangProxyFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@TransactionalTouchBlob protected Content getAsset(final String path) { StorageTx tx = UnitOfWork.currentTx(); Asset asset = golangDataAccess.findAsset(tx, tx.findBucket(getRepository()), path); if (asset == null) { return null; } return golangDataAccess.toContent(asset, tx.requireBlob(asset.requireBlobRef())); }
Example #25
Source File: GolangHostedFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Nullable @TransactionalTouchBlob @Override public Content getPackage(final String path) { checkNotNull(path); return doGet(path); }
Example #26
Source File: OrientNpmProxyFacet.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Nullable @TransactionalTouchBlob public Content getTarball(final NpmPackageId packageId, final String tarballName) throws IOException { checkNotNull(packageId); checkNotNull(tarballName); StorageTx tx = UnitOfWork.currentTx(); return NpmFacetUtils.getTarballContent(tx, tx.findBucket(getRepository()), packageId, tarballName); }
Example #27
Source File: P2ProxyFacetImpl.java From nexus-repository-p2 with Eclipse Public License 1.0 | 5 votes |
@TransactionalTouchBlob protected Content getAsset(final String name) { StorageTx tx = UnitOfWork.currentTx(); Asset asset = facet(P2Facet.class).findAsset(tx, tx.findBucket(getRepository()), name); if (asset == null) { return null; } if (asset.markAsDownloaded()) { tx.saveAsset(asset); } return facet(P2Facet.class).toContent(asset, tx.requireBlob(asset.requireBlobRef())); }
Example #28
Source File: HelmProxyFacetImpl.java From nexus-repository-helm with Eclipse Public License 1.0 | 5 votes |
@TransactionalTouchBlob protected Content getAsset(final String name) { StorageTx tx = UnitOfWork.currentTx(); Optional<Asset> assetOpt = helmFacet.findAsset(tx, name); if (!assetOpt.isPresent()) { return null; } Asset asset = assetOpt.get(); if (asset.markAsDownloaded()) { tx.saveAsset(asset); } return helmFacet.toContent(asset, tx.requireBlob(asset.requireBlobRef())); }
Example #29
Source File: HelmRestoreFacetImpl.java From nexus-repository-helm with Eclipse Public License 1.0 | 5 votes |
@Override @TransactionalTouchBlob public void restore(final AssetBlob assetBlob, final String path) throws IOException { StorageTx tx = UnitOfWork.currentTx(); AssetKind assetKind = AssetKind.getAssetKindByFileName(path); HelmAttributes attributes = helmAttributeParser.getAttributes(assetKind, assetBlob.getBlob().getInputStream()); Asset asset = helmFacet.findOrCreateAsset(tx, path, assetKind, attributes); tx.attachBlob(asset, assetBlob); Content.applyToAsset(asset, Content.maintainLastModified(asset, new AttributesMap())); tx.saveAsset(asset); }
Example #30
Source File: RProxyFacetImpl.java From nexus-repository-r with Eclipse Public License 1.0 | 5 votes |
@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())); }