Class FileHandler

java.lang.Object
com.jbstrap.core.interfaces.FileHandler
Direct Known Subclasses:
DefaultFileHandler

public abstract class FileHandler extends Object

If using the JpaDao, custom file handler methods can be created, that are called during saving, deleting and querying.

The file handler class can be set in the JBStrapParamType.FILE_HANDLER parameter. The parameter value must be an implementation of the FileHandler interface. If the parameter is not set, the DefaultFileHandler will be used to handle the files. The file saving and loading back can be implemented with the class methods.

Since:
4.0
Author:
JBStrap
See Also:
  • Constructor Details

    • FileHandler

      public FileHandler()
  • Method Details

    • processFilesBeforePersist

      public Record processFilesBeforePersist(List<JBFile> fileList, Record record, String attributeName, Client client) throws Exception
      If a field in the record is of the file type, this method is called for the specific field before the record is persisted to the database. Persisting a record to the database includes record operations, such as saving, removing or updating a record. If more than one fields within the record are of the file type, this method is called for each field. Modifications of the record in the parameter are persisted.
      Parameters:
      fileList - A list of JBFiles from the attributeName parameter within the persisted record
      record - The record that is persisted and contains the files
      attributeName - The name of the field that contains the files in the record
      client - The client object used to reach the current user
      Returns:
      Record containing the files The record modifications will be persisted to the database.
      Throws:
      Exception - Thrown if there are errors during the implementation
      See Also:
    • processFilesAfterPersist

      public Record processFilesAfterPersist(List<JBFile> fileList, Record record, String attributeName, Client client) throws Exception
      If a field in the record is of the file type, this method is called for the specific field after the record is persisted to the database. Persisting a record to the database includes record operations, such as saving, removing or updating a record. If more than one fields within the record are of the file type, this method is called for each field. Modifications of the record in the parameter are persisted.
      Parameters:
      fileList - A list of JBFiles from the attributeName parameter within the persisted record
      record - Persisted record
      attributeName - The name of the field that contains the files in the record
      client - The client object used to reach the current user
      Returns:
      Record containing the files The record modifications will be persisted to the database.
      Throws:
      Exception - Thrown if there are errors during the implementation
      See Also:
    • getFiles

      public abstract List<JBFile> getFiles(Record record, String attributeName, Client client) throws Exception
      If a field in the record is of the file type, this method is called. If there are more than one fields in the record that are of the file type, the method is called for each field, each method call uses a different attributeName parameter. Files JBFile in the record are set as a list, as components can only handle them in this format.
      Parameters:
      record - Record associated with the file list
      attributeName - Field with the file type
      client - The client object used to reach the current user
      Returns:
      The list containing the files for the attributeName field
      Throws:
      Exception - Thrown if there are errors during the implementation
      See Also: