Java Code Examples for org.sonatype.nexus.repository.cache.CacheInfo#applyToAsset()

The following examples show how to use org.sonatype.nexus.repository.cache.CacheInfo#applyToAsset() . 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: RProxyFacetImpl.java    From nexus-repository-r with Eclipse Public License 1.0 6 votes vote down vote up
@TransactionalTouchMetadata
public void setCacheInfo(final Content content, final CacheInfo cacheInfo) {
  StorageTx tx = UnitOfWork.currentTx();

  Asset asset = Content.findAsset(tx, tx.findBucket(getRepository()), content);
  if (asset == null) {
    log.debug(
        "Attempting to set cache info for non-existent R asset {}", content.getAttributes().require(Asset.class)
    );
    return;
  }

  log.debug("Updating cacheInfo of {} to {}", asset, cacheInfo);
  CacheInfo.applyToAsset(asset, cacheInfo);
  tx.saveAsset(asset);
}
 
Example 2
Source File: OrientNpmProxyFacet.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@TransactionalTouchMetadata
public void setCacheInfo(final Content content, final CacheInfo cacheInfo) throws IOException {
  StorageTx tx = UnitOfWork.currentTx();

  Asset asset = Content.findAsset(tx, tx.findBucket(getRepository()), content);
  if (asset == null) {
    log.debug(
        "Attempting to set cache info for non-existent npm asset {}", content.getAttributes().require(Asset.class)
    );
    return;
  }

  log.debug("Updating cacheInfo of {} to {}", asset, cacheInfo);
  CacheInfo.applyToAsset(asset, cacheInfo);
  tx.saveAsset(asset);
}
 
Example 3
Source File: OrientPyPiProxyFacetImpl.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@TransactionalTouchMetadata
protected void setCacheInfo(final Content content, final CacheInfo cacheInfo) throws IOException {
  StorageTx tx = UnitOfWork.currentTx();

  Asset asset = Content.findAsset(tx, tx.findBucket(getRepository()), content);
  if (asset == null) {
    log.debug(
        "Attempting to set cache info for non-existent pypi asset {}", content.getAttributes().require(Asset.class)
    );
    return;
  }

  log.debug("Updating cacheInfo of {} to {}", asset, cacheInfo);
  CacheInfo.applyToAsset(asset, cacheInfo);
  tx.saveAsset(asset);
}
 
Example 4
Source File: RawContentFacetImpl.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@Override
@TransactionalTouchMetadata
public void setCacheInfo(final String path, final Content content, final CacheInfo cacheInfo) throws IOException {
  StorageTx tx = UnitOfWork.currentTx();
  Bucket bucket = tx.findBucket(getRepository());

  // by EntityId
  Asset asset = Content.findAsset(tx, bucket, content);
  if (asset == null) {
    // by format coordinates
    Component component = tx.findComponentWithProperty(P_NAME, path, bucket);
    if (component != null) {
      asset = tx.firstAsset(component);
    }
  }
  if (asset == null) {
    log.debug("Attempting to set cache info for non-existent raw component {}", path);
    return;
  }

  log.debug("Updating cacheInfo of {} to {}", path, cacheInfo);
  CacheInfo.applyToAsset(asset, cacheInfo);
  tx.saveAsset(asset);
}
 
Example 5
Source File: MavenProxyFacet.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@Override
@TransactionalTouchMetadata
protected void indicateVerified(final Context context, final Content content, final CacheInfo cacheInfo)
    throws IOException
{
  final StorageTx tx = UnitOfWork.currentTx();
  final Bucket bucket = tx.findBucket(getRepository());
  final MavenPath path = mavenPath(context);

  // by EntityId
  Asset asset = Content.findAsset(tx, bucket, content);
  if (asset == null) {
    // by format coordinates
    asset = findAsset(tx, bucket, path);
  }
  if (asset == null) {
    log.debug("Attempting to set cache info for non-existent maven asset {}", path.getPath());
    return;
  }

  log.debug("Updating cacheInfo of {} to {}", path.getPath(), cacheInfo);
  CacheInfo.applyToAsset(asset, cacheInfo);
  tx.saveAsset(asset);
}
 
Example 6
Source File: CocoapodsProxyFacet.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@TransactionalTouchMetadata
public void setCacheInfo(final Content content, final CacheInfo cacheInfo) throws IOException {
  StorageTx tx = UnitOfWork.currentTx();

  Asset asset = Content.findAsset(tx, tx.findBucket(getRepository()), content);
  if (asset == null) {
    log.debug(
        "Attempting to set cache info for non-existent Cocoapods asset {}",
        content.getAttributes().require(Asset.class)
    );
    return;
  }

  log.debug("Updating cacheInfo of {} to {}", asset, cacheInfo);
  CacheInfo.applyToAsset(asset, cacheInfo);
  tx.saveAsset(asset);
}
 
Example 7
Source File: ComposerContentFacetImpl.java    From nexus-repository-composer with Eclipse Public License 1.0 5 votes vote down vote up
@Override
@TransactionalTouchMetadata
public void setCacheInfo(final String path, final Content content, final CacheInfo cacheInfo) throws IOException {
  StorageTx tx = UnitOfWork.currentTx();
  Bucket bucket = tx.findBucket(getRepository());

  Asset asset = Content.findAsset(tx, bucket, content);
  if (asset == null) {
    log.debug("Attempting to set cache info for non-existent Composer asset {}", path);
    return;
  }

  CacheInfo.applyToAsset(asset, cacheInfo);
  tx.saveAsset(asset);
}
 
Example 8
Source File: P2ProxyFacetImpl.java    From nexus-repository-p2 with Eclipse Public License 1.0 5 votes vote down vote up
@TransactionalTouchMetadata
public void setCacheInfo(final Content content, final CacheInfo cacheInfo) {
  StorageTx tx = UnitOfWork.currentTx();
  Asset asset = Content.findAsset(tx, tx.findBucket(getRepository()), content);
  if (asset == null) {
    log.debug(
        "Attempting to set cache info for non-existent P2 asset {}", content.getAttributes().require(Asset.class)
    );
    return;
  }
  log.debug("Updating cacheInfo of {} to {}", asset, cacheInfo);
  CacheInfo.applyToAsset(asset, cacheInfo);
  tx.saveAsset(asset);
}
 
Example 9
Source File: HelmProxyFacetImpl.java    From nexus-repository-helm with Eclipse Public License 1.0 5 votes vote down vote up
@TransactionalTouchMetadata
public void setCacheInfo(final Content content, final CacheInfo cacheInfo) {
  StorageTx tx = UnitOfWork.currentTx();
  Asset asset = Content.findAsset(tx, tx.findBucket(getRepository()), content);
  if (asset == null) {
    log.debug(
        "Attempting to set cache info for non-existent Helm asset {}", content.getAttributes().require(Asset.class)
    );
    return;
  }
  log.debug("Updating cacheInfo of {} to {}", asset, cacheInfo);
  CacheInfo.applyToAsset(asset, cacheInfo);
  tx.saveAsset(asset);
}
 
Example 10
Source File: AptProxyFacet.java    From nexus-repository-apt with Eclipse Public License 1.0 5 votes vote down vote up
@Transactional(retryOn = { ONeedRetryException.class })
protected void doIndicateVerified(Content content, CacheInfo cacheInfo, String assetPath) {
  StorageTx tx = UnitOfWork.currentTx();
  Bucket bucket = tx.findBucket(getRepository());

  Asset asset = Content.findAsset(tx, bucket, content);
  if (asset == null) {
    asset = tx.findAssetWithProperty(P_NAME, assetPath, bucket);
  }
  if (asset == null) {
    return;
  }
  CacheInfo.applyToAsset(asset, cacheInfo);
  tx.saveAsset(asset);
}
 
Example 11
Source File: CondaProxyFacetImpl.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@TransactionalTouchMetadata
protected void setCacheInfo(final Content content, final CacheInfo cacheInfo)
{
  StorageTx tx = UnitOfWork.currentTx();
  Asset asset = Content.findAsset(tx, tx.findBucket(getRepository()), content);
  if (asset == null) {
    log.debug(
        "Attempting to set cache info for non-existent Conda asset {}", content.getAttributes().require(Asset.class)
    );
    return;
  }
  log.debug("Updating cacheInfo of {} to {}", asset, cacheInfo);
  CacheInfo.applyToAsset(asset, cacheInfo);
  tx.saveAsset(asset);
}
 
Example 12
Source File: GolangProxyFacetImpl.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@TransactionalTouchMetadata
public void setCacheInfo(final Content content, final CacheInfo cacheInfo) throws IOException {
  StorageTx tx = UnitOfWork.currentTx();
  Asset asset = Content.findAsset(tx, tx.findBucket(getRepository()), content);
  if (asset == null) {
    log.debug(
        "Attempting to set cache info for non-existent go asset {}", content.getAttributes().require(Asset.class)
    );
    return;
  }
  log.debug("Updating cacheInfo of {} to {}", asset, cacheInfo);
  CacheInfo.applyToAsset(asset, cacheInfo);
  tx.saveAsset(asset);
}
 
Example 13
Source File: AptProxyFacet.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Transactional(retryOn = {ONeedRetryException.class})
protected void doIndicateVerified(final Content content, final CacheInfo cacheInfo, final String assetPath) {
  StorageTx tx = UnitOfWork.currentTx();
  Bucket bucket = tx.findBucket(getRepository());

  Asset asset = Content.findAsset(tx, bucket, content);
  if (asset == null) {
    asset = tx.findAssetWithProperty(P_NAME, assetPath, bucket);
  }
  if (asset == null) {
    return;
  }
  CacheInfo.applyToAsset(asset, cacheInfo);
  tx.saveAsset(asset);
}
 
Example 14
Source File: Content.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Applies non-format specific content attributes onto passed in {@link Asset} from passed in {@link AttributesMap}
 * (usually originating from {@link Content#getAttributes()}).
 */
public static void applyToAsset(final Asset asset, final AttributesMap contentAttributes) {
  checkNotNull(asset);
  checkNotNull(contentAttributes);
  final NestedAttributesMap assetAttributes = asset.attributes().child(CONTENT);
  assetAttributes.set(P_LAST_MODIFIED, toDate(contentAttributes.get(Content.CONTENT_LAST_MODIFIED, DateTime.class)));
  assetAttributes.set(P_ETAG, contentAttributes.get(Content.CONTENT_ETAG, String.class));
  final CacheInfo cacheInfo = contentAttributes.get(CacheInfo.class);
  if (cacheInfo != null) {
    CacheInfo.applyToAsset(asset, cacheInfo);
  }
}
 
Example 15
Source File: DeconflictAssetMetadataTest.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
private void setLastVerified(final Asset asset, final DateTime lastVerified) {
  CacheInfo.applyToAsset(asset, new CacheInfo(lastVerified, null));
}
 
Example 16
Source File: DeconflictAssetMetadataTest.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
private void setCacheToken(final Asset asset, final String cacheToken) {
  CacheInfo.applyToAsset(asset, new CacheInfo(DateTime.now(), cacheToken));
}