org.mycore.services.imaging
Class MCRImgCacheManager

java.lang.Object
  extended by org.mycore.services.imaging.MCRImgCacheManager
All Implemented Interfaces:
CacheManager

public class MCRImgCacheManager
extends Object
implements CacheManager

The MCRImgCacheManager deliver the method for getting data into and out of the cache structure which lies in the IFS.
The cache structure is just an one level flat tree:
|--> [imgCache] --> [cached Image File] --> [versions of image]

Cached image file is a subfolder of the root node imgCache in IFS. The name is composed the following:
ownerID + absolute path + filename
in absolute path the "/" is replaced by "%20"

Version:
0.01pre 03/01/2006
1.00 08/08/2006
Author:
Vu Huu Chi

Field Summary
static String CACHE
           
static String CACHE_FOLDER
           
static String ORIG
           
static String THUMB
           
 
Method Summary
 void deleteCache()
           
 void deleteImage(MCRFile image)
          Deletes every cache version for the original image.
 void deleteImage(MCRFile image, Dimension size)
           
 void deleteImage(MCRFile image, String filename)
          Deletes one certain cache version for the original image.
 boolean existInCache(MCRFile image)
          Checks if the original image has at least one cache version.
 boolean existInCache(MCRFile image, Dimension size)
           
 boolean existInCache(MCRFile image, String filename)
          Checks if one certain cache version of the original image exists in cache.
 void getImage(MCRFile image, String filename, OutputStream imageData)
          Get the cache version of the image.
 InputStream getImageAsInputStream(MCRFile image, String filename)
           
 Dimension getImgDimension(MCRFile image)
           
 int getImgHeight(MCRFile image)
          Get the width of the original image height is stored in the cache
 int getImgWidth(MCRFile image)
          Get the width of the original image which is stored in the cache
static MCRImgCacheManager instance()
           
 void saveImage(MCRFile image, Dimension size, InputStream imageData)
           
 void saveImage(MCRFile image, String filename, InputStream imageData)
          Save the edited image as cache for the original image.
 void setImgSize(MCRFile image, int width, int height)
          Save the size of the original image in the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

THUMB

public static final String THUMB
See Also:
Constant Field Values

CACHE

public static final String CACHE
See Also:
Constant Field Values

ORIG

public static final String ORIG
See Also:
Constant Field Values

CACHE_FOLDER

public static final String CACHE_FOLDER
See Also:
Constant Field Values
Method Detail

instance

public static MCRImgCacheManager instance()

getImage

public void getImage(MCRFile image,
                     String filename,
                     OutputStream imageData)
Description copied from interface: CacheManager
Get the cache version of the image.

Specified by:
getImage in interface CacheManager
Parameters:
image - the original image
filename - the cache version thumbnail etc.
imageData - the cached image

getImageAsInputStream

public InputStream getImageAsInputStream(MCRFile image,
                                         String filename)
                                  throws IOException
Specified by:
getImageAsInputStream in interface CacheManager
Throws:
IOException

saveImage

public void saveImage(MCRFile image,
                      Dimension size,
                      InputStream imageData)

saveImage

public void saveImage(MCRFile image,
                      String filename,
                      InputStream imageData)
Description copied from interface: CacheManager
Save the edited image as cache for the original image.

Specified by:
saveImage in interface CacheManager
Parameters:
image - the original image
filename - the cache version
imageData - the cached image

deleteImage

public void deleteImage(MCRFile image,
                        Dimension size)

deleteImage

public void deleteImage(MCRFile image,
                        String filename)
Description copied from interface: CacheManager
Deletes one certain cache version for the original image.

Specified by:
deleteImage in interface CacheManager
Parameters:
image - the original image
filename - the cache version of the original image

deleteImage

public void deleteImage(MCRFile image)
Description copied from interface: CacheManager
Deletes every cache version for the original image.

Specified by:
deleteImage in interface CacheManager
Parameters:
image - the original image

existInCache

public boolean existInCache(MCRFile image,
                            String filename)
Description copied from interface: CacheManager
Checks if one certain cache version of the original image exists in cache.

Specified by:
existInCache in interface CacheManager
Parameters:
image - the original image
filename - the cache version
Returns:
true if the cache version exists in cache

existInCache

public boolean existInCache(MCRFile image)
Description copied from interface: CacheManager
Checks if the original image has at least one cache version.

Specified by:
existInCache in interface CacheManager
Returns:
true if the the original image has at least one cache version

getImgDimension

public Dimension getImgDimension(MCRFile image)

getImgWidth

public int getImgWidth(MCRFile image)
Description copied from interface: CacheManager
Get the width of the original image which is stored in the cache

Specified by:
getImgWidth in interface CacheManager
Parameters:
image - the original image
Returns:
int the image width

getImgHeight

public int getImgHeight(MCRFile image)
Description copied from interface: CacheManager
Get the width of the original image height is stored in the cache

Specified by:
getImgHeight in interface CacheManager
Parameters:
image - the original image
Returns:
int the image height

setImgSize

public void setImgSize(MCRFile image,
                       int width,
                       int height)
Description copied from interface: CacheManager
Save the size of the original image in the cache.

Specified by:
setImgSize in interface CacheManager
Parameters:
image - the original image
width - original image width
height - original image height

existInCache

public boolean existInCache(MCRFile image,
                            Dimension size)

deleteCache

public void deleteCache()