Package fr.gouv.vitam.worker.common
Interface HandlerIO
-
- All Superinterfaces:
java.lang.AutoCloseable
,VitamAutoCloseable
- All Known Implementing Classes:
HandlerIOImpl
public interface HandlerIO extends VitamAutoCloseable
Interface of HandlerIO for all Handlers
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addInIOParameters(java.util.List<IOParameter> list)
Add Input parametersvoid
addOutIOParameters(java.util.List<IOParameter> list)
Add Output parametersHandlerIO
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 resultboolean
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 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 asyncManagerjava.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 parametersjava.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 WorkspaceLogbookLifeCyclesClientHelper
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 inputjava.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 parameterscom.fasterxml.jackson.databind.JsonNode
getJsonFromWorkspace(java.lang.String jsonFilePath)
Retrieve a json file as aJsonNode
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 outputjava.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)
boolean
removeFolder(java.lang.String folderName)
Remove a specific foldervoid
reset()
Reset after each Actionvoid
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 Parametersvoid
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 Parametersvoid
transferJsonToWorkspace(java.lang.String collectionName, java.lang.String workspacePath, 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 interface fr.gouv.vitam.common.model.VitamAutoCloseable
close
-
-
-
-
Method Detail
-
addInIOParameters
void addInIOParameters(java.util.List<IOParameter> list)
Add Input parameters- Parameters:
list
-- Throws:
java.lang.IllegalArgumentException
- if an error occurs
-
addOutIOParameters
void addOutIOParameters(java.util.List<IOParameter> list)
Add Output parameters- Parameters:
list
-- Throws:
java.lang.IllegalArgumentException
- if an error occurs
-
reset
void reset()
Reset after each Action
-
getInput
java.util.List<java.lang.Object> getInput()
- Returns:
- list of input
-
getInput
java.lang.Object getInput(int rank)
Return one Object from input- Parameters:
rank
-- Returns:
- the rank-th object
-
getInput
<T> T getInput(int rank, java.lang.Class<T> type)
Return one Object casted to type from input- Parameters:
rank
-- Returns:
- the rank-th object
-
getOutput
java.util.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, java.lang.Object object) throws ProcessingException
- Throws:
ProcessingException
-
addOutputResult
HandlerIO addOutputResult(int rank, java.lang.Object object, boolean asyncIO) throws ProcessingException
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
java.lang.IllegalArgumentException
-
addOutputResult
HandlerIO addOutputResult(int rank, java.lang.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
java.lang.IllegalArgumentException
-
getContainerName
java.lang.String getContainerName()
- Returns:
- the container Name
-
getWorkerId
java.lang.String getWorkerId()
- Returns:
- the worker Id
-
getNewLocalFile
java.io.File getNewLocalFile(java.lang.String name)
- Parameters:
name
-- Returns:
- a File pointing to a local path in Tmp directory under protected Worker instance space
-
getUriList
java.util.List<java.net.URI> getUriList(java.lang.String containerName, java.lang.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, 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- Parameters:
outputNumber
- the number of outputArgumentsclasz
- the list of Class that should be in the InputParameters- Returns:
- true if everything ok
-
isExistingFileInWorkspace
boolean isExistingFileInWorkspace(java.lang.String workspacePath) throws ProcessingException
- Throws:
ProcessingException
-
transferFileToWorkspace
void transferFileToWorkspace(java.lang.String workspacePath, java.io.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(java.lang.String workspacePath, java.io.File sourceFile) throws ProcessingException
- Throws:
ProcessingException
-
transferInputStreamToWorkspace
void transferInputStreamToWorkspace(java.lang.String workspacePath, java.io.InputStream inputStream, java.nio.file.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
java.io.File getFileFromWorkspace(java.lang.String objectName) throws java.io.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:
java.io.IOException
ContentAddressableStorageNotFoundException
ContentAddressableStorageServerException
-
getFilesWithParamsFromWorkspace
java.util.Map<java.lang.String,java.lang.Long> getFilesWithParamsFromWorkspace(java.lang.String containerName, java.lang.String folderName) throws ProcessingException
get Map of File With Params From folder in Workspace- Parameters:
containerName
-folderName
-- Returns:
- Throws:
ProcessingException
-
getInputStreamFromWorkspace
java.io.InputStream getInputStreamFromWorkspace(java.lang.String objectName) throws java.io.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:
java.io.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(java.lang.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(java.lang.String collectionName, java.lang.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(java.lang.String container, java.lang.String folderName, java.lang.String archiveMimeType, java.io.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(java.lang.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(java.lang.String currentObjectId)
-
getWorkspaceClientFactory
WorkspaceClientFactory getWorkspaceClientFactory()
-
-