Java Code Examples for org.sonatype.nexus.blobstore.api.Blob#getHeaders()

The following examples show how to use org.sonatype.nexus.blobstore.api.Blob#getHeaders() . 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: FluentAssetImpl.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
private AssetBlobData createAssetBlob(final BlobRef blobRef,
                                      final Blob blob,
                                      final Map<HashAlgorithm, HashCode> checksums)
{
  BlobMetrics metrics = blob.getMetrics();
  Map<String, String> headers = blob.getHeaders();

  AssetBlobData assetBlob = new AssetBlobData();
  assetBlob.setBlobRef(blobRef);
  assetBlob.setBlobSize(metrics.getContentSize());
  assetBlob.setContentType(headers.get(CONTENT_TYPE_HEADER));

  assetBlob.setChecksums(checksums.entrySet().stream().collect(
      toImmutableMap(
          e -> e.getKey().name(),
          e -> e.getValue().toString())));

  assetBlob.setBlobCreated(toOffsetDateTime(metrics.getCreationTime()));
  assetBlob.setCreatedBy(headers.get(CREATED_BY_HEADER));
  assetBlob.setCreatedByIp(headers.get(CREATED_BY_IP_HEADER));

  facet.stores().assetBlobStore.createAssetBlob(assetBlob);

  return assetBlob;
}
 
Example 2
Source File: FluentAssetImpl.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
private Blob makePermanent(final Blob tempBlob) {
  ImmutableMap.Builder<String, String> headerBuilder = ImmutableMap.builder();

  Map<String, String> tempHeaders = tempBlob.getHeaders();
  headerBuilder.put(REPO_NAME_HEADER, tempHeaders.get(REPO_NAME_HEADER));
  headerBuilder.put(BLOB_NAME_HEADER, asset.path());
  headerBuilder.put(CREATED_BY_HEADER, tempHeaders.get(CREATED_BY_HEADER));
  headerBuilder.put(CREATED_BY_IP_HEADER, tempHeaders.get(CREATED_BY_IP_HEADER));
  headerBuilder.put(CONTENT_TYPE_HEADER, facet.checkContentType(asset, tempBlob));

  return facet.stores().blobStore.copy(tempBlob.getId(), headerBuilder.build());
}