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 TypeMethodDescriptionvoidarchiveNodeContent(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.voiddeleteNodeContent(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.getNodeContentInfo(String nodeId) Retrieves metadata information about a node's content stored in GridFS.
-
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 aAnvDigestInputStreamto 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:
archiveNodeContentin 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:
getNodeContentin interfaceContentService- Parameters:
nodeId- the ID of the node- Returns:
- the
NodeContentStreamcontaining file name, content type, length and the content stream - Throws:
NodeNotFoundOnVaultException- if the node content is not found in the vault
-
getNodeContentInfo
Retrieves metadata information about a node's content stored in GridFS.- Specified by:
getNodeContentInfoin interfaceContentService- Parameters:
nodeId- identifier of the node- Returns:
- a
NodeContentInfodescribing the stored content - Throws:
NodeNotFoundOnVaultException- if the node content cannot be found
-
deleteNodeContent
Removes the stored content associated with the given node identifier.- Specified by:
deleteNodeContentin 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:
computeHashin interfaceContentService- Parameters:
nodeId- identifier of the nodealgorithm- name of the hash algorithm- Returns:
- the resulting hash string
-