Interface DLProcessor
public interface DLProcessor
Provides a common interface for all the processors of the document library.
All document library processors must implement this interface.
A DLProcessor (processor) is responsible for extracting additional metadata
or assets from
a Documents and Media file entry. Here are a couple examples of such metadata
and assets:
- Metadata stored in JPEG images or video files.
- Images to use as previews for PDF or Word documents.
DLProcessor
:
@Component(service = DLProcessor.class) public class MyDLProcessor implements DLProcessor { }Implementing classes are responsible for managing any storage required by the generated resources and for providing access to any generated assets. See current implementations for examples.
- Author:
- Alexander Chow, Mika Koivisto
- See Also:
-
AudioProcessor
DLPreviewableProcessor
ImageProcessor
PDFProcessor
RawMetadataProcessor
VideoProcessor
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Cleans up any resources that the processor created for the file entry.void
cleanUp
(FileVersion fileVersion) Cleans up any resources that the processor created for the given file version.void
copy
(FileVersion sourceFileVersion, FileVersion destinationFileVersion) Copies all resources generated for the source file version, reusing them for destination file version.void
exportGeneratedFiles
(PortletDataContext portletDataContext, FileEntry fileEntry, Element fileEntryElement) Exports any resources generated for the file entry into file entry element.getType()
Returns the processor's type.void
importGeneratedFiles
(PortletDataContext portletDataContext, FileEntry fileEntry, FileEntry importedFileEntry, Element fileEntryElement) Imports any existing resources from the file entry or file entry element.boolean
isSupported
(FileVersion fileVersion) Returnstrue
if the file version is supported by this processor.boolean
isSupported
(String mimeType) Returnstrue
if the given file MIME type is supported by this processor.void
trigger
(FileVersion sourceFileVersion, FileVersion destinationFileVersion) Launches the processor's work with respect to the destination file version.
-
Method Details
-
cleanUp
Cleans up any resources that the processor created for the file entry. Note that all resources for all file versions of this file entry are permanently deleted.- Parameters:
fileEntry
- the file entry for which resources are cleaned up
-
cleanUp
Cleans up any resources that the processor created for the given file version. Note that other resources associated with other file versions for the same file entry aren't affected; usecleanUp(FileEntry)
if you want to clean up everything.- Parameters:
fileVersion
- the file version for which resources will be cleaned up
-
copy
Copies all resources generated for the source file version, reusing them for destination file version. Note that resources are literally copied, making the resulting resources independent (i.e., if afterwards the source file version is deleted, the destination file version resources aren't affected).- Parameters:
sourceFileVersion
- the file version to copy resources fromdestinationFileVersion
- the file version to copy resources to
-
exportGeneratedFiles
void exportGeneratedFiles(PortletDataContext portletDataContext, FileEntry fileEntry, Element fileEntryElement) throws Exception Exports any resources generated for the file entry into file entry element.- Parameters:
portletDataContext
- the portlet data context to use during this export operationfileEntry
- the file entry for which resources are exportedfileEntryElement
- the file entry element to save resources into- Throws:
Exception
- if an error occurred while exporting the file entry resources
-
getType
String getType()Returns the processor's type. Seecom.liferay.portlet.documentlibrary.model.DLProcessorConstants
for the set of predefined processor types.- Returns:
- the type of this processor
-
importGeneratedFiles
void importGeneratedFiles(PortletDataContext portletDataContext, FileEntry fileEntry, FileEntry importedFileEntry, Element fileEntryElement) throws Exception Imports any existing resources from the file entry or file entry element. If the portlet data context supports direct binary import (seePortletDataContext.isPerformDirectBinaryImport()
), the resources are directly copied from the file entry; otherwise, they're extracted from the file entry element.- Parameters:
portletDataContext
- the portlet data context to use during this import operationfileEntry
- the file entry to import resources from, if direct binary import is supportedimportedFileEntry
- the file entry for which resources are importedfileEntryElement
- the file entry element to import resources from, if direct binary import is not supported- Throws:
Exception
- if an error occurred while importing the file entry resources
-
isSupported
Returnstrue
if the file version is supported by this processor.- Parameters:
fileVersion
- the file version- Returns:
true
if this processor supports the file version;false
otherwise
-
isSupported
Returnstrue
if the given file MIME type is supported by this processor.- Parameters:
mimeType
- the MIME type- Returns:
true
if this processor supports the MIME type;false
otherwise
-
trigger
Launches the processor's work with respect to the destination file version.- Parameters:
sourceFileVersion
- the file version to copy previews and thumbnails from (optionallynull
)destinationFileVersion
- the latest file version to process
-