Tabnine Logo
Content.applyToAsset
Code IndexAdd Tabnine 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)

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

  • Running tasks concurrently on multiple threads
  • setScale (BigDecimal)
  • onRequestPermissionsResult (Fragment)
  • findViewById (Activity)
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • IsNull (org.hamcrest.core)
    Is the value null?
  • PhpStorm for WordPress
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now