Package fr.gouv.vitam.worker.common
Interface HandlerIO
- All Superinterfaces:
AutoCloseable
,VitamAutoCloseable
- All Known Implementing Classes:
HandlerIOImpl
Interface of HandlerIO for all Handlers
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addInIOParameters
(List<IOParameter> list) Add Input parametersvoid
addOutIOParameters
(List<IOParameter> list) Add Output parametersaddOutputResult
(int rank, Object object) addOutputResult
(int rank, Object object, boolean asyncIO) Add one output result (no delete)addOutputResult
(int rank, Object object, boolean deleteLocal, boolean asyncIO) Add one output resultboolean
checkHandlerIO
(int outputNumber, List<Class<?>> clasz) Check if input and output have the very same number of elements and for Input the associated typesvoid
consumeAnyEntityAndClose
(javax.ws.rs.core.Response response) Consume any entity and close responsevoid
enableAsync
(boolean asyncIo) If true then start async manager, if false then waitEndOfTransfer and stop asyncManagergetFile
(int rank) getFileFromWorkspace
(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 parametersgetFilesWithParamsFromWorkspace
(String containerName, String folderName) get Map of File With Params From folder in WorkspacegetInput()
getInput
(int rank) Return one Object from input<T> T
Return one Object casted to type from inputgetInputStreamFromWorkspace
(String objectName) Helper to get an InputStream (using local cache if possible) from Workspace
To be used when not specified within the Input parameterscom.fasterxml.jackson.databind.JsonNode
getJsonFromWorkspace
(String jsonFilePath) Retrieve a json file as aJsonNode
from the workspace.getNewLocalFile
(String name) getOutput
(int rank) Return one ProcessingUri from outputgetUriList
(String containerName, String folderName) boolean
isExistingFileInWorkspace
(String workspacePath) boolean
removeFolder
(String folderName) Remove a specific foldervoid
reset()
Reset after each Actionvoid
setCurrentObjectId
(String currentObjectId) void
transferAtomicFileToWorkspace
(String workspacePath, File sourceFile) void
transferFileToWorkspace
(String workspacePath, File sourceFile, boolean toDelete, boolean asyncIO) Helper to write a file to Workspace
To be used when not specified within the Output Parametersvoid
transferInputStreamToWorkspace
(String workspacePath, InputStream inputStream, Path filePath, boolean asyncIO) Helper to write an InputStream to Workspace
To be used when not specified within the Output Parametersvoid
transferJsonToWorkspace
(String collectionName, String workspacePath, com.fasterxml.jackson.databind.JsonNode jsonNode, boolean toDelete, boolean asyncIO) Helper to convert and write a file to Workspace
void
unzipInputStreamOnWorkspace
(String container, String folderName, String archiveMimeType, InputStream uploadedInputStream, boolean asyncIO) Methods inherited from interface fr.gouv.vitam.common.model.VitamAutoCloseable
close
-
Method Details
-
addInIOParameters
Add Input parameters- Parameters:
list
-- Throws:
IllegalArgumentException
- if an error occurs
-
addOutIOParameters
Add Output parameters- Parameters:
list
-- Throws:
IllegalArgumentException
- if an error occurs
-
reset
void reset()Reset after each Action -
getInput
- Returns:
- list of input
-
getInput
Return one Object from input- Parameters:
rank
-- Returns:
- the rank-th object
-
getInput
Return one Object casted to type from input- Parameters:
rank
-- Returns:
- the rank-th object
-
getFile
-
getOutput
List<ProcessingUri> getOutput()- Returns:
- list of output
-
getOutput
Return one ProcessingUri from output- Parameters:
rank
-- Returns:
- the rank-th ProcessingUri
-
addOutputResult
- Throws:
ProcessingException
-
addOutputResult
Add one output result (no delete)- Parameters:
rank
- the position in the outputobject
- 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 outputobject
- 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 onlyasyncIO
- 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
- Parameters:
name
-- Returns:
- a File pointing to a local path in Tmp directory under protected Worker instance space
-
getUriList
- Parameters:
containerName
-folderName
-- Returns:
- List
a list of uri of object in SIP folder - Throws:
ProcessingException
-
checkHandlerIO
Check if input and output have the very same number of elements and for Input the associated types- Parameters:
outputNumber
- the number of outputArgumentsclasz
- the list of Class that should be in the InputParameters- Returns:
- true if everything ok
-
isExistingFileInWorkspace
- 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 writetoDelete
- if True, will delete the local fileasyncIO
- 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 writeasyncIO
- asynchronously send to the workspace- Throws:
ProcessingException
-
getFileFromWorkspace
File getFileFromWorkspace(String objectName) throws IOException, ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException 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
InputStream getInputStreamFromWorkspace(String objectName) throws IOException, ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException 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 aJsonNode
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
LogbookLifeCyclesClientHelper 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 typeworkspacePath
- path within the workspacepath, without the container (implicit)jsonNode
- the json file to writetoDelete
- if True, will delete the local fileasyncIO
- 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
If true then start async manager, if false then waitEndOfTransfer and stop asyncManager- Parameters:
asyncIo
-- Throws:
WorkerspaceQueueException
-
removeFolder
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
-
getWorkspaceClientFactory
WorkspaceClientFactory getWorkspaceClientFactory()
-