Search in sources :

Example 1 with RFacet

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

the class RHostedFacetImpl method doPutPackagesGz.

@TransactionalStoreBlob
protected Content doPutPackagesGz(final StorageTx tx, final String basePath, final TempBlob tempPackagesGz) throws IOException {
    RFacet rFacet = facet(RFacet.class);
    Asset asset = rFacet.findOrCreateAsset(tx, buildPath(basePath, PACKAGES_GZ_FILENAME));
    return saveAsset(tx, asset, tempPackagesGz, "", null);
}
Also used : RFacet(org.sonatype.nexus.repository.r.RFacet) 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) TransactionalStoreBlob(org.sonatype.nexus.repository.transaction.TransactionalStoreBlob)

Example 2 with RFacet

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

the class RHostedFacetImpl method doPutArchive.

@TransactionalStoreBlob
protected Asset doPutArchive(final String path, final TempBlob archiveContent, final Payload payload) throws IOException {
    StorageTx tx = UnitOfWork.currentTx();
    RFacet rFacet = facet(RFacet.class);
    Map<String, String> attributes;
    try (InputStream is = archiveContent.get()) {
        attributes = extractDescriptionFromArchive(path, is);
    }
    Component component = rFacet.findOrCreateComponent(tx, path, attributes);
    Asset asset = rFacet.findOrCreateAsset(tx, component, path, attributes);
    saveAsset(tx, asset, archiveContent, payload);
    return asset;
}
Also used : RFacet(org.sonatype.nexus.repository.r.RFacet) StorageTx(org.sonatype.nexus.repository.storage.StorageTx) 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) Component(org.sonatype.nexus.repository.storage.Component) TransactionalStoreBlob(org.sonatype.nexus.repository.transaction.TransactionalStoreBlob)

Example 3 with RFacet

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

the class RProxyFacetImpl method doPutMetadata.

@TransactionalStoreBlob
protected Content doPutMetadata(final String path, final TempBlob packagesContent, final Payload payload) throws IOException {
    StorageTx tx = UnitOfWork.currentTx();
    RFacet rFacet = facet(RFacet.class);
    Asset asset = rFacet.findOrCreateAsset(tx, path);
    return saveAsset(tx, asset, packagesContent, payload);
}
Also used : RFacet(org.sonatype.nexus.repository.r.RFacet) StorageTx(org.sonatype.nexus.repository.storage.StorageTx) 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) TransactionalStoreBlob(org.sonatype.nexus.repository.transaction.TransactionalStoreBlob)

Example 4 with RFacet

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

the class RProxyFacetImpl method doPutArchive.

@TransactionalStoreBlob
protected Content doPutArchive(final String path, final TempBlob archiveContent, final Content content) throws IOException {
    RFacet rFacet = facet(RFacet.class);
    StorageTx tx = UnitOfWork.currentTx();
    Map<String, String> attributes;
    try (InputStream is = archiveContent.get()) {
        attributes = extractDescriptionFromArchive(path, is);
    }
    Component component = rFacet.findOrCreateComponent(tx, path, attributes);
    Asset asset = rFacet.findOrCreateAsset(tx, component, path, attributes);
    return saveAsset(tx, asset, archiveContent, content);
}
Also used : RFacet(org.sonatype.nexus.repository.r.RFacet) StorageTx(org.sonatype.nexus.repository.storage.StorageTx) 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) Component(org.sonatype.nexus.repository.storage.Component) TransactionalStoreBlob(org.sonatype.nexus.repository.transaction.TransactionalStoreBlob)

Example 5 with RFacet

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

the class RRestoreFacetImpl method restore.

@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);
}
Also used : RFacet(org.sonatype.nexus.repository.r.RFacet) StorageTx(org.sonatype.nexus.repository.storage.StorageTx) InputStream(java.io.InputStream) AttributesMap(org.sonatype.nexus.common.collect.AttributesMap) Asset(org.sonatype.nexus.repository.storage.Asset) Component(org.sonatype.nexus.repository.storage.Component) TransactionalTouchBlob(org.sonatype.nexus.repository.transaction.TransactionalTouchBlob)

Aggregations

RFacet (org.sonatype.nexus.repository.r.RFacet)5 Asset (org.sonatype.nexus.repository.storage.Asset)5 RFacetUtils.findAsset (org.sonatype.nexus.repository.r.internal.util.RFacetUtils.findAsset)4 RFacetUtils.saveAsset (org.sonatype.nexus.repository.r.internal.util.RFacetUtils.saveAsset)4 StorageTx (org.sonatype.nexus.repository.storage.StorageTx)4 TransactionalStoreBlob (org.sonatype.nexus.repository.transaction.TransactionalStoreBlob)4 InputStream (java.io.InputStream)3 Component (org.sonatype.nexus.repository.storage.Component)3 ByteArrayInputStream (java.io.ByteArrayInputStream)1 AttributesMap (org.sonatype.nexus.common.collect.AttributesMap)1 TransactionalTouchBlob (org.sonatype.nexus.repository.transaction.TransactionalTouchBlob)1