Package fr.gouv.vitam.worker.core.impl
Class HandlerIOImpl
java.lang.Object
fr.gouv.vitam.worker.core.impl.HandlerIOImpl
- All Implemented Interfaces:
VitamAutoCloseable,HandlerIO,AutoCloseable
Handler input and output parameter
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionHandlerIOImpl(WorkFlowExecutionContext workFlowExecutionContext, WorkspaceClientFactory workspaceClientFactory, LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory, String containerName, String workerId, List<String> objectIds) Constructor with workspaceClient, local root path he is used for test purposeHandlerIOImpl(WorkFlowExecutionContext workFlowExecutionContext, String containerName, String workerId, List<String> objectIds) Constructor with local root path -
Method Summary
Modifier and TypeMethodDescriptionvoidaddInIOParameters(List<IOParameter> list) Add Input parametersvoidaddOutIOParameters(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 resultbooleancheckHandlerIO(int outputNumber, List<Class<?>> clasz) Check if input and output have the very same number of elements and for Input the associated typesvoidclose()voidconsumeAnyEntityAndClose(javax.ws.rs.core.Response response) Consume any entity and close responsevoidenableAsync(boolean async) 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> TReturn 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.JsonNodegetJsonFromWorkspace(String jsonFilePath) Retrieve a json file as aJsonNodefrom the workspace.getNewLocalFile(String name) getOutput(int rank) Return one ProcessingUri from outputgetUriList(String containerName, String folderName) booleanisExistingFileInWorkspace(String workspacePath) voidClose the HandlerIO, including temporary files and directories at the end of the step Workflow execution, but do not close the WorkspaceClientbooleanremoveFolder(String folderName) Remove a specific foldervoidreset()Reset after each ActionvoidsetCurrentObjectId(String currentObjectId) voidtransferAtomicFileToWorkspace(String workspacePath, File sourceFile) voidtransferFileToWorkspace(String workspacePath, File sourceFile, boolean toDelete, boolean asyncIO) Helper to write a file to Workspace
To be used when not specified within the Output ParametersvoidtransferInputStreamToWorkspace(String workspacePath, InputStream inputStream, Path filePath, boolean asyncIO) Helper to write an InputStream to Workspace
To be used when not specified within the Output ParametersvoidtransferJsonToWorkspace(String collectionName, String objectName, com.fasterxml.jackson.databind.JsonNode jsonNode, boolean toDelete, boolean asyncIO) Helper to convert and write a file to Workspace
voidunzipInputStreamOnWorkspace(String container, String folderName, String archiveMimeType, InputStream uploadedInputStream, boolean asyncIO)
-
Field Details
-
NOT_CONFORM_PARAM
Not Conform Param- See Also:
-
-
Constructor Details
-
HandlerIOImpl
public HandlerIOImpl(WorkFlowExecutionContext workFlowExecutionContext, String containerName, String workerId, List<String> objectIds) Constructor with local root path- Parameters:
workFlowExecutionContext-containerName- the container nameworkerId- the worker idobjectIds-
-
HandlerIOImpl
public HandlerIOImpl(WorkFlowExecutionContext workFlowExecutionContext, WorkspaceClientFactory workspaceClientFactory, LogbookLifeCyclesClientFactory logbookLifeCyclesClientFactory, String containerName, String workerId, List<String> objectIds) Constructor with workspaceClient, local root path he is used for test purpose- Parameters:
workFlowExecutionContext-containerName- the container nameworkerId- the worker idobjectIds-
-
-
Method Details
-
getHelper
-
addInIOParameters
Description copied from interface:HandlerIOAdd Input parameters- Specified by:
addInIOParametersin interfaceHandlerIO
-
addOutIOParameters
Description copied from interface:HandlerIOAdd Output parameters- Specified by:
addOutIOParametersin interfaceHandlerIO
-
reset
public void reset()Description copied from interface:HandlerIOReset after each Action -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceVitamAutoCloseable
-
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
-
getInput
Description copied from interface:HandlerIOReturn one Object from input -
getInput
Description copied from interface:HandlerIOReturn one Object casted to type from input -
getFile
-
getOutput
-
getOutput
Description copied from interface:HandlerIOReturn one ProcessingUri from output -
addOutputResult
- Specified by:
addOutputResultin interfaceHandlerIO- Throws:
ProcessingException
-
addOutputResult
public HandlerIO addOutputResult(int rank, Object object, boolean asyncIO) throws ProcessingException Description copied from interface:HandlerIOAdd one output result (no delete)- Specified by:
addOutputResultin interfaceHandlerIO- 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
-
addOutputResult
public HandlerIO addOutputResult(int rank, Object object, boolean deleteLocal, boolean asyncIO) throws ProcessingException Description copied from interface:HandlerIOAdd one output result- Specified by:
addOutputResultin interfaceHandlerIO- 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
-
getContainerName
- Specified by:
getContainerNamein interfaceHandlerIO- Returns:
- the container Name
-
getWorkerId
- Specified by:
getWorkerIdin interfaceHandlerIO- Returns:
- the worker Id
-
getNewLocalFile
- Specified by:
getNewLocalFilein interfaceHandlerIO- Returns:
- a File pointing to a local path in Tmp directory under protected Worker instance space
-
checkHandlerIO
Description copied from interface:HandlerIOCheck if input and output have the very same number of elements and for Input the associated types- Specified by:
checkHandlerIOin interfaceHandlerIO- Parameters:
outputNumber- the number of outputArgumentsclasz- the list of Class that should be in the InputParameters- Returns:
- true if everything ok
-
isExistingFileInWorkspace
- Specified by:
isExistingFileInWorkspacein interfaceHandlerIO- Throws:
ProcessingException
-
transferFileToWorkspace
public void transferFileToWorkspace(String workspacePath, File sourceFile, boolean toDelete, boolean asyncIO) throws ProcessingException Description copied from interface:HandlerIOHelper to write a file to Workspace
To be used when not specified within the Output Parameters- Specified by:
transferFileToWorkspacein interfaceHandlerIO- 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
public void transferAtomicFileToWorkspace(String workspacePath, File sourceFile) throws ProcessingException - Specified by:
transferAtomicFileToWorkspacein interfaceHandlerIO- Throws:
ProcessingException
-
transferInputStreamToWorkspace
public void transferInputStreamToWorkspace(String workspacePath, InputStream inputStream, Path filePath, boolean asyncIO) throws ProcessingException Description copied from interface:HandlerIOHelper to write an InputStream to Workspace
To be used when not specified within the Output Parameters- Specified by:
transferInputStreamToWorkspacein interfaceHandlerIO- Parameters:
workspacePath- path within the workspath, without the container (implicit)inputStream- the source InputStream to writeasyncIO- asynchronously send to the workspace- Throws:
ProcessingException
-
getFileFromWorkspace
public File getFileFromWorkspace(String objectName) throws IOException, ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException Description copied from interface:HandlerIOHelper 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- Specified by:
getFileFromWorkspacein interfaceHandlerIO- Returns:
- file if found
- Throws:
IOExceptionContentAddressableStorageNotFoundExceptionContentAddressableStorageServerException
-
getInputStreamFromWorkspace
public InputStream getInputStreamFromWorkspace(String objectName) throws IOException, ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException Description copied from interface:HandlerIOHelper to get an InputStream (using local cache if possible) from Workspace
To be used when not specified within the Input parameters- Specified by:
getInputStreamFromWorkspacein interfaceHandlerIO- Returns:
- the InputStream
- Throws:
IOExceptionContentAddressableStorageNotFoundExceptionContentAddressableStorageServerException
-
consumeAnyEntityAndClose
public void consumeAnyEntityAndClose(javax.ws.rs.core.Response response) Description copied from interface:HandlerIOConsume any entity and close response- Specified by:
consumeAnyEntityAndClosein interfaceHandlerIO
-
getJsonFromWorkspace
public com.fasterxml.jackson.databind.JsonNode getJsonFromWorkspace(String jsonFilePath) throws ProcessingException Description copied from interface:HandlerIORetrieve a json file as aJsonNodefrom the workspace.- Specified by:
getJsonFromWorkspacein interfaceHandlerIO- Parameters:
jsonFilePath- path in workspace of the json File- Returns:
- JsonNode of the json file
- Throws:
ProcessingException- throws when error occurs
-
getUriList
- Specified by:
getUriListin interfaceHandlerIO- Returns:
- List
a list of uri of object in SIP folder - Throws:
ProcessingException
-
transferJsonToWorkspace
public void transferJsonToWorkspace(String collectionName, String objectName, com.fasterxml.jackson.databind.JsonNode jsonNode, boolean toDelete, boolean asyncIO) throws ProcessingException Description copied from interface:HandlerIOHelper to convert and write a file to Workspace
- Specified by:
transferJsonToWorkspacein interfaceHandlerIO- Parameters:
collectionName- : collection typeobjectName- 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
public void unzipInputStreamOnWorkspace(String container, String folderName, String archiveMimeType, InputStream uploadedInputStream, boolean asyncIO) throws ContentAddressableStorageException - Specified by:
unzipInputStreamOnWorkspacein interfaceHandlerIOasyncIO- asynchronously send and unzip file to/in the workspace- Throws:
ContentAddressableStorageException
-
enableAsync
Description copied from interface:HandlerIOIf true then start async manager, if false then waitEndOfTransfer and stop asyncManager- Specified by:
enableAsyncin interfaceHandlerIO- Throws:
WorkerspaceQueueException
-
removeFolder
Description copied from interface:HandlerIORemove a specific folder- Specified by:
removeFolderin interfaceHandlerIO- 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
- Specified by:
setCurrentObjectIdin interfaceHandlerIO
-
getFilesWithParamsFromWorkspace
public Map<String,Long> getFilesWithParamsFromWorkspace(String containerName, String folderName) throws ProcessingException Description copied from interface:HandlerIOget Map of File With Params From folder in Workspace- Specified by:
getFilesWithParamsFromWorkspacein interfaceHandlerIO- Returns:
- Throws:
ProcessingException
-
getLifeCyclesClientFactory
- Specified by:
getLifeCyclesClientFactoryin interfaceHandlerIO- Returns:
- the LogbookLifeCyclesClientFactory for the current execution context
-
getLifeCyclesClient
- Specified by:
getLifeCyclesClientin interfaceHandlerIO- Returns:
- the HandlerIO LifecycleClient
-
getWorkspaceClientFactory
- Specified by:
getWorkspaceClientFactoryin interfaceHandlerIO- Returns:
- the WorkspaceClientFactory for the current execution context
-
getWorkspaceClient
- Specified by:
getWorkspaceClientin interfaceHandlerIO- Returns:
- the WorkspaceClient for the current execution context
-
getMetaDataClientFactory
- Specified by:
getMetaDataClientFactoryin interfaceHandlerIO- Returns:
- the metadata client for the current execution context
-
getMetaDataClient
- Specified by:
getMetaDataClientin interfaceHandlerIO- Returns:
- the metadata client for the current execution context
-
getAdminManagementClientFactory
- Specified by:
getAdminManagementClientFactoryin interfaceHandlerIO- Returns:
- the metadata client for the current execution context
-
getAdminManagementClient
- Specified by:
getAdminManagementClientin interfaceHandlerIO- Returns:
- the metadata client for the current execution context
-
getBatchReportClientFactory
- Specified by:
getBatchReportClientFactoryin interfaceHandlerIO- Returns:
- the batch report client factory for the current execution context
-
getBatchReportClient
- Specified by:
getBatchReportClientin interfaceHandlerIO- Returns:
- the batch report client for the current execution context
-
getLogbookOperationsClientFactory
- Specified by:
getLogbookOperationsClientFactoryin interfaceHandlerIO- Returns:
- the logbook operations client factory for the current execution context
-
getLogbookOperationsClient
- Specified by:
getLogbookOperationsClientin interfaceHandlerIO- Returns:
- the logbook operations client for the current execution context
-
getStorageClientFactory
- Specified by:
getStorageClientFactoryin interfaceHandlerIO- Returns:
- the storage client factory for the current execution context
-
getStorageClient
- Specified by:
getStorageClientin interfaceHandlerIO- Returns:
- the storage client for the current execution context
-
getWorkFlowExecutionContext
- Specified by:
getWorkFlowExecutionContextin interfaceHandlerIO
-