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.
Processors can be defined as OSGi components. To do that, annotate your processor and register it under the type 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:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    cleanUp(FileEntry fileEntry)
    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.
    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)
    Returns true if the file version is supported by this processor.
    boolean
    isSupported(String mimeType)
    Returns true 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

      void cleanUp(FileEntry fileEntry)
      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

      void cleanUp(FileVersion fileVersion)
      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; use cleanUp(FileEntry) if you want to clean up everything.
      Parameters:
      fileVersion - the file version for which resources will be cleaned up
    • copy

      void copy(FileVersion sourceFileVersion, FileVersion destinationFileVersion)
      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 from
      destinationFileVersion - 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 operation
      fileEntry - the file entry for which resources are exported
      fileEntryElement - 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. See com.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 (see PortletDataContext.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 operation
      fileEntry - the file entry to import resources from, if direct binary import is supported
      importedFileEntry - the file entry for which resources are imported
      fileEntryElement - 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

      boolean isSupported(FileVersion fileVersion)
      Returns true 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

      boolean isSupported(String mimeType)
      Returns true 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

      void trigger(FileVersion sourceFileVersion, FileVersion destinationFileVersion)
      Launches the processor's work with respect to the destination file version.
      Parameters:
      sourceFileVersion - the file version to copy previews and thumbnails from (optionally null)
      destinationFileVersion - the latest file version to process