Package com.jbstrap.core.interfaces
Class FileHandler
java.lang.Object
com.jbstrap.core.interfaces.FileHandler
- Direct Known Subclasses:
DefaultFileHandler
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionIf a field in the record is of the file type, this method is called.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.processFilesBeforePersist
(List<JBFile> fileList, Record record, String attributeName, Client client) 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.
-
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 recordrecord
- The record that is persisted and contains the filesattributeName
- The name of the field that contains the files in the recordclient
- 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 recordrecord
- Persisted recordattributeName
- The name of the field that contains the files in the recordclient
- 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 differentattributeName
parameter. FilesJBFile
in the record are set as a list, as components can only handle them in this format.- Parameters:
record
- Record associated with the file listattributeName
- Field with the file typeclient
- 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:
-