Package com.cksource.ckfinder.image
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 Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cacheImageMetadata
(ResourceType resourceType, String folderPath, String fileName, ImageSize imageSize, long fileSize) Saves image metadata in cache.void
changeCachedImageMetadataPrefix
(ResourceType resourceType, String folderPath, String newFolderPath) Changes image metadata prefix for all existing image metadata entries under given prefix.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.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.void
deleteCachedImageMetadata
(ResourceType resourceType, String folderPath) Deletes all cached image metadata entries for given image.void
deleteCachedImageMetadata
(ResourceType resourceType, String folderPath, String fileName) Deletes all cached image metadata entries for given image.void
deleteResizedImages
(ResourceType resourceType, String folderPath, String fileName) Deletes all resized versions of images when the main image file is deleted.getCachedImageMetadata
(ResourceType resourceType, String folderPath, String fileName) Returns cached image metadata.getExistingResizedImage
(ResourceType resourceType, String folderPath, String fileName, String resizedImageFileName) Returns an existing resized version of given image file.protected String
getImageSizeNameFromConfig
(ImageSize imageSize) Returns the name defined in config for image size that fits image size passed to this method.getResizedImage
(WorkingFolder workingFolder, String fileName, ImageSize requestedSize) Returns resized image for given image file.getResizedImage
(ResourceType resourceType, String folderPath, String fileName, ImageSize requestedSize) Creates a resized version of given image file.getResizedImagesList
(ResourceType resourceType, String folderPath, String fileName) Returns a list of all resized versions of given image.protected boolean
isImageSizeAllowedInConfig
(ImageSize imageSize) Checks if given image size is allowed in config.void
renameResizedImages
(ResourceType resourceType, String folderPath, String fileName, String newFileName) Renames all resized versions of images when the main image file is renamed.
-
Field Details
-
cache
-
config
-
acl
-
-
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 typefolderPath
- folder pathfileName
- file nameimageSize
- image dimensionsfileSize
- 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 typesourceFolderPath
- source file pathsourceFileName
- source file nametargetResourceType
- target resource typetargetFolderPath
- target folder pathtargetFileName
- 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 typefolderPath
- folder pathfileName
- file name
-
deleteCachedImageMetadata
Deletes all cached image metadata entries for given image.- Parameters:
resourceType
- resource typefolderPath
- 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 typefolderPath
- folder pathnewFolderPath
- new folder path
-
getCachedImageMetadata
public Map<String,Object> getCachedImageMetadata(ResourceType resourceType, String folderPath, String fileName) Returns cached image metadata.- Parameters:
resourceType
- resource typefolderPath
- folder pathfileName
- 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 typefolderPath
- folder pathfileName
- file name- Returns:
- list of all resized versions of given image
-
getImageSizeNameFromConfig
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 typefolderPath
- folder pathfileName
- file namerequestedSize
- 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 typefolderPath
- folder pathfileName
- file nameresizedImageFileName
- 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 folderfileName
- file namerequestedSize
- requested image size- Returns:
- resized image
- Throws:
IOException
- in case of any processing exception
-
deleteResizedImages
Deletes all resized versions of images when the main image file is deleted.- Parameters:
resourceType
- resource typefolderPath
- folder pathfileName
- 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 typesourceFolderPath
- source folder pathsourceFileName
- source file nametargetResourceType
- target resource typetargetFolderPath
- target folder pathtargetFileName
- 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 typefolderPath
- folder pathfileName
- file namenewFileName
- new file name
-
isImageSizeAllowedInConfig
Checks if given image size is allowed in config.- Parameters:
imageSize
- image size- Returns:
- true if image size is allowed in config, false otherwise
-