Java Code Examples for org.sonatype.nexus.repository.storage.Asset#requireContentType()

The following examples show how to use org.sonatype.nexus.repository.storage.Asset#requireContentType() . 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: NpmFacetUtils.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns the tarball content.
 */
@Nullable
static Content getTarballContent(final StorageTx tx,
                                 final Bucket bucket,
                                 final NpmPackageId packageId,
                                 final String tarballName)
{
  Asset asset = findTarballAsset(tx, bucket, packageId, tarballName);
  if (asset == null) {
    return null;
  }

  Blob blob = tx.requireBlob(asset.requireBlobRef());
  Content content = new Content(new BlobPayload(blob, asset.requireContentType()));
  Content.extractFromAsset(asset, HASH_ALGORITHMS, content.getAttributes());
  return content;
}
 
Example 2
Source File: P2FacetImpl.java    From nexus-repository-p2 with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Convert an asset blob to {@link Content}.
 *
 * @return content of asset blob
 */
@Override
public 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;
}
 
Example 3
Source File: CondaFacetImpl.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public 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;
}
 
Example 4
Source File: CocoapodsFacetImpl.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Override
@Nullable
@TransactionalTouchBlob
public Content get(final String path) {
  final StorageTx tx = UnitOfWork.currentTx();
  final Asset asset = tx.findAssetWithProperty(P_NAME, path, tx.findBucket(getRepository()));
  if (asset == null) {
    return null;
  }
  Content content = new Content(new BlobPayload(tx.requireBlob(asset.requireBlobRef()), asset.requireContentType()));
  Content.extractFromAsset(asset, HASH_ALGORITHMS, content.getAttributes());
  return content;
}
 
Example 5
Source File: CocoapodsFacetImpl.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Override
@TransactionalStoreBlob
public Content getOrCreateAsset(final String path, final Content content, boolean toAttachComponent)
    throws IOException
{
  StorageFacet storageFacet = facet(StorageFacet.class);
  try (final TempBlob tempBlob = storageFacet.createTempBlob(content, HASH_ALGORITHMS)) {
    StorageTx tx = UnitOfWork.currentTx();
    Bucket bucket = tx.findBucket(getRepository());

    Asset asset = tx.findAssetWithProperty(P_NAME, path, bucket);
    if (asset == null) {
      if (toAttachComponent) {
        Component component = findOrCreateComponent(tx, bucket, path);
        asset = tx.createAsset(bucket, component).name(path);
      }
      else {
        asset = tx.createAsset(bucket, getRepository().getFormat()).name(path);
      }
    }
    Content.applyToAsset(asset, content.getAttributes());
    AssetBlob blob = tx.setBlob(asset, path, tempBlob, HASH_ALGORITHMS, null, null, false);
    tx.saveAsset(asset);

    final Content updatedContent = new Content(new BlobPayload(blob.getBlob(), asset.requireContentType()));
    Content.extractFromAsset(asset, HASH_ALGORITHMS, updatedContent.getAttributes());
    return updatedContent;
  }
}
 
Example 6
Source File: ComposerContentFacetImpl.java    From nexus-repository-composer with Eclipse Public License 1.0 4 votes vote down vote up
private Content toContent(final Asset asset, final Blob blob) {
  final Content content = new Content(new BlobPayload(blob, asset.requireContentType()));
  Content.extractFromAsset(asset, hashAlgorithms, content.getAttributes());
  return content;
}
 
Example 7
Source File: HelmFacetImpl.java    From nexus-repository-helm with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Convert an asset blob to {@link Content}.
 *
 * @return content of asset blob
 */
public 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;
}
 
Example 8
Source File: RFacetUtils.java    From nexus-repository-r with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 9
Source File: ConanProxyFacet.java    From nexus-repository-conan with Eclipse Public License 1.0 4 votes vote down vote up
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;
}
 
Example 10
Source File: FacetHelper.java    From nexus-repository-apt with Eclipse Public License 1.0 4 votes vote down vote up
public static Content toContent(final Asset asset, final Blob blob) {
  final Content content = new Content(new BlobPayload(blob, asset.requireContentType()));
  Content.extractFromAsset(asset, hashAlgorithms, content.getAttributes());
  return content;
}
 
Example 11
Source File: NpmFacetUtils.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * 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;
}
 
Example 12
Source File: OrientPyPiDataUtils.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Convert an asset blob to {@link Content}.
 *
 * @return content of asset blob
 */
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;
}
 
Example 13
Source File: RawContentFacetImpl.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
private Content toContent(final Asset asset, final Blob blob) {
  final Content content = new Content(new BlobPayload(blob, asset.requireContentType()));
  Content.extractFromAsset(asset, hashAlgorithms, content.getAttributes());
  return content;
}
 
Example 14
Source File: GolangDataAccess.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Convert an asset blob to {@link Content}.
 *
 * @return content of asset blob
 */
public 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;
}
 
Example 15
Source File: GolangDataAccess.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
public Payload getBlobAsPayload(final StorageTx tx, final Asset asset) {
  return new BlobPayload(tx.requireBlob(asset.requireBlobRef()), asset.requireContentType());
}
 
Example 16
Source File: FacetHelper.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
public static Content toContent(final Asset asset, final Blob blob) {
  final Content content = new Content(new BlobPayload(blob, asset.requireContentType()));
  Content.extractFromAsset(asset, hashAlgorithms, content.getAttributes());
  return content;
}