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:
-
AudioProcessorDLPreviewableProcessorImageProcessorPDFProcessorRawMetadataProcessorVideoProcessor
-
Method Summary
Modifier and TypeMethodDescriptionvoidCleans up any resources that the processor created for the file entry.voidcleanUp(FileVersion fileVersion) Cleans up any resources that the processor created for the given file version.voidcopy(FileVersion sourceFileVersion, FileVersion destinationFileVersion) Copies all resources generated for the source file version, reusing them for destination file version.voidexportGeneratedFiles(PortletDataContext portletDataContext, FileEntry fileEntry, Element fileEntryElement) Exports any resources generated for the file entry into file entry element.getType()Returns the processor's type.voidimportGeneratedFiles(PortletDataContext portletDataContext, FileEntry fileEntry, FileEntry importedFileEntry, Element fileEntryElement) Imports any existing resources from the file entry or file entry element.booleanisSupported(FileVersion fileVersion) Returnstrueif the file version is supported by this processor.booleanisSupported(String mimeType) Returnstrueif the given file MIME type is supported by this processor.voidtrigger(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.DLProcessorConstantsfor 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
Returnstrueif the file version is supported by this processor.- Parameters:
fileVersion- the file version- Returns:
trueif this processor supports the file version;falseotherwise
-
isSupported
Returnstrueif the given file MIME type is supported by this processor.- Parameters:
mimeType- the MIME type- Returns:
trueif this processor supports the MIME type;falseotherwise
-
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
-