Class ResizedImageManager

java.lang.Object
com.cksource.ckfinder.image.ResizedImageManager

@Component @Scope(value="request", proxyMode=TARGET_CLASS) public class ResizedImageManager extends Object
Request scoped service used for resized images processing.
See Also:
  • Field Details

  • Constructor Details

    • ResizedImageManager

      public ResizedImageManager()
  • Method Details

    • cacheImageMetadata

      public void cacheImageMetadata(ResourceType resourceType, String folderPath, String fileName, ImageSize imageSize, long fileSize)
      Saves image metadata in cache.
      Parameters:
      resourceType - resource type
      folderPath - folder path
      fileName - file name
      imageSize - image dimensions
      fileSize - image file size
    • copyCachedImageMetadata

      public void copyCachedImageMetadata(ResourceType sourceResourceType, String sourceFolderPath, String sourceFileName, ResourceType targetResourceType, String targetFolderPath, String targetFileName)
      Copies image metadata from one cache key to another cache entry.
      Parameters:
      sourceResourceType - source resource type
      sourceFolderPath - source file path
      sourceFileName - source file name
      targetResourceType - target resource type
      targetFolderPath - target folder path
      targetFileName - target file name
    • deleteCachedImageMetadata

      public void deleteCachedImageMetadata(ResourceType resourceType, String folderPath, String fileName)
      Deletes all cached image metadata entries for given image.
      Parameters:
      resourceType - resource type
      folderPath - folder path
      fileName - file name
    • deleteCachedImageMetadata

      public void deleteCachedImageMetadata(ResourceType resourceType, String folderPath)
      Deletes all cached image metadata entries for given image.
      Parameters:
      resourceType - resource type
      folderPath - folder path
    • changeCachedImageMetadataPrefix

      public void changeCachedImageMetadataPrefix(ResourceType resourceType, String folderPath, String newFolderPath)
      Changes image metadata prefix for all existing image metadata entries under given prefix.
      Parameters:
      resourceType - resource type
      folderPath - folder path
      newFolderPath - new folder path
    • getCachedImageMetadata

      public Map<String,Object> getCachedImageMetadata(ResourceType resourceType, String folderPath, String fileName)
      Returns cached image metadata.
      Parameters:
      resourceType - resource type
      folderPath - folder path
      fileName - file name
      Returns:
      image metadata found in cache or null if no cache entry exists
    • getResizedImagesList

      public Map<String,Object> getResizedImagesList(ResourceType resourceType, String folderPath, String fileName)
      Returns a list of all resized versions of given image.
      Parameters:
      resourceType - resource type
      folderPath - folder path
      fileName - file name
      Returns:
      list of all resized versions of given image
    • getImageSizeNameFromConfig

      protected String getImageSizeNameFromConfig(ImageSize imageSize)
      Returns the name defined in config for image size that fits image size passed to this method.
      Parameters:
      imageSize - image dimensions
      Returns:
      name for image size defined in config
      See Also:
    • getResizedImage

      public ResizedImage getResizedImage(ResourceType resourceType, String folderPath, String fileName, ImageSize requestedSize) throws IOException
      Creates a resized version of given image file.
      Parameters:
      resourceType - resource type
      folderPath - folder path
      fileName - file name
      requestedSize - requested image size
      Returns:
      resized version of image
      Throws:
      IOException - in case of any processing exception
    • getExistingResizedImage

      public ResizedImage getExistingResizedImage(ResourceType resourceType, String folderPath, String fileName, String resizedImageFileName) throws IOException
      Returns an existing resized version of given image file.
      Parameters:
      resourceType - resource type
      folderPath - folder path
      fileName - file name
      resizedImageFileName - file name of the resized image file
      Returns:
      resized image or null if not found
      Throws:
      IOException - in case of any processing exception
    • getResizedImage

      public ResizedImage getResizedImage(WorkingFolder workingFolder, String fileName, ImageSize requestedSize) throws IOException
      Returns resized image for given image file.
      Parameters:
      workingFolder - working folder
      fileName - file name
      requestedSize - requested image size
      Returns:
      resized image
      Throws:
      IOException - in case of any processing exception
    • deleteResizedImages

      public void deleteResizedImages(ResourceType resourceType, String folderPath, String fileName)
      Deletes all resized versions of images when the main image file is deleted.
      Parameters:
      resourceType - resource type
      folderPath - folder path
      fileName - file name
    • copyResizedImages

      public void copyResizedImages(ResourceType sourceResourceType, String sourceFolderPath, String sourceFileName, ResourceType targetResourceType, String targetFolderPath, String targetFileName)
      Copies all resized versions of images when the main image file is copied.
      Parameters:
      sourceResourceType - source resource type
      sourceFolderPath - source folder path
      sourceFileName - source file name
      targetResourceType - target resource type
      targetFolderPath - target folder path
      targetFileName - target file name
    • renameResizedImages

      public void renameResizedImages(ResourceType resourceType, String folderPath, String fileName, String newFileName)
      Renames all resized versions of images when the main image file is renamed.
      Parameters:
      resourceType - resource type
      folderPath - folder path
      fileName - file name
      newFileName - new file name
    • isImageSizeAllowedInConfig

      protected boolean isImageSizeAllowedInConfig(ImageSize imageSize)
      Checks if given image size is allowed in config.
      Parameters:
      imageSize - image size
      Returns:
      true if image size is allowed in config, false otherwise