Class FileExportActionHandler

    • Constructor Detail

      • FileExportActionHandler

        public FileExportActionHandler()
    • Method Detail

      • execute

        public void execute()
        execute() method overridden to add the logic to download or display the file stored in the temporary folder.
        Specified by:
        execute in interface ActionHandler
        Overrides:
        execute in class BaseActionHandler
      • doGenerateFile

        protected Path doGenerateFile​(Map<String,​Object> parameters,
                                      org.codehaus.jettison.json.JSONObject data)
                               throws IOException,
                                      org.codehaus.jettison.json.JSONException
        Throws:
        IOException
        org.codehaus.jettison.json.JSONException
      • doValidations

        protected void doValidations​(Map<String,​Object> parameters,
                                     org.codehaus.jettison.json.JSONObject data)
        Allows to do verifications in the data
        Parameters:
        parameters - The map of parameters extracted from the request
        data - JSONObject with the request content
      • generateFileToDownload

        protected abstract Path generateFileToDownload​(Map<String,​Object> parameters,
                                                       org.codehaus.jettison.json.JSONObject data)
                                                throws IOException,
                                                       org.codehaus.jettison.json.JSONException
        This method that allows possible verifications in the data
        Parameters:
        parameters - The map of parameters extracted from the request
        data - JSONObject with the request content
        Throws:
        IOException
        org.codehaus.jettison.json.JSONException
      • getDownloadFileName

        protected abstract String getDownloadFileName​(Map<String,​Object> parameters,
                                                      org.codehaus.jettison.json.JSONObject data)
                                               throws org.codehaus.jettison.json.JSONException
        Retrieves the name of the file to be downloaded
        Parameters:
        parameters - The map of parameters extracted from the request
        data - JSONObject with the request content
        Returns:
        the name of the file to be downloaded
        Throws:
        org.codehaus.jettison.json.JSONException
      • isValidDownloadFileType

        protected boolean isValidDownloadFileType​(ReportingUtils.ExportType exportType)
        Returns:
        true if the handler supports downloading files with the give type. Otherwise false is returned.
      • getAdditionalResponseActions

        protected org.codehaus.jettison.json.JSONObject getAdditionalResponseActions()
        Returns:
        a JSONObject containing the additional response actions to be done together with the file action defined by the process
      • getDownloadAction

        protected FileExportActionHandler.FileAction getDownloadAction​(org.codehaus.jettison.json.JSONObject data)
                                                                throws org.codehaus.jettison.json.JSONException
        Allows to define the action to be done with the file when it is downloaded. It returns FileExportActionHandler.FileAction.DOWNLOAD by default.
        Parameters:
        data - JSONObject with the request content
        Returns:
        the action to be done when the file is downloaded
        Throws:
        org.codehaus.jettison.json.JSONException
      • uploadAttachment

        protected void uploadAttachment​(Path originalFile,
                                        Map<String,​Object> parameters,
                                        org.codehaus.jettison.json.JSONObject data)
                                 throws IOException,
                                        org.codehaus.jettison.json.JSONException
        Uploads the downloaded file as an attachment. By default, it only attaches the file when the process has been executed for a single record. So the attach is not done in a multiRecord process definition or when process definition is executed directly from a menu entry. Subclasses are allowed to override this method in case it is desired to change this default behavior or not to attach any file at all.
        Parameters:
        originalFile - The file whose content is attached
        parameters - The map of parameters extracted from the request
        data - JSONObject with the request content. Used to extract required information for creating the attachment like the record ID.
        Throws:
        IOException
        org.codehaus.jettison.json.JSONException