Package titan.tasks

Class FileHandler

java.lang.Object
titan.tasks.FileHandler
All Implemented Interfaces:
TaskHandler

public class FileHandler extends Object implements 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 Details

    • WORKSPACE_DIR

      private static final String 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 of FileHandler.
      See Also:
  • Constructor Details

    • FileHandler

      public FileHandler()
      Constructs a new FileHandler instance. 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

      public String execute(String payload)
      Description copied from interface: TaskHandler
      Executes a task with the given payload. Implementations should define the specific logic for processing the payload and generating a result.
      Specified by:
      execute in interface TaskHandler
      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.