Class HandlerIOImpl

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String NOT_CONFORM_PARAM
      Not Conform Param
    • Constructor Summary

      Constructors 
      Constructor Description
      HandlerIOImpl​(WorkspaceClientFactory workspaceClientFactory, LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory, java.lang.String containerName, java.lang.String workerId, java.util.List<java.lang.String> objectIds)
      Constructor with workspaceClient, local root path he is used for test purpose
      HandlerIOImpl​(java.lang.String containerName, java.lang.String workerId, java.util.List<java.lang.String> objectIds)
      Constructor with local root path
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addInIOParameters​(java.util.List<IOParameter> list)
      Add Input parameters
      void addOutIOParameters​(java.util.List<IOParameter> list)
      Add Output parameters
      HandlerIO addOutputResult​(int rank, java.lang.Object object)  
      HandlerIO addOutputResult​(int rank, java.lang.Object object, boolean asyncIO)
      Add one output result (no delete)
      HandlerIO addOutputResult​(int rank, java.lang.Object object, boolean deleteLocal, boolean asyncIO)
      Add one output result
      boolean checkHandlerIO​(int outputNumber, java.util.List<java.lang.Class<?>> clasz)
      Check if input and output have the very same number of elements and for Input the associated types
      void close()  
      void consumeAnyEntityAndClose​(javax.ws.rs.core.Response response)
      Consume any entity and close response
      void enableAsync​(boolean async)
      If true then start async manager, if false then waitEndOfTransfer and stop asyncManager
      java.lang.String getContainerName()  
      java.io.File getFileFromWorkspace​(java.lang.String objectName)
      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
      java.util.Map<java.lang.String,​java.lang.Long> getFilesWithParamsFromWorkspace​(java.lang.String containerName, java.lang.String folderName)
      get Map of File With Params From folder in Workspace
      LogbookLifeCyclesClientHelper getHelper()  
      java.util.List<java.lang.Object> getInput()  
      java.lang.Object getInput​(int rank)
      Return one Object from input
      <T> T getInput​(int rank, java.lang.Class<T> type)
      Return one Object casted to type from input
      java.io.InputStream getInputStreamFromWorkspace​(java.lang.String objectName)
      Helper to get an InputStream (using local cache if possible) from Workspace

      To be used when not specified within the Input parameters
      com.fasterxml.jackson.databind.JsonNode getJsonFromWorkspace​(java.lang.String jsonFilePath)
      Retrieve a json file as a JsonNode from the workspace.
      LogbookLifeCyclesClient getLifecyclesClient()  
      java.io.File getNewLocalFile​(java.lang.String name)  
      java.util.List<ProcessingUri> getOutput()  
      ProcessingUri getOutput​(int rank)
      Return one ProcessingUri from output
      java.util.List<java.net.URI> getUriList​(java.lang.String containerName, java.lang.String folderName)  
      java.lang.String getWorkerId()  
      WorkspaceClientFactory getWorkspaceClientFactory()  
      boolean isExistingFileInWorkspace​(java.lang.String workspacePath)  
      void partialClose()
      Close the HandlerIO, including temporary files and directories at the end of the step Workflow execution, but do not close the WorkspaceClient
      boolean removeFolder​(java.lang.String folderName)
      Remove a specific folder
      void reset()
      Reset after each Action
      void setCurrentObjectId​(java.lang.String currentObjectId)  
      void transferAtomicFileToWorkspace​(java.lang.String workspacePath, java.io.File sourceFile)  
      void transferFileToWorkspace​(java.lang.String workspacePath, java.io.File sourceFile, boolean toDelete, boolean asyncIO)
      Helper to write a file to Workspace

      To be used when not specified within the Output Parameters
      void transferInputStreamToWorkspace​(java.lang.String workspacePath, java.io.InputStream inputStream, java.nio.file.Path filePath, boolean asyncIO)
      Helper to write an InputStream to Workspace

      To be used when not specified within the Output Parameters
      void transferJsonToWorkspace​(java.lang.String collectionName, java.lang.String objectName, com.fasterxml.jackson.databind.JsonNode jsonNode, boolean toDelete, boolean asyncIO)
      Helper to convert and write a file to Workspace

      void unzipInputStreamOnWorkspace​(java.lang.String container, java.lang.String folderName, java.lang.String archiveMimeType, java.io.InputStream uploadedInputStream, boolean asyncIO)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • NOT_CONFORM_PARAM

        public static final java.lang.String NOT_CONFORM_PARAM
        Not Conform Param
        See Also:
        Constant Field Values
    • Constructor Detail

      • HandlerIOImpl

        public HandlerIOImpl​(java.lang.String containerName,
                             java.lang.String workerId,
                             java.util.List<java.lang.String> objectIds)
        Constructor with local root path
        Parameters:
        containerName - the container name
        workerId - the worker id
        objectIds -
      • HandlerIOImpl

        public HandlerIOImpl​(WorkspaceClientFactory workspaceClientFactory,
                             LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory,
                             java.lang.String containerName,
                             java.lang.String workerId,
                             java.util.List<java.lang.String> objectIds)
        Constructor with workspaceClient, local root path he is used for test purpose
        Parameters:
        workspaceClientFactory -
        logbookLifeCyclesClientFactory -
        containerName - the container name
        workerId - the worker id
        objectIds -
    • Method Detail

      • reset

        public void reset()
        Description copied from interface: HandlerIO
        Reset after each Action
        Specified by:
        reset in interface HandlerIO
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface VitamAutoCloseable
      • partialClose

        public void partialClose()
        Close the HandlerIO, including temporary files and directories at the end of the step Workflow execution, but do not close the WorkspaceClient
      • getInput

        public java.util.List<java.lang.Object> getInput()
        Specified by:
        getInput in interface HandlerIO
        Returns:
        list of input
      • getInput

        public java.lang.Object getInput​(int rank)
        Description copied from interface: HandlerIO
        Return one Object from input
        Specified by:
        getInput in interface HandlerIO
        Returns:
        the rank-th object
      • getInput

        public <T> T getInput​(int rank,
                              java.lang.Class<T> type)
        Description copied from interface: HandlerIO
        Return one Object casted to type from input
        Specified by:
        getInput in interface HandlerIO
        Returns:
        the rank-th object
      • getOutput

        public ProcessingUri getOutput​(int rank)
        Description copied from interface: HandlerIO
        Return one ProcessingUri from output
        Specified by:
        getOutput in interface HandlerIO
        Returns:
        the rank-th ProcessingUri
      • addOutputResult

        public HandlerIO addOutputResult​(int rank,
                                         java.lang.Object object,
                                         boolean asyncIO)
                                  throws ProcessingException
        Description copied from interface: HandlerIO
        Add one output result (no delete)
        Specified by:
        addOutputResult in interface HandlerIO
        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
      • addOutputResult

        public HandlerIO addOutputResult​(int rank,
                                         java.lang.Object object,
                                         boolean deleteLocal,
                                         boolean asyncIO)
                                  throws ProcessingException
        Description copied from interface: HandlerIO
        Add one output result
        Specified by:
        addOutputResult in interface HandlerIO
        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
      • getContainerName

        public java.lang.String getContainerName()
        Specified by:
        getContainerName in interface HandlerIO
        Returns:
        the container Name
      • getWorkerId

        public java.lang.String getWorkerId()
        Specified by:
        getWorkerId in interface HandlerIO
        Returns:
        the worker Id
      • getNewLocalFile

        public java.io.File getNewLocalFile​(java.lang.String name)
        Specified by:
        getNewLocalFile in interface HandlerIO
        Returns:
        a File pointing to a local path in Tmp directory under protected Worker instance space
      • checkHandlerIO

        public boolean checkHandlerIO​(int outputNumber,
                                      java.util.List<java.lang.Class<?>> clasz)
        Description copied from interface: HandlerIO
        Check if input and output have the very same number of elements and for Input the associated types
        Specified by:
        checkHandlerIO in interface HandlerIO
        Parameters:
        outputNumber - the number of outputArguments
        clasz - the list of Class that should be in the InputParameters
        Returns:
        true if everything ok
      • transferFileToWorkspace

        public void transferFileToWorkspace​(java.lang.String workspacePath,
                                            java.io.File sourceFile,
                                            boolean toDelete,
                                            boolean asyncIO)
                                     throws ProcessingException
        Description copied from interface: HandlerIO
        Helper to write a file to Workspace

        To be used when not specified within the Output Parameters
        Specified by:
        transferFileToWorkspace in interface HandlerIO
        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
      • transferInputStreamToWorkspace

        public void transferInputStreamToWorkspace​(java.lang.String workspacePath,
                                                   java.io.InputStream inputStream,
                                                   java.nio.file.Path filePath,
                                                   boolean asyncIO)
                                            throws ProcessingException
        Description copied from interface: HandlerIO
        Helper to write an InputStream to Workspace

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

        public void consumeAnyEntityAndClose​(javax.ws.rs.core.Response response)
        Description copied from interface: HandlerIO
        Consume any entity and close response
        Specified by:
        consumeAnyEntityAndClose in interface HandlerIO
      • getJsonFromWorkspace

        public com.fasterxml.jackson.databind.JsonNode getJsonFromWorkspace​(java.lang.String jsonFilePath)
                                                                     throws ProcessingException
        Description copied from interface: HandlerIO
        Retrieve a json file as a JsonNode from the workspace.
        Specified by:
        getJsonFromWorkspace in interface HandlerIO
        Parameters:
        jsonFilePath - path in workspace of the json File
        Returns:
        JsonNode of the json file
        Throws:
        ProcessingException - throws when error occurs
      • transferJsonToWorkspace

        public void transferJsonToWorkspace​(java.lang.String collectionName,
                                            java.lang.String objectName,
                                            com.fasterxml.jackson.databind.JsonNode jsonNode,
                                            boolean toDelete,
                                            boolean asyncIO)
                                     throws ProcessingException
        Description copied from interface: HandlerIO
        Helper to convert and write a file to Workspace

        Specified by:
        transferJsonToWorkspace in interface HandlerIO
        Parameters:
        collectionName - : collection type
        objectName - 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
      • setCurrentObjectId

        public void setCurrentObjectId​(java.lang.String currentObjectId)
        Specified by:
        setCurrentObjectId in interface HandlerIO