Search in sources :

Example 1 with StorageFacet

use of org.sonatype.nexus.repository.storage.StorageFacet in project nexus-repository-r by sonatype-nexus-community.

the class RHostedFacetImpl method upload.

@Override
public void upload(final String path, final Payload payload) throws IOException {
    checkNotNull(path);
    checkNotNull(payload);
    StorageFacet storageFacet = facet(StorageFacet.class);
    try (TempBlob tempBlob = storageFacet.createTempBlob(payload, RFacetUtils.HASH_ALGORITHMS)) {
        doPutArchive(path, tempBlob, payload);
    }
}
Also used : TempBlob(org.sonatype.nexus.repository.storage.TempBlob) StorageFacet(org.sonatype.nexus.repository.storage.StorageFacet)

Example 2 with StorageFacet

use of org.sonatype.nexus.repository.storage.StorageFacet in project nexus-repository-r by sonatype-nexus-community.

the class RHostedFacetImpl method buildAndPutPackagesGz.

@Override
@TransactionalTouchMetadata
public Content buildAndPutPackagesGz(final String basePath) throws IOException {
    checkNotNull(basePath);
    StorageTx tx = UnitOfWork.currentTx();
    RPackagesBuilder packagesBuilder = new RPackagesBuilder();
    Iterable<Asset> archiveAssets = browseAllAssetsByKind(tx, tx.findBucket(getRepository()), ARCHIVE);
    // packageInfoBuilder doesn't support multithreading
    StreamSupport.stream(archiveAssets.spliterator(), false).filter(asset -> basePath.equals(getBasePath(asset.name()))).forEach(packagesBuilder::append);
    byte[] packagesBytes = packagesBuilder.buildPackagesGz();
    StorageFacet storageFacet = getRepository().facet(StorageFacet.class);
    try (InputStream is = new ByteArrayInputStream(packagesBytes)) {
        TempBlob tempPackagesGz = storageFacet.createTempBlob(is, RFacetUtils.HASH_ALGORITHMS);
        return doPutPackagesGz(tx, basePath, tempPackagesGz);
    }
}
Also used : StorageFacet(org.sonatype.nexus.repository.storage.StorageFacet) ARCHIVE(org.sonatype.nexus.repository.r.internal.AssetKind.ARCHIVE) RFacetUtils.saveAsset(org.sonatype.nexus.repository.r.internal.util.RFacetUtils.saveAsset) RFacet(org.sonatype.nexus.repository.r.RFacet) RFacetUtils(org.sonatype.nexus.repository.r.internal.util.RFacetUtils) RFacetUtils.toContent(org.sonatype.nexus.repository.r.internal.util.RFacetUtils.toContent) Component(org.sonatype.nexus.repository.storage.Component) UnitOfWork(org.sonatype.nexus.transaction.UnitOfWork) ByteArrayInputStream(java.io.ByteArrayInputStream) RHostedFacet(org.sonatype.nexus.repository.r.RHostedFacet) Map(java.util.Map) Payload(org.sonatype.nexus.repository.view.Payload) StreamSupport(java.util.stream.StreamSupport) PACKAGES_GZ_FILENAME(org.sonatype.nexus.repository.r.internal.util.RPathUtils.PACKAGES_GZ_FILENAME) Named(javax.inject.Named) TransactionalStoreBlob(org.sonatype.nexus.repository.transaction.TransactionalStoreBlob) RDescriptionUtils.extractDescriptionFromArchive(org.sonatype.nexus.repository.r.internal.util.RDescriptionUtils.extractDescriptionFromArchive) TempBlob(org.sonatype.nexus.repository.storage.TempBlob) RPathUtils.getBasePath(org.sonatype.nexus.repository.r.internal.util.RPathUtils.getBasePath) TransactionalTouchBlob(org.sonatype.nexus.repository.transaction.TransactionalTouchBlob) FacetSupport(org.sonatype.nexus.repository.FacetSupport) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) RFacetUtils.findAsset(org.sonatype.nexus.repository.r.internal.util.RFacetUtils.findAsset) IOException(java.io.IOException) StorageTx(org.sonatype.nexus.repository.storage.StorageTx) Asset(org.sonatype.nexus.repository.storage.Asset) Content(org.sonatype.nexus.repository.view.Content) TransactionalTouchMetadata(org.sonatype.nexus.repository.transaction.TransactionalTouchMetadata) RFacetUtils.browseAllAssetsByKind(org.sonatype.nexus.repository.r.internal.util.RFacetUtils.browseAllAssetsByKind) RPathUtils.buildPath(org.sonatype.nexus.repository.r.internal.util.RPathUtils.buildPath) InputStream(java.io.InputStream) TempBlob(org.sonatype.nexus.repository.storage.TempBlob) StorageTx(org.sonatype.nexus.repository.storage.StorageTx) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) RFacetUtils.saveAsset(org.sonatype.nexus.repository.r.internal.util.RFacetUtils.saveAsset) RFacetUtils.findAsset(org.sonatype.nexus.repository.r.internal.util.RFacetUtils.findAsset) Asset(org.sonatype.nexus.repository.storage.Asset) StorageFacet(org.sonatype.nexus.repository.storage.StorageFacet) TransactionalTouchMetadata(org.sonatype.nexus.repository.transaction.TransactionalTouchMetadata)

Example 3 with StorageFacet

use of org.sonatype.nexus.repository.storage.StorageFacet in project nexus-repository-r by sonatype-nexus-community.

the class RProxyFacetImpl method putArchive.

private Content putArchive(final String path, final Content content) throws IOException {
    checkNotNull(path);
    checkNotNull(content);
    StorageFacet storageFacet = facet(StorageFacet.class);
    try (TempBlob tempBlob = storageFacet.createTempBlob(content.openInputStream(), RFacetUtils.HASH_ALGORITHMS)) {
        return doPutArchive(path, tempBlob, content);
    }
}
Also used : TempBlob(org.sonatype.nexus.repository.storage.TempBlob) StorageFacet(org.sonatype.nexus.repository.storage.StorageFacet)

Example 4 with StorageFacet

use of org.sonatype.nexus.repository.storage.StorageFacet in project nexus-repository-r by sonatype-nexus-community.

the class RHostedFacetImpl method upload.

@Override
public Asset upload(final String path, final Payload payload) throws IOException {
    checkNotNull(path);
    checkNotNull(payload);
    StorageFacet storageFacet = facet(StorageFacet.class);
    try (TempBlob tempBlob = storageFacet.createTempBlob(payload, RFacetUtils.HASH_ALGORITHMS)) {
        return doPutArchive(path, tempBlob, payload);
    }
}
Also used : TempBlob(org.sonatype.nexus.repository.storage.TempBlob) StorageFacet(org.sonatype.nexus.repository.storage.StorageFacet)

Aggregations

StorageFacet (org.sonatype.nexus.repository.storage.StorageFacet)4 TempBlob (org.sonatype.nexus.repository.storage.TempBlob)4 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Map (java.util.Map)1 StreamSupport (java.util.stream.StreamSupport)1 Named (javax.inject.Named)1 FacetSupport (org.sonatype.nexus.repository.FacetSupport)1 RFacet (org.sonatype.nexus.repository.r.RFacet)1 RHostedFacet (org.sonatype.nexus.repository.r.RHostedFacet)1 ARCHIVE (org.sonatype.nexus.repository.r.internal.AssetKind.ARCHIVE)1 RDescriptionUtils.extractDescriptionFromArchive (org.sonatype.nexus.repository.r.internal.util.RDescriptionUtils.extractDescriptionFromArchive)1 RFacetUtils (org.sonatype.nexus.repository.r.internal.util.RFacetUtils)1 RFacetUtils.browseAllAssetsByKind (org.sonatype.nexus.repository.r.internal.util.RFacetUtils.browseAllAssetsByKind)1 RFacetUtils.findAsset (org.sonatype.nexus.repository.r.internal.util.RFacetUtils.findAsset)1 RFacetUtils.saveAsset (org.sonatype.nexus.repository.r.internal.util.RFacetUtils.saveAsset)1 RFacetUtils.toContent (org.sonatype.nexus.repository.r.internal.util.RFacetUtils.toContent)1 PACKAGES_GZ_FILENAME (org.sonatype.nexus.repository.r.internal.util.RPathUtils.PACKAGES_GZ_FILENAME)1