Package org.saidone.service.content
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.computeHash
(String nodeId, String algorithm) Computes the checksum of a node's content stored in GridFS using the provided algorithm.void
deleteNodeContent
(String nodeId) Removes the stored content associated with the given node identifier.getNodeContent
(String nodeId) Retrieves the content of a node stored in GridFS by node ID.
-
Constructor Details
-
GridFsContentService
public GridFsContentService()
-
-
Method Details
-
archiveNodeContent
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 aAnvDigestInputStream
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 interfaceContentService
- Parameters:
node
- the node whose content is to be archivedinputStream
- the input stream of the node's content to be saved and checksummed
-
getNodeContent
Retrieves the content of a node stored in GridFS by node ID.- Specified by:
getNodeContent
in interfaceContentService
- 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
Removes the stored content associated with the given node identifier.- Specified by:
deleteNodeContent
in interfaceContentService
- Parameters:
nodeId
- the id of the node whose content should be deleted
-
computeHash
Computes the checksum of a node's content stored in GridFS using the provided algorithm.- Specified by:
computeHash
in interfaceContentService
- Parameters:
nodeId
- identifier of the nodealgorithm
- name of the hash algorithm- Returns:
- the resulting hash string
-