Class ThumbnailManager

java.lang.Object
org.codelibs.fess.thumbnail.ThumbnailManager

public class ThumbnailManager extends Object
Manager class for handling thumbnail generation and management. Provides functionality to generate, cache, and serve thumbnail images for documents.
  • Field Details

    • THUMBNAILS_DIR_NAME

      protected static final String THUMBNAILS_DIR_NAME
      Default directory name for thumbnails.
      See Also:
    • logger

      protected static final org.apache.logging.log4j.Logger logger
      Logger instance for this class.
    • baseDir

      protected File baseDir
      Base directory for storing thumbnail files.
    • generatorList

      protected final List<ThumbnailGenerator> generatorList
      List of available thumbnail generators.
    • thumbnailTaskQueue

      protected BlockingQueue<org.codelibs.core.misc.Tuple3<String,String,String>> thumbnailTaskQueue
      Queue for thumbnail generation tasks containing URL, content, and path tuples.
    • generating

      protected volatile boolean generating
      Flag indicating whether thumbnail generation is currently in progress.
    • thumbnailPathCacheSize

      protected int thumbnailPathCacheSize
      Size of the thumbnail path cache.
    • imageExtention

      protected String imageExtention
      File extension for generated thumbnail images.
    • splitSize

      protected int splitSize
      Number of subdirectories for organizing thumbnails.
    • thumbnailTaskQueueSize

      protected int thumbnailTaskQueueSize
      Maximum size of the thumbnail generation task queue.
    • thumbnailTaskBulkSize

      protected int thumbnailTaskBulkSize
      Number of tasks to process in bulk operations.
    • thumbnailTaskQueueTimeout

      protected long thumbnailTaskQueueTimeout
      Timeout in milliseconds for thumbnail task queue operations.
    • noImageExpired

      protected long noImageExpired
      Expiration time in milliseconds for no-image placeholder files.
    • splitHashSize

      protected int splitHashSize
      Hash size for splitting thumbnail storage directories.
  • Constructor Details

    • ThumbnailManager

      public ThumbnailManager()
      Default constructor for ThumbnailManager.
  • Method Details

    • init

      @PostConstruct public void init()
      Initializes the thumbnail manager after construction. Sets up base directory and starts background processing.
    • destroy

      @PreDestroy public void destroy()
      Cleans up resources when the thumbnail manager is destroyed. Stops background processing and waits for threads to complete.
    • getThumbnailPathOption

      public String getThumbnailPathOption()
      Gets the system property option string for thumbnail path configuration.
      Returns:
      the property option string for JVM arguments
    • storeQueue

      protected void storeQueue(List<org.codelibs.core.misc.Tuple3<String,String,String>> taskList)
      Stores thumbnail generation tasks to the queue for processing.
      Parameters:
      taskList - list of thumbnail tasks to store
    • generate

      public int generate(ExecutorService executorService, boolean cleanup)
      Generates thumbnails using the provided executor service.
      Parameters:
      executorService - the executor service for parallel processing
      cleanup - whether to run in cleanup mode
      Returns:
      the number of tasks processed
    • process

      protected void process(org.codelibs.fess.mylasta.direction.FessConfig fessConfig, org.codelibs.fess.opensearch.config.exentity.ThumbnailQueue entity)
      Processes a single thumbnail generation task.
      Parameters:
      fessConfig - the Fess configuration
      entity - the thumbnail queue entity to process
    • offer

      public boolean offer(Map<String,Object> docMap)
      Offers a document for thumbnail generation.
      Parameters:
      docMap - the document data map
      Returns:
      true if the task was successfully added to the queue
    • getImageFilename

      protected String getImageFilename(Map<String,Object> docMap)
      Gets the image filename for a document based on its document map.
      Parameters:
      docMap - the document data map
      Returns:
      the generated image filename
    • getImageFilename

      protected String getImageFilename(String docid)
      Gets the image filename for a document based on its document ID.
      Parameters:
      docid - the document ID
      Returns:
      the generated image filename
    • getThumbnailFile

      public File getThumbnailFile(Map<String,Object> docMap)
      Gets the thumbnail file for a document if it exists.
      Parameters:
      docMap - the document data map
      Returns:
      the thumbnail file or null if not found
    • add

      public void add(ThumbnailGenerator generator)
      Adds a thumbnail generator to the manager.
      Parameters:
      generator - the thumbnail generator to add
    • purge

      public long purge(long expiry)
      Purges old thumbnail files based on the expiry time.
      Parameters:
      expiry - the expiry time threshold
      Returns:
      the number of files purged
    • migrate

      public void migrate()
      Migrates existing thumbnail files to the new directory structure.
    • setThumbnailPathCacheSize

      public void setThumbnailPathCacheSize(int thumbnailPathCacheSize)
      Sets the thumbnail path cache size.
      Parameters:
      thumbnailPathCacheSize - the cache size to set
    • setImageExtention

      public void setImageExtention(String imageExtention)
      Sets the image file extension for thumbnails.
      Parameters:
      imageExtention - the file extension to set
    • setSplitSize

      public void setSplitSize(int splitSize)
      Sets the split size for directory organization.
      Parameters:
      splitSize - the split size to set
    • setThumbnailTaskQueueSize

      public void setThumbnailTaskQueueSize(int thumbnailTaskQueueSize)
      Sets the maximum size of the thumbnail task queue.
      Parameters:
      thumbnailTaskQueueSize - the queue size to set
    • setNoImageExpired

      public void setNoImageExpired(long noImageExpired)
      Sets the expiration time for no-image placeholder files.
      Parameters:
      noImageExpired - the expiration time in milliseconds
    • setSplitHashSize

      public void setSplitHashSize(int splitHashSize)
      Sets the hash size for splitting thumbnail storage directories.
      Parameters:
      splitHashSize - the hash size to set