Codota Logo
Content.applyToAsset
Code IndexAdd Codota to your IDE (free)

How to use
applyToAsset
method
in
org.sonatype.nexus.repository.view.Content

Best Java code snippets using org.sonatype.nexus.repository.view.Content.applyToAsset (Showing top 12 results out of 315)

  • Common ways to obtain Content
private void myMethod () {
Content c =
  • Codota IconBlob blob;Asset asset;new Content(new BlobPayload(blob, asset.requireContentType()))
  • Smart code suggestions by Codota
}
origin: org.sonatype.nexus.plugins/nexus-repository-maven

private void putAssetPayload(final StorageTx tx,
  final Asset asset,
  final AssetBlob assetBlob,
  @Nullable final AttributesMap contentAttributes)
  throws IOException
{
 tx.attachBlob(asset, assetBlob);
 Content.applyToAsset(asset, Content.maintainLastModified(asset, contentAttributes));
}
origin: org.sonatype.nexus.plugins/nexus-repository-npm

private void saveAsset(final StorageTx tx,
            final Asset asset,
            final AssetBlob assetBlob,
            final AssetKind kind,
            @Nullable final AttributesMap contentAttributes)
{
 asset.formatAttributes().set(P_ASSET_KIND, kind.name());
 tx.attachBlob(asset, assetBlob);
 Content.applyToAsset(asset, Content.maintainLastModified(asset, contentAttributes));
 tx.saveAsset(asset);
}
origin: org.sonatype.nexus.plugins/nexus-repository-npm

/**
 * Save repository root asset & create blob from an input stream.
 *
 * @return blob content
 */
@Nonnull
public static Content saveRepositoryRoot(final StorageTx tx,
                     final Asset asset,
                     final Supplier<InputStream> contentSupplier,
                     final Content content) throws IOException
{
 Content.applyToAsset(asset, Content.maintainLastModified(asset, content.getAttributes()));
 final AssetBlob assetBlob = storeContent(tx, asset, contentSupplier, AssetKind.REPOSITORY_ROOT);
 tx.saveAsset(asset);
 return toContent(asset, assetBlob.getBlob());
}
origin: org.sonatype.nexus.plugins/nexus-repository-npm

/**
 * Save repository root asset & create blob from a temporary blob.
 *
 * @return blob content
 */
@Nonnull
static Content saveRepositoryRoot(final StorageTx tx,
                 final Asset asset,
                 final TempBlob tempBlob,
                 final Content content) throws IOException
{
 Content.applyToAsset(asset, Content.maintainLastModified(asset, content.getAttributes()));
 AssetBlob assetBlob = storeContent(tx, asset, tempBlob, AssetKind.REPOSITORY_ROOT);
 tx.saveAsset(asset);
 return toContent(asset, assetBlob.getBlob());
}
origin: org.sonatype.nexus.plugins/nexus-repository-raw

@Override
@TransactionalStoreBlob
public Asset put(final String path, final AssetBlob assetBlob, @Nullable final AttributesMap contentAttributes) {
 StorageTx tx = UnitOfWork.currentTx();
 Asset asset = getOrCreateAsset(getRepository(), path, RawCoordinatesHelper.getGroup(path), path);
 tx.attachBlob(asset, assetBlob);
 Content.applyToAsset(asset, Content.maintainLastModified(asset, contentAttributes));
 tx.saveAsset(asset);
 return asset;
}
origin: sonatype-nexus-community/nexus-repository-helm

/**
 * Save an asset and create blob.
 *
 * @return blob content
 */
public Content saveAsset(final StorageTx tx,
             final Asset asset,
             final Supplier<InputStream> contentSupplier,
             final String contentType,
             @Nullable final AttributesMap contentAttributes) throws IOException
{
 Content.applyToAsset(asset, Content.maintainLastModified(asset, contentAttributes));
 AssetBlob assetBlob = tx.setBlob(
   asset, asset.name(), contentSupplier, HASH_ALGORITHMS, null, contentType, false
 );
 asset.markAsDownloaded();
 tx.saveAsset(asset);
 return toContent(asset, assetBlob.getBlob());
}
origin: org.sonatype.nexus.plugins/nexus-repository-npm

@TransactionalStoreBlob
protected Asset savePackageRootToCache(final NpmPackageId packageId, final NestedAttributesMap result) throws IOException {
 StorageTx tx = UnitOfWork.currentTx();
 Asset asset = getAsset(tx, packageId);
 AttributesMap contentAttributes = maintainLastModified(asset, null);
 maintainCacheInfo(contentAttributes);
 applyToAsset(asset, contentAttributes);
 savePackageRoot(tx, asset, result);
 return asset;
}
origin: org.sonatype.nexus.plugins/nexus-repository-raw

@TransactionalStoreBlob
protected Content doPutContent(final String path, final TempBlob tempBlob, final Payload payload)
  throws IOException
{
 StorageTx tx = UnitOfWork.currentTx();
 Asset asset = getOrCreateAsset(getRepository(), path, RawCoordinatesHelper.getGroup(path), path);
 AttributesMap contentAttributes = null;
 if (payload instanceof Content) {
  contentAttributes = ((Content) payload).getAttributes();
 }
 Content.applyToAsset(asset, Content.maintainLastModified(asset, contentAttributes));
 AssetBlob assetBlob = tx.setBlob(
   asset,
   path,
   tempBlob,
   null,
   payload.getContentType(),
   false
 );
 tx.saveAsset(asset);
 return toContent(asset, assetBlob.getBlob());
}
origin: sonatype-nexus-community/nexus-repository-composer

@TransactionalStoreBlob
protected Content doPutMetadata(final String path,
                final TempBlob tempBlob,
                final Payload payload,
                final AssetKind assetKind)
  throws IOException
{
 StorageTx tx = UnitOfWork.currentTx();
 Asset asset = getOrCreateAsset(path);
 asset.formatAttributes().set(P_ASSET_KIND, assetKind.toString());
 if (payload instanceof Content) {
  Content.applyToAsset(asset, Content.maintainLastModified(asset, ((Content) payload).getAttributes()));
 }
 AssetBlob assetBlob = tx.setBlob(
   asset,
   path,
   tempBlob,
   null,
   payload.getContentType(),
   false
 );
 tx.saveAsset(asset);
 return toContent(asset, assetBlob.getBlob());
}
origin: org.sonatype.nexus.plugins/nexus-repository-npm

@TransactionalStoreBlob
protected Content doPutPackageRoot(final NpmPackageId packageId,
                  final NestedAttributesMap packageRoot,
                  final Content content,
                  final boolean mergePackageRoot) throws IOException
{
 log.debug("Storing package: {}", packageId);
 StorageTx tx = UnitOfWork.currentTx();
 Bucket bucket = tx.findBucket(getRepository());
 NestedAttributesMap newPackageRoot =  packageRoot;
   
 Asset asset = NpmFacetUtils.findPackageRootAsset(tx, bucket, packageId);
 if (asset == null) {
  asset = tx.createAsset(bucket, getRepository().getFormat()).name(packageId.id());
 }
 else if (mergePackageRoot) {
  newPackageRoot = mergeNewRootWithExistingRoot(tx, newPackageRoot, asset);
 }
 
 Content.applyToAsset(asset, Content.maintainLastModified(asset, content.getAttributes()));
 NpmFacetUtils.savePackageRoot(tx, asset, newPackageRoot);
 // we must have the round-trip to equip record with _rev rewrite the URLs (ret val is served to client)
 NestedAttributesMap storedPackageRoot = NpmFacetUtils.loadPackageRoot(tx, asset);
 NpmMetadataUtils.rewriteTarballUrl(getRepository().getName(), storedPackageRoot);
 return NpmFacetUtils.toContent(asset, storedPackageRoot);
}
origin: sonatype-nexus-community/nexus-repository-composer

Content.applyToAsset(asset, Content.maintainLastModified(asset, ((Content) payload).getAttributes()));
origin: sonatype-nexus-community/nexus-repository-apt

@Override
@TransactionalStoreBlob
public Content put(String path, Payload content) throws IOException {
 StorageFacet storageFacet = facet(StorageFacet.class);
 try (final TempBlob tembBlob = storageFacet.createTempBlob(content, FacetHelper.hashAlgorithms)) {
  StorageTx tx = UnitOfWork.currentTx();
  Bucket bucket = tx.findBucket(getRepository());
  Asset asset = tx.findAssetWithProperty(P_NAME, path, bucket);
  if (asset == null) {
   asset = tx.createAsset(bucket, getRepository().getFormat()).name(path);
  }
  AttributesMap contentAttributes = null;
  if (content instanceof Content) {
   contentAttributes = ((Content) content).getAttributes();
  }
  Content.applyToAsset(asset, Content.maintainLastModified(asset, contentAttributes));
  AssetBlob blob = tx.setBlob(
    asset,
    path,
    tembBlob,
    FacetHelper.hashAlgorithms,
    null,
    content.getContentType(),
    false);
  tx.saveAsset(asset);
  return FacetHelper.toContent(asset, blob.getBlob());
 }
}
org.sonatype.nexus.repository.viewContentapplyToAsset

Javadoc

Applies non-format specific content attributes onto passed in Asset from passed in AttributesMap(usually originating from Content#getAttributes()).

Popular methods of Content

  • <init>
  • getAttributes
  • extractFromAsset
    Extracts non-format specific content attributes into the passed in AttributesMap (usually originatin
  • findAsset
    Finds fresh Asset instance from passed in TX by entity ID of the Asset used to create passed in Cont
  • maintainLastModified
    Maintains the "last modified" attribute of the content by setting it to "now". It accepts nulls, and
  • openInputStream
  • getContentType
  • close
  • getSize

Popular in Java

  • Updating database using SQL prepared statement
  • setScale (BigDecimal)
  • orElseThrow (Optional)
  • getSharedPreferences (Context)
  • Kernel (java.awt.image)
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • HashSet (java.util)
    This class implements the Set interface, backed by a hash table (actually a HashMap instance). It m
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • TimerTask (java.util)
    A task that can be scheduled for one-time or repeated execution by a Timer.
  • JTextField (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now