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 public class VaultService extends BaseComponent
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 Details

    • VaultService

      public VaultService()
  • Method Details

    • archiveNode

      public void archiveNode(String nodeId)
      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 Alfresco
      VaultException - 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 vault
      com.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 restore
      restorePermissions - 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 vault
      com.fasterxml.jackson.core.JsonProcessingException - if there is an error processing the node metadata JSON
    • doubleCheck

      public 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. If the hashes match, a successful comparison is logged. If a mismatch is detected, a HashesMismatchException is thrown. Any exception occurring during hash computation is wrapped and rethrown as a VaultException.
      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 match
      VaultException - if any error occurs during hash calculation or comparison