public class HandlerIOImpl extends Object implements HandlerIO, VitamAutoCloseable
| Modifier and Type | Field and Description |
|---|---|
static String |
NOT_CONFORM_PARAM
Not Conform Param
|
static String |
NOT_ENOUGH_PARAM
Not Enough Param
|
| Constructor and Description |
|---|
HandlerIOImpl(String containerName,
String workerId)
Constructor with local root path
|
HandlerIOImpl(WorkspaceClient workspaceClient,
String containerName,
String workerId)
Constructor with workspaceClient, local root path he is used for test purpose
|
| Modifier and Type | Method and Description |
|---|---|
void |
addInIOParameters(List<IOParameter> list)
Add Input parameters
|
HandlerIO |
addOuputResult(int rank,
Object object,
boolean asyncIO)
Add one output result (no delete)
|
HandlerIO |
addOuputResult(int rank,
Object object,
boolean deleteLocal,
boolean asyncIO)
Add one output result
|
void |
addOutIOParameters(List<IOParameter> list)
Add Output parameters
|
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
|
void |
close() |
void |
consumeAnyEntityAndClose(javax.ws.rs.core.Response response)
Consume any entity and close response
|
boolean |
deleteLocalFile(String objectName)
Helper to delete a local file
To be used when not specified within the Input/Output parameters |
void |
enableAsync(boolean async)
If true then start async manager, if false then waitEndOfTransfer and stop asyncManager
|
String |
getContainerName() |
File |
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 parameters |
LogbookLifeCyclesClientHelper |
getHelper() |
List<Object> |
getInput() |
Object |
getInput(int rank)
Return one Object from input
|
InputStream |
getInputStreamFromWorkspace(String objectName)
Helper to get an InputStream (using local cache if possible) from Workspace
To be used when not specified within the Input parameters |
javax.ws.rs.core.Response |
getInputStreamNoCachedFromWorkspace(String objectName)
Helper to get an InputStream (without cache) from Workspace
To be used when not specified within the Input parameters |
com.fasterxml.jackson.databind.JsonNode |
getJsonFromWorkspace(String jsonFilePath)
Retrieve a json file as a
JsonNode from the workspace. |
LogbookLifeCyclesClient |
getLifecyclesClient() |
File |
getLocalPathRoot() |
File |
getNewLocalFile(String name) |
List<ProcessingUri> |
getOutput() |
ProcessingUri |
getOutput(int rank)
Return one ProcessingUri from output
|
List<URI> |
getUriList(String containerName,
String folderName) |
String |
getWorkerId() |
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(String folderName)
Remove a specific folder
|
void |
reset()
Reset after each Action
|
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 Parameters |
void |
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 Parameters |
void |
transferJsonToWorkspace(String collectionName,
String objectName,
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) |
void |
zipWorkspace(String outputFile,
String... inputFiles)
compress list of file or directory in a specific output file
|
public static final String NOT_ENOUGH_PARAM
public static final String NOT_CONFORM_PARAM
public HandlerIOImpl(String containerName, String workerId)
containerName - the container nameworkerId - the worker idpublic HandlerIOImpl(WorkspaceClient workspaceClient, String containerName, String workerId)
workspaceClient - containerName - the container nameworkerId - the worker idpublic LogbookLifeCyclesClient getLifecyclesClient()
getLifecyclesClient in interface HandlerIOpublic LogbookLifeCyclesClientHelper getHelper()
public void addInIOParameters(List<IOParameter> list)
HandlerIOaddInIOParameters in interface HandlerIOpublic void addOutIOParameters(List<IOParameter> list)
HandlerIOaddOutIOParameters in interface HandlerIOpublic void reset()
HandlerIOpublic void close()
close in interface VitamAutoCloseableclose in interface AutoCloseablepublic void partialClose()
public Object getInput(int rank)
HandlerIOpublic List<ProcessingUri> getOutput()
public ProcessingUri getOutput(int rank)
HandlerIOpublic HandlerIO addOuputResult(int rank, Object object, boolean asyncIO) throws ProcessingException
HandlerIOaddOuputResult in interface HandlerIOrank - 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 workspaceProcessingExceptionpublic HandlerIO addOuputResult(int rank, Object object, boolean deleteLocal, boolean asyncIO) throws ProcessingException
HandlerIOaddOuputResult in interface HandlerIOrank - 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 workspaceProcessingExceptionpublic String getContainerName()
getContainerName in interface HandlerIOpublic String getWorkerId()
getWorkerId in interface HandlerIOpublic File getLocalPathRoot()
getLocalPathRoot in interface HandlerIOpublic File getNewLocalFile(String name)
getNewLocalFile in interface HandlerIOpublic boolean checkHandlerIO(int outputNumber,
List<Class<?>> clasz)
HandlerIOcheckHandlerIO in interface HandlerIOoutputNumber - the number of outputArgumentsclasz - the list of Class that should be in the InputParameterspublic void transferFileToWorkspace(String workspacePath, File sourceFile, boolean toDelete, boolean asyncIO) throws ProcessingException
HandlerIOtransferFileToWorkspace in interface HandlerIOworkspacePath - 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 workspaceProcessingExceptionpublic void transferInputStreamToWorkspace(String workspacePath, InputStream inputStream, Path filePath, boolean asyncIO) throws ProcessingException
HandlerIOtransferInputStreamToWorkspace in interface HandlerIOworkspacePath - path within the workspath, without the container (implicit)inputStream - the source InputStream to writeasyncIO - asynchronously send to the workspaceProcessingExceptionpublic File getFileFromWorkspace(String objectName) throws IOException, ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException
HandlerIOgetFileFromWorkspace in interface HandlerIOIOExceptionContentAddressableStorageNotFoundExceptionContentAddressableStorageServerExceptionpublic InputStream getInputStreamFromWorkspace(String objectName) throws IOException, ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException
HandlerIOgetInputStreamFromWorkspace in interface HandlerIOIOExceptionContentAddressableStorageNotFoundExceptionContentAddressableStorageServerExceptionpublic javax.ws.rs.core.Response getInputStreamNoCachedFromWorkspace(String objectName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException
HandlerIOgetInputStreamNoCachedFromWorkspace in interface HandlerIOContentAddressableStorageNotFoundExceptionContentAddressableStorageServerExceptionpublic void consumeAnyEntityAndClose(javax.ws.rs.core.Response response)
HandlerIOconsumeAnyEntityAndClose in interface HandlerIOpublic com.fasterxml.jackson.databind.JsonNode getJsonFromWorkspace(String jsonFilePath) throws ProcessingException
HandlerIOJsonNode from the workspace.getJsonFromWorkspace in interface HandlerIOjsonFilePath - path in workspace of the json FileProcessingException - throws when error occurspublic boolean deleteLocalFile(String objectName)
HandlerIOdeleteLocalFile in interface HandlerIOpublic List<URI> getUriList(String containerName, String folderName) throws ProcessingException
getUriList in interface HandlerIOProcessingExceptionpublic void transferJsonToWorkspace(String collectionName, String objectName, com.fasterxml.jackson.databind.JsonNode jsonNode, boolean toDelete, boolean asyncIO) throws ProcessingException
HandlerIOtransferJsonToWorkspace in interface HandlerIOcollectionName - : 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 workspaceProcessingExceptionpublic void unzipInputStreamOnWorkspace(String container, String folderName, String archiveMimeType, InputStream uploadedInputStream, boolean asyncIO) throws ContentAddressableStorageException
unzipInputStreamOnWorkspace in interface HandlerIOasyncIO - asynchronously send and unzip file to/in the workspaceContentAddressableStorageExceptionpublic void zipWorkspace(String outputFile, String... inputFiles) throws ContentAddressableStorageException
HandlerIOzipWorkspace in interface HandlerIOoutputFile - path of the zip fileinputFiles - list of file or directory to zipContentAddressableStorageExceptionpublic void enableAsync(boolean async)
throws WorkerspaceQueueException
HandlerIOenableAsync in interface HandlerIOWorkerspaceQueueExceptionpublic boolean removeFolder(String folderName) throws ContentAddressableStorageException
HandlerIOremoveFolder in interface HandlerIOfolderName - the folderName to deleteContentAddressableStorageException - when storage error occursCopyright © 2018 Vitam. All rights reserved.