Java Code Examples for org.sonatype.nexus.repository.view.Content#maintainLastModified()

The following examples show how to use org.sonatype.nexus.repository.view.Content#maintainLastModified() . 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: OrientPyPiGroupFacet.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@TransactionalStoreBlob
public Content saveToCache(final String name, final Content content) throws IOException {
  StorageTx tx = UnitOfWork.currentTx();

  Asset asset = getAsset(tx, name);
  AttributesMap contentAttributes = Content.maintainLastModified(asset, null);
  contentAttributes.set(CacheInfo.class, cacheController.current());
  Content.applyToAsset(asset, contentAttributes);

  AssetBlob blob = updateAsset(tx, asset, content);

  Content response = new Content(new BlobPayload(blob.getBlob(), ContentTypes.TEXT_HTML));
  Content.extractFromAsset(asset, HASH_ALGORITHMS, response.getAttributes());

  return response;
}
 
Example 2
Source File: OrientPyPiGroupFacet.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@TransactionalStoreBlob
protected AssetBlob updateAsset(final StorageTx tx, final Asset asset, final Content content) throws IOException {
  AttributesMap contentAttributes = Content.maintainLastModified(asset, content.getAttributes());
  Content.applyToAsset(asset, contentAttributes);

  InputStream inputStream = content.openInputStream();
  AssetBlob blob = tx.setBlob(asset,
      asset.name(),
      () -> inputStream,
      HASH_ALGORITHMS,
      null,
      ContentTypes.TEXT_HTML,
      true);

  tx.saveAsset(asset);

  return blob;
}