Package titan.tasks
Class FileHandler
java.lang.Object
titan.tasks.FileHandler
- All Implemented Interfaces:
TaskHandler
Handles file-related tasks, specifically saving files to a designated workspace directory.
This class implements the
TaskHandler interface, providing an execution mechanism
for file operations. It decodes a Base64-encoded file content from a payload and writes
it to a file within the "./titan_workspace" directory.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringThe base directory where all files processed by this handler will be saved. -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface titan.tasks.TaskHandler
setLogListener
-
Field Details
-
WORKSPACE_DIR
The base directory where all files processed by this handler will be saved. This directory is created if it does not already exist upon instantiation ofFileHandler.- See Also:
-
-
Constructor Details
-
FileHandler
public FileHandler()Constructs a newFileHandlerinstance. This constructor ensures that the "./titan_workspace" directory exists. If the directory does not exist, it attempts to create it, along with any necessary but nonexistent parent directories.
-
-
Method Details
-
execute
Description copied from interface:TaskHandlerExecutes a task with the given payload. Implementations should define the specific logic for processing the payload and generating a result.- Specified by:
executein interfaceTaskHandler- Parameters:
payload- The input data or parameters for the task, typically in a serialized format like JSON or XML.- Returns:
- A string representing the result of the task execution. This could be a success message, a serialized object, or an error message.
-