Java Code Examples for org.sonatype.nexus.repository.storage.StorageTx#createBlob()
The following examples show how to use
org.sonatype.nexus.repository.storage.StorageTx#createBlob() .
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: AptSnapshotFacetSupport.java From nexus-repository-apt with Eclipse Public License 1.0 | 6 votes |
@Transactional(retryOn = { ONeedRetryException.class }) @Override public void createSnapshot(String id, SnapshotComponentSelector selector) throws IOException { StorageTx tx = UnitOfWork.currentTx(); StorageFacet storageFacet = facet(StorageFacet.class); Bucket bucket = tx.findBucket(getRepository()); Component component = tx.createComponent(bucket, getRepository().getFormat()).name(id); tx.saveComponent(component); for (SnapshotItem item : collectSnapshotItems(selector)) { String assetName = createAssetPath(id, item.specifier.path); Asset asset = tx.createAsset(bucket, component).name(assetName); try (final TempBlob streamSupplier = storageFacet.createTempBlob(item.content.openInputStream(), FacetHelper.hashAlgorithms)) { AssetBlob blob = tx.createBlob(item.specifier.path, streamSupplier, FacetHelper.hashAlgorithms, null, FacetHelper.determineContentType(item), true); tx.attachBlob(asset, blob); } finally { item.content.close(); } tx.saveAsset(asset); } }
Example 2
Source File: NpmFacetUtils.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
/** * Creates an {@link AssetBlob} out of passed in content and attaches it to passed in {@link Asset}. */ @Nonnull static AssetBlob storeContent(final StorageTx tx, final Asset asset, final Supplier<InputStream> content, final AssetKind assetKind) throws IOException { asset.formatAttributes().set(P_ASSET_KIND, assetKind.name()); final AssetBlob result = tx.createBlob( asset.name(), content, HASH_ALGORITHMS, null, assetKind.getContentType(), assetKind.isSkipContentVerification() ); tx.attachBlob(asset, result); return result; }
Example 3
Source File: NpmFacetUtils.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
/** * Creates an {@link AssetBlob} out of passed in temporary blob and attaches it to passed in {@link Asset}. */ @Nonnull static AssetBlob storeContent(final StorageTx tx, final Asset asset, final TempBlob tempBlob, final AssetKind assetKind) throws IOException { asset.formatAttributes().set(P_ASSET_KIND, assetKind.name()); AssetBlob result = tx.createBlob( asset.name(), tempBlob, null, assetKind.getContentType(), assetKind.isSkipContentVerification() ); tx.attachBlob(asset, result); return result; }
Example 4
Source File: MavenFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@TransactionalStoreBlob protected Content doPut(final MavenPath path, final Payload payload, final TempBlob tempBlob) throws IOException { final StorageTx tx = UnitOfWork.currentTx(); final AssetBlob assetBlob = tx.createBlob( path.getPath(), tempBlob, null, payload.getContentType(), false ); AttributesMap contentAttributes = null; if (payload instanceof Content) { contentAttributes = ((Content) payload).getAttributes(); } return doPutAssetBlob(path, contentAttributes, tx, assetBlob); }
Example 5
Source File: MavenFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@TransactionalStoreBlob protected Content doPut(final MavenPath path, final Path sourceFile, final String contentType, final AttributesMap contentAttributes, final Map<HashAlgorithm, HashCode> hashes, final long size) throws IOException { final StorageTx tx = UnitOfWork.currentTx(); final AssetBlob assetBlob = tx.createBlob( path.getPath(), sourceFile, hashes, null, contentType, size ); return doPutAssetBlob(path, contentAttributes, tx, assetBlob); }
Example 6
Source File: AptSnapshotFacetSupport.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Transactional(retryOn = {ONeedRetryException.class}) protected void createSnapshot(final String id, final Iterable<SnapshotItem> snapshots) throws IOException { StorageTx tx = UnitOfWork.currentTx(); StorageFacet storageFacet = facet(StorageFacet.class); Bucket bucket = tx.findBucket(getRepository()); for (SnapshotItem item : snapshots) { String assetName = createAssetPath(id, item.specifier.path); Asset asset = tx.createAsset(bucket, getRepository().getFormat()).name(assetName); try (final TempBlob streamSupplier = storageFacet .createTempBlob(item.content.openInputStream(), FacetHelper.hashAlgorithms)) { AssetBlob blob = tx.createBlob(item.specifier.path, streamSupplier, FacetHelper.hashAlgorithms, null, item.specifier.role.getMimeType(), true); tx.attachBlob(asset, blob); } finally { item.content.close(); } tx.saveAsset(asset); } }
Example 7
Source File: NpmFacetUtils.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
/** * Creates an {@code AssetBlob} from a tarball's {@code TempBlob}. * * @since 3.7 */ static AssetBlob createTarballAssetBlob(final StorageTx tx, final NpmPackageId packageId, final String tarballName, final TempBlob tempBlob) throws IOException { return tx.createBlob( tarballAssetName(packageId, tarballName), tempBlob, null, TARBALL.getContentType(), TARBALL.isSkipContentVerification() ); }
Example 8
Source File: MavenFacetImpl.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@TransactionalStoreBlob protected Content doPut(final MavenPath path, final TempBlob blob, final String contentType, final AttributesMap contentAttributes) throws IOException { StorageTx tx = UnitOfWork.currentTx(); AssetBlob assetBlob = tx.createBlob(path.getPath(), blob, null, contentType, true); return doPutAssetBlob(path, contentAttributes, tx, assetBlob); }