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 HandlerIO
public LogbookLifeCyclesClientHelper getHelper()
public void addInIOParameters(List<IOParameter> list)
HandlerIO
addInIOParameters
in interface HandlerIO
public void addOutIOParameters(List<IOParameter> list)
HandlerIO
addOutIOParameters
in interface HandlerIO
public void reset()
HandlerIO
public void close()
close
in interface VitamAutoCloseable
close
in interface AutoCloseable
public void partialClose()
public Object getInput(int rank)
HandlerIO
public List<ProcessingUri> getOutput()
public ProcessingUri getOutput(int rank)
HandlerIO
public HandlerIO addOuputResult(int rank, Object object, boolean asyncIO) throws ProcessingException
HandlerIO
addOuputResult
in interface HandlerIO
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 workspaceProcessingException
public HandlerIO addOuputResult(int rank, Object object, boolean deleteLocal, boolean asyncIO) throws ProcessingException
HandlerIO
addOuputResult
in interface HandlerIO
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 workspaceProcessingException
public String getContainerName()
getContainerName
in interface HandlerIO
public String getWorkerId()
getWorkerId
in interface HandlerIO
public File getLocalPathRoot()
getLocalPathRoot
in interface HandlerIO
public File getNewLocalFile(String name)
getNewLocalFile
in interface HandlerIO
public boolean checkHandlerIO(int outputNumber, List<Class<?>> clasz)
HandlerIO
checkHandlerIO
in interface HandlerIO
outputNumber
- 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
HandlerIO
transferFileToWorkspace
in interface HandlerIO
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 workspaceProcessingException
public void transferInputStreamToWorkspace(String workspacePath, InputStream inputStream, Path filePath, boolean asyncIO) throws ProcessingException
HandlerIO
transferInputStreamToWorkspace
in interface HandlerIO
workspacePath
- path within the workspath, without the container (implicit)inputStream
- the source InputStream to writeasyncIO
- asynchronously send to the workspaceProcessingException
public File getFileFromWorkspace(String objectName) throws IOException, ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException
HandlerIO
getFileFromWorkspace
in interface HandlerIO
IOException
ContentAddressableStorageNotFoundException
ContentAddressableStorageServerException
public InputStream getInputStreamFromWorkspace(String objectName) throws IOException, ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException
HandlerIO
getInputStreamFromWorkspace
in interface HandlerIO
IOException
ContentAddressableStorageNotFoundException
ContentAddressableStorageServerException
public javax.ws.rs.core.Response getInputStreamNoCachedFromWorkspace(String objectName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException
HandlerIO
getInputStreamNoCachedFromWorkspace
in interface HandlerIO
ContentAddressableStorageNotFoundException
ContentAddressableStorageServerException
public void consumeAnyEntityAndClose(javax.ws.rs.core.Response response)
HandlerIO
consumeAnyEntityAndClose
in interface HandlerIO
public com.fasterxml.jackson.databind.JsonNode getJsonFromWorkspace(String jsonFilePath) throws ProcessingException
HandlerIO
JsonNode
from the workspace.getJsonFromWorkspace
in interface HandlerIO
jsonFilePath
- path in workspace of the json FileProcessingException
- throws when error occurspublic boolean deleteLocalFile(String objectName)
HandlerIO
deleteLocalFile
in interface HandlerIO
public List<URI> getUriList(String containerName, String folderName) throws ProcessingException
getUriList
in interface HandlerIO
ProcessingException
public void transferJsonToWorkspace(String collectionName, String objectName, com.fasterxml.jackson.databind.JsonNode jsonNode, boolean toDelete, boolean asyncIO) throws ProcessingException
HandlerIO
transferJsonToWorkspace
in interface HandlerIO
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 workspaceProcessingException
public void unzipInputStreamOnWorkspace(String container, String folderName, String archiveMimeType, InputStream uploadedInputStream, boolean asyncIO) throws ContentAddressableStorageException
unzipInputStreamOnWorkspace
in interface HandlerIO
asyncIO
- asynchronously send and unzip file to/in the workspaceContentAddressableStorageException
public void zipWorkspace(String outputFile, String... inputFiles) throws ContentAddressableStorageException
HandlerIO
zipWorkspace
in interface HandlerIO
outputFile
- path of the zip fileinputFiles
- list of file or directory to zipContentAddressableStorageException
public void enableAsync(boolean async) throws WorkerspaceQueueException
HandlerIO
enableAsync
in interface HandlerIO
WorkerspaceQueueException
public boolean removeFolder(String folderName) throws ContentAddressableStorageException
HandlerIO
removeFolder
in interface HandlerIO
folderName
- the folderName to deleteContentAddressableStorageException
- when storage error occursCopyright © 2018 Vitam. All rights reserved.