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.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static class 
    File visitor for purging old thumbnail files.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected File
    Base directory for storing thumbnail files.
    protected String
    File extension for generated thumbnail images.
    protected long
    Expiration time in milliseconds for no-image placeholder files.
    protected int
    Hash size for splitting thumbnail storage directories.
    protected int
    Number of subdirectories for organizing thumbnails.
    protected int
    Size of the thumbnail path cache.
    protected static final String
    Default directory name for thumbnails.
    protected int
    Number of tasks to process in bulk operations.
    protected int
    Maximum size of the thumbnail generation task queue.
    protected long
    Timeout in milliseconds for thumbnail task queue operations.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor for ThumbnailManager.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds a thumbnail generator to the manager.
    void
    Cleans up resources when the thumbnail manager is destroyed.
    int
    generate(ExecutorService executorService, boolean cleanup)
    Generates thumbnails using the provided executor service.
    protected String
    Gets the image filename for a document based on its document ID.
    protected String
    Gets the image filename for a document based on its document map.
    Gets the thumbnail file for a document if it exists.
    Gets the system property option string for thumbnail path configuration.
    void
    Initializes the thumbnail manager after construction.
    void
    Migrates existing thumbnail files to the new directory structure.
    boolean
    Offers a document for thumbnail generation.
    protected void
    process(org.codelibs.fess.mylasta.direction.FessConfig fessConfig, org.codelibs.fess.opensearch.config.exentity.ThumbnailQueue entity)
    Processes a single thumbnail generation task.
    long
    purge(long expiry)
    Purges old thumbnail files based on the expiry time.
    void
    setImageExtention(String imageExtention)
    Sets the image file extension for thumbnails.
    void
    setNoImageExpired(long noImageExpired)
    Sets the expiration time for no-image placeholder files.
    void
    setSplitHashSize(int splitHashSize)
    Sets the hash size for splitting thumbnail storage directories.
    void
    setSplitSize(int splitSize)
    Sets the split size for directory organization.
    void
    setThumbnailPathCacheSize(int thumbnailPathCacheSize)
    Sets the thumbnail path cache size.
    void
    setThumbnailTaskQueueSize(int thumbnailTaskQueueSize)
    Sets the maximum size of the thumbnail task queue.
    protected void
    storeQueue(List<org.codelibs.core.misc.Tuple3<String,String,String>> taskList)
    Stores thumbnail generation tasks to the queue for processing.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • THUMBNAILS_DIR_NAME

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

      protected File baseDir
      Base directory for storing thumbnail files.
    • 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