Package org.saidone.service
Class VaultService
java.lang.Object
org.saidone.component.BaseComponent
org.saidone.service.VaultService
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
Service responsible for archiving, restoring and managing nodes in the vault.
It interacts with Alfresco to retrieve nodes and their binaries while
persisting metadata and content through the configured
NodeService
and ContentService
implementations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
archiveNode
(String nodeId) Archives a node by its ID.void
doubleCheck
(String nodeId) Performs a consistency check by comparing the cryptographic hashes of a node's content retrieved from both Alfresco and the vault storage using the specified algorithm.org.alfresco.core.model.Node
Retrieves the node metadata by node ID.restoreNode
(String nodeId, boolean restorePermissions) Restores a node from the vault back to Alfresco.Methods inherited from class org.saidone.component.BaseComponent
init, setApplicationContext, shutDown, stop
-
Constructor Details
-
VaultService
public VaultService()
-
-
Method Details
-
archiveNode
Archives a node by its ID.Retrieves the node and its content from Alfresco, stores metadata and binaries through the configured services with checksum information, optionally verifies the checksum and finally deletes the source node from Alfresco.
- Parameters:
nodeId
- the ID of the node to archive- Throws:
NodeNotFoundOnAlfrescoException
- if the node is not found in AlfrescoVaultException
- if any error occurs during archiving, including rollback
-
getNode
public org.alfresco.core.model.Node getNode(String nodeId) throws com.fasterxml.jackson.core.JsonProcessingException Retrieves the node metadata by node ID.- Parameters:
nodeId
- the ID of the node- Returns:
- the Alfresco Node object
- Throws:
NodeNotFoundOnVaultException
- if the node is not found in the vaultcom.fasterxml.jackson.core.JsonProcessingException
- if there is an error processing the node metadata JSON
-
restoreNode
public String restoreNode(String nodeId, boolean restorePermissions) throws com.fasterxml.jackson.core.JsonProcessingException Restores a node from the vault back to Alfresco.Restores node metadata and content, optionally restoring permissions, and marks the node as restored in the vault.
- Parameters:
nodeId
- the ID of the node to restorerestorePermissions
- whether to restore permissions along with the node- Returns:
- the new node ID assigned by Alfresco after restoration
- Throws:
NodeNotFoundOnVaultException
- if the node is not found in the vaultcom.fasterxml.jackson.core.JsonProcessingException
- if there is an error processing the node metadata JSON
-
doubleCheck
Performs a consistency check by comparing the cryptographic hashes of a node's content retrieved from both Alfresco and the vault storage using the specified algorithm. If the hashes match, a successful comparison is logged. If a mismatch is detected, aHashesMismatchException
is thrown. Any exception occurring during hash computation is wrapped and rethrown as aVaultException
.- Parameters:
nodeId
- the unique identifier of the node whose content will be checked- Throws:
HashesMismatchException
- if the computed hashes from Alfresco and the vault do not matchVaultException
- if any error occurs during hash calculation or comparison
-