Search in sources :

Example 6 with AttributesMap

use of org.sonatype.nexus.common.collect.AttributesMap 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

AttributesMap (org.sonatype.nexus.common.collect.AttributesMap)6 Content (org.sonatype.nexus.repository.view.Content)2 InputStream (java.io.InputStream)1 RFacet (org.sonatype.nexus.repository.r.RFacet)1 Asset (org.sonatype.nexus.repository.storage.Asset)1 Component (org.sonatype.nexus.repository.storage.Component)1 StorageTx (org.sonatype.nexus.repository.storage.StorageTx)1 TransactionalTouchBlob (org.sonatype.nexus.repository.transaction.TransactionalTouchBlob)1