private String calculateIntegrity(final Asset asset, final Blob blob, final String algorithm) { try { HashCode hash; if (algorithm.equalsIgnoreCase(SHA1.name())) { hash = hash(SHA1, blob.getInputStream()); } else { hash = hash(SHA512, blob.getInputStream()); } return algorithm + "-" + Base64.getEncoder().encodeToString(hash.asBytes()); } catch (IOException e) { log.error("Failed to calculate hash for asset {}", asset.name(), e); } return ""; } }
@TransactionalStoreMetadata protected void doCreateAssetFromBlob(final RestoreBlobData blobData, final T restoreData, final Blob blob) throws IOException { List<HashAlgorithm> hashTypes = getHashAlgorithms(); AssetBlob assetBlob = new AssetBlob(nodeAccess, blobStoreManager.get(blobData.getBlobStoreName()), blobStore -> blob, blobData.getProperty(HEADER_PREFIX + CONTENT_TYPE_HEADER), hash(hashTypes, blob.getInputStream()), true); createAssetFromBlob(assetBlob, restoreData); }