Search in sources :

Example 16 with Content

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

the class RFacetUtils method saveAsset.

/**
 * Save an asset && create blob.
 *
 * @return blob content
 */
public static Content saveAsset(final StorageTx tx, final Asset asset, final Supplier<InputStream> contentSupplier, final Payload payload) throws IOException {
    AttributesMap contentAttributes = null;
    String contentType = null;
    if (payload instanceof Content) {
        contentAttributes = ((Content) payload).getAttributes();
        contentType = payload.getContentType();
    }
    return saveAsset(tx, asset, contentSupplier, contentType, contentAttributes);
}
Also used : Content(org.sonatype.nexus.repository.view.Content) AttributesMap(org.sonatype.nexus.common.collect.AttributesMap)

Example 17 with Content

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

the class RFacetUtils method toContent.

/**
 * Convert an asset blob to {@link Content}.
 *
 * @return content of asset blob
 */
public static Content toContent(final Asset asset, final Blob blob) {
    Content content = new Content(new BlobPayload(blob, asset.requireContentType()));
    Content.extractFromAsset(asset, HASH_ALGORITHMS, content.getAttributes());
    return content;
}
Also used : BlobPayload(org.sonatype.nexus.repository.view.payloads.BlobPayload) Content(org.sonatype.nexus.repository.view.Content)

Aggregations

Content (org.sonatype.nexus.repository.view.Content)17 Test (org.junit.Test)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 OutputStreamWriter (java.io.OutputStreamWriter)3 InternetHeaders (javax.mail.internet.InternetHeaders)3 CompressorException (org.apache.commons.compress.compressors.CompressorException)3 CompressorOutputStream (org.apache.commons.compress.compressors.CompressorOutputStream)3 CompressorStreamFactory (org.apache.commons.compress.compressors.CompressorStreamFactory)3 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 Map (java.util.Map)2 AttributesMap (org.sonatype.nexus.common.collect.AttributesMap)2 RFacetUtils.toContent (org.sonatype.nexus.repository.r.internal.RFacetUtils.toContent)2 RFacetUtils.toContent (org.sonatype.nexus.repository.r.internal.util.RFacetUtils.toContent)2 Asset (org.sonatype.nexus.repository.storage.Asset)2 Bucket (org.sonatype.nexus.repository.storage.Bucket)2 StorageTx (org.sonatype.nexus.repository.storage.StorageTx)2 TransactionalTouchMetadata (org.sonatype.nexus.repository.transaction.TransactionalTouchMetadata)2 BlobPayload (org.sonatype.nexus.repository.view.payloads.BlobPayload)2 BytesPayload (org.sonatype.nexus.repository.view.payloads.BytesPayload)2