@Transactional(retryOn = {ONeedRetryException.class, ORecordDuplicatedException.class})
  protected void doPutContent(
      final String path, final Supplier<InputStream> streamSupplier, final Payload payload)
      throws IOException {
    StorageTx tx = UnitOfWork.currentTransaction();

    final Bucket bucket = tx.getBucket();
    Component component = getComponent(tx, path, bucket);
    Asset asset;
    if (component == null) {
      // CREATE
      component =
          tx.createComponent(bucket, getRepository().getFormat())
              .group(getGroup(path))
              .name(getName(path));

      // Set attributes map to contain "raw" format-specific metadata (in this case, path)
      component.formatAttributes().set(P_PATH, path);
      tx.saveComponent(component);

      asset = tx.createAsset(bucket, component);
      asset.name(component.name());
    } else {
      // UPDATE
      asset = tx.firstAsset(component);
    }

    AttributesMap contentAttributes = null;
    if (payload instanceof Content) {
      contentAttributes = ((Content) payload).getAttributes();
    }
    Content.applyToAsset(asset, Content.maintainLastModified(asset, contentAttributes));
    tx.setBlob(asset, path, streamSupplier.get(), hashAlgorithms, null, payload.getContentType());
    tx.saveAsset(asset);
  }
 private Content marshall(final Asset asset, final Blob blob) {
   final Content content = new Content(new BlobPayload(blob, asset.requireContentType()));
   Content.extractFromAsset(asset, hashAlgorithms, content.getAttributes());
   return content;
 }