Class GridFsContentService

java.lang.Object
org.saidone.service.content.GridFsContentService
All Implemented Interfaces:
ContentService

@Service @ConfigurationProperties(prefix="application.service.vault.storage") @ConditionalOnExpression("\'${application.service.vault.storage.impl:}\' == \'gridfs\'") public class GridFsContentService extends Object implements ContentService
ContentService implementation backed by MongoDB GridFS.

This class handles persisting node content streams as GridFS files and retrieving them on demand. Checksums are calculated during the archive operation and stored as metadata.

  • Constructor Details

    • GridFsContentService

      public GridFsContentService()
  • Method Details

    • archiveNodeContent

      public void archiveNodeContent(org.alfresco.core.model.Node node, InputStream inputStream)
      Archives the content of the given node by saving the content stream into a GridFS repository with associated metadata. The input stream is wrapped in a AnvDigestInputStream to compute a checksum using the configured algorithm during the save operation. After saving, the method updates the file metadata with both the algorithm name and the computed value.
      Specified by:
      archiveNodeContent in interface ContentService
      Parameters:
      node - the node whose content is to be archived
      inputStream - the input stream of the node's content to be saved and checksummed
    • getNodeContent

      public NodeContent getNodeContent(String nodeId)
      Retrieves the content of a node stored in GridFS by node ID.
      Specified by:
      getNodeContent in interface ContentService
      Parameters:
      nodeId - the ID of the node
      Returns:
      the NodeContent containing file name, content type, length and the content stream
      Throws:
      NodeNotFoundOnVaultException - if the node content is not found in the vault
    • deleteNodeContent

      public void deleteNodeContent(String nodeId)
      Removes the stored content associated with the given node identifier.
      Specified by:
      deleteNodeContent in interface ContentService
      Parameters:
      nodeId - the id of the node whose content should be deleted
    • computeHash

      public String computeHash(String nodeId, String algorithm)
      Computes the checksum of a node's content stored in GridFS using the provided algorithm.
      Specified by:
      computeHash in interface ContentService
      Parameters:
      nodeId - identifier of the node
      algorithm - name of the hash algorithm
      Returns:
      the resulting hash string