Interface HandlerIO

All Superinterfaces:
AutoCloseable, VitamAutoCloseable
All Known Implementing Classes:
HandlerIOImpl

public interface HandlerIO extends VitamAutoCloseable
Interface of HandlerIO for all Handlers
  • Method Details

    • addInIOParameters

      void addInIOParameters(List<IOParameter> list)
      Add Input parameters
      Parameters:
      list -
      Throws:
      IllegalArgumentException - if an error occurs
    • addOutIOParameters

      void addOutIOParameters(List<IOParameter> list)
      Add Output parameters
      Parameters:
      list -
      Throws:
      IllegalArgumentException - if an error occurs
    • reset

      void reset()
      Reset after each Action
    • getInput

      List<Object> getInput()
      Returns:
      list of input
    • getInput

      Object getInput(int rank)
      Return one Object from input
      Parameters:
      rank -
      Returns:
      the rank-th object
    • getInput

      <T> T getInput(int rank, Class<T> type)
      Return one Object casted to type from input
      Parameters:
      rank -
      Returns:
      the rank-th object
    • getFile

      File getFile(int rank)
    • getOutput

      List<ProcessingUri> getOutput()
      Returns:
      list of output
    • getOutput

      ProcessingUri getOutput(int rank)
      Return one ProcessingUri from output
      Parameters:
      rank -
      Returns:
      the rank-th ProcessingUri
    • addOutputResult

      HandlerIO addOutputResult(int rank, Object object) throws ProcessingException
      Throws:
      ProcessingException
    • addOutputResult

      HandlerIO addOutputResult(int rank, Object object, boolean asyncIO) throws ProcessingException
      Add one output result (no delete)
      Parameters:
      rank - the position in the output
      object - the result to store (WORKSPACE to workspace and must be a File, MEMORY to memory whatever it is)
      asyncIO - asynchronously send to the workspace
      Returns:
      this
      Throws:
      ProcessingException
      IllegalArgumentException
    • addOutputResult

      HandlerIO addOutputResult(int rank, Object object, boolean deleteLocal, boolean asyncIO) throws ProcessingException
      Add one output result
      Parameters:
      rank - the position in the output
      object - the result to store (WORKSPACE to workspace and must be a File, MEMORY to memory whatever it is)
      deleteLocal - if true, will delete the local file in case of WORKSPACE only
      asyncIO - asynchronously send to the workspace
      Returns:
      this
      Throws:
      ProcessingException
      IllegalArgumentException
    • getContainerName

      String getContainerName()
      Returns:
      the container Name
    • getWorkerId

      String getWorkerId()
      Returns:
      the worker Id
    • getNewLocalFile

      File getNewLocalFile(String name)
      Parameters:
      name -
      Returns:
      a File pointing to a local path in Tmp directory under protected Worker instance space
    • getUriList

      List<URI> getUriList(String containerName, String folderName) throws ProcessingException
      Parameters:
      containerName -
      folderName -
      Returns:
      List a list of uri of object in SIP folder
      Throws:
      ProcessingException
    • checkHandlerIO

      boolean checkHandlerIO(int outputNumber, List<Class<?>> clasz)
      Check if input and output have the very same number of elements and for Input the associated types
      Parameters:
      outputNumber - the number of outputArguments
      clasz - the list of Class that should be in the InputParameters
      Returns:
      true if everything ok
    • isExistingFileInWorkspace

      boolean isExistingFileInWorkspace(String workspacePath) throws ProcessingException
      Throws:
      ProcessingException
    • transferFileToWorkspace

      void transferFileToWorkspace(String workspacePath, File sourceFile, boolean toDelete, boolean asyncIO) throws ProcessingException
      Helper to write a file to Workspace

      To be used when not specified within the Output Parameters
      Parameters:
      workspacePath - path within the workspath, without the container (implicit)
      sourceFile - the source file to write
      toDelete - if True, will delete the local file
      asyncIO - asynchronously send to the workspace
      Throws:
      ProcessingException
    • transferAtomicFileToWorkspace

      void transferAtomicFileToWorkspace(String workspacePath, File sourceFile) throws ProcessingException
      Throws:
      ProcessingException
    • transferInputStreamToWorkspace

      void transferInputStreamToWorkspace(String workspacePath, InputStream inputStream, Path filePath, boolean asyncIO) throws ProcessingException
      Helper to write an InputStream to Workspace

      To be used when not specified within the Output Parameters
      Parameters:
      workspacePath - path within the workspath, without the container (implicit)
      inputStream - the source InputStream to write
      asyncIO - asynchronously send to the workspace
      Throws:
      ProcessingException
    • getFileFromWorkspace

      Helper to load a file from Workspace (or local cache) and save it into local cache.

      To be used when not specified within the Input parameters
      Parameters:
      objectName -
      Returns:
      file if found
      Throws:
      IOException
      ContentAddressableStorageNotFoundException
      ContentAddressableStorageServerException
    • getFilesWithParamsFromWorkspace

      Map<String,Long> getFilesWithParamsFromWorkspace(String containerName, String folderName) throws ProcessingException
      get Map of File With Params From folder in Workspace
      Parameters:
      containerName -
      folderName -
      Returns:
      Throws:
      ProcessingException
    • getInputStreamFromWorkspace

      Helper to get an InputStream (using local cache if possible) from Workspace

      To be used when not specified within the Input parameters
      Parameters:
      objectName -
      Returns:
      the InputStream
      Throws:
      IOException
      ContentAddressableStorageNotFoundException
      ContentAddressableStorageServerException
    • consumeAnyEntityAndClose

      void consumeAnyEntityAndClose(javax.ws.rs.core.Response response)
      Consume any entity and close response
      Parameters:
      response -
    • getJsonFromWorkspace

      com.fasterxml.jackson.databind.JsonNode getJsonFromWorkspace(String jsonFilePath) throws ProcessingException
      Retrieve a json file as a JsonNode from the workspace.
      Parameters:
      jsonFilePath - path in workspace of the json File
      Returns:
      JsonNode of the json file
      Throws:
      ProcessingException - throws when error occurs
    • getLifecyclesClient

      LogbookLifeCyclesClient getLifecyclesClient()
      Returns:
      the HandlerIO LifecycleClient
    • getHelper

      Returns:
      the helper for bulk lifecycle for LifecyclesClient
    • transferJsonToWorkspace

      void transferJsonToWorkspace(String collectionName, String workspacePath, com.fasterxml.jackson.databind.JsonNode jsonNode, boolean toDelete, boolean asyncIO) throws ProcessingException
      Helper to convert and write a file to Workspace

      Parameters:
      collectionName - : collection type
      workspacePath - path within the workspacepath, without the container (implicit)
      jsonNode - the json file to write
      toDelete - if True, will delete the local file
      asyncIO - asynchronously send to the workspace
      Throws:
      ProcessingException
    • unzipInputStreamOnWorkspace

      void unzipInputStreamOnWorkspace(String container, String folderName, String archiveMimeType, InputStream uploadedInputStream, boolean asyncIO) throws ContentAddressableStorageException
      Parameters:
      container -
      folderName -
      archiveMimeType -
      uploadedInputStream -
      asyncIO - asynchronously send and unzip file to/in the workspace
      Throws:
      ContentAddressableStorageException
    • enableAsync

      void enableAsync(boolean asyncIo) throws WorkerspaceQueueException
      If true then start async manager, if false then waitEndOfTransfer and stop asyncManager
      Parameters:
      asyncIo -
      Throws:
      WorkerspaceQueueException
    • removeFolder

      boolean removeFolder(String folderName) throws ContentAddressableStorageException
      Remove a specific folder
      Parameters:
      folderName - the folderName to delete
      Returns:
      true if the folder was removed, false if it does not exist
      Throws:
      ContentAddressableStorageException - when storage error occurs
    • setCurrentObjectId

      void setCurrentObjectId(String currentObjectId)
    • getWorkspaceClientFactory

      WorkspaceClientFactory getWorkspaceClientFactory()