Class InaTapeHelper

java.lang.Object
fr.gouv.vitam.storage.cold.server.util.InaTapeHelper

public class InaTapeHelper extends Object
Helper class for tape operations.
  • Constructor Details

  • Method Details

    • driveIdByIndex

      public static String driveIdByIndex(int driveIndex)
    • tryWriteAndUpdateDatabase

      public void tryWriteAndUpdateDatabase(long fileSize, int driveIndex, InaTapeHelper.ThrowingRunnable writeAction) throws Exception
      Executes a write atomically: validates capacity, runs the provided write action, then increments tape size. The entire sequence is synchronized to prevent race conditions between concurrent writes and load/unload.
      Throws:
      Exception
    • advanceDrivePosition

      public void advanceDrivePosition(int driveIndex) throws InaTapeProxyException
      Increments the position of the specified tape drive by one file.
      Parameters:
      driveIndex - the index of the tape drive to update
      Throws:
      InaTapeProxyException - if the drive model cannot be retrieved or saved
    • getTapeDriveModel

      public TapeDriveModel getTapeDriveModel(int driveIndex) throws InaTapeProxyServerException
      Retrieves a tape drive model by its index.
      Parameters:
      driveIndex - the drive index
      Returns:
      the tape drive model
      Throws:
      InaTapeProxyServerException - if the drive is not found
    • getTapeCatalogModel

      public TapeCatalogModel getTapeCatalogModel(String tapeCode) throws InaTapeProxyServerException
      Retrieves a tape catalog model by its tape code.
      Parameters:
      tapeCode - the tape code
      Returns:
      the tape catalog model
      Throws:
      InaTapeProxyServerException - if the tape is not found
    • sanityCheckPath

      public Path sanityCheckPath(String inputPath) throws InaTapeProxyBadRequestException
      Validates, normalizes, and secures a file path to prevent security vulnerabilities (Path Traversal). Also ensures that the path points to a regular file and not a directory.
      Parameters:
      inputPath - The raw file path provided as input.
      Returns:
      The secured, absolute, and normalized Path object.
      Throws:
      InaTapeProxyBadRequestException - If the path is invalid, malicious, or does not correspond to a file.