Package com.day.cq.dam.commons.util
Interface AssetCache
- 
public interface AssetCacheProvides convenience methods for handlingInputStreams from and temporary files for DAM asset renditions. A proper instance of anAssetCachecan be retrieved viaDamUtil.getAssetCache(). Every obtained instance needs to berelease()d after use.The AssetCache might keep temporary files around for longer and reuse them in future
AssetCacheinstances. This is transparent to the caller. 
- 
- 
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ByteSourcegetByteSource(Rendition rendition, boolean needFile)Get aByteSourcefor the renction's content.java.io.FilegetFile(Rendition rendition)Get anFilewith the content of the Asset rendition.java.io.InputStreamgetOriginalStream(Asset asset, boolean needFile)Get an InputStream to the content of the original Asset rendition.java.io.InputStreamgetRenditionStream(Asset asset, java.lang.String name, boolean needFile)Get an InputStream to the content of the Asset rendition with name.java.io.InputStreamgetStream(Rendition rendition, boolean needFile)Get an InputStream to the content of the Asset rendition.voidinvalidateCache(Asset asset)Notify the cache that an asset has been modified/deleted and that cached data is no longer validvoidinvalidateCache(Rendition rendition)Notify the cache that an asset rendition has been modified/deleted and that cached data is no longer validvoidrelease()Release this cache instance and cleanup all handed out streams and data. 
 - 
 
- 
- 
Method Detail
- 
getOriginalStream
java.io.InputStream getOriginalStream(Asset asset, boolean needFile) throws java.io.IOException
Get an InputStream to the content of the original Asset rendition. The stream is automatically closed on release of this cache instance.- Parameters:
 asset- the asset to get the original rendition forneedFile- if a file based stream is preferred- Returns:
 - stream to original rendition content, closed on release
 - Throws:
 java.io.IOException- if original rendition was not found
 
- 
getRenditionStream
java.io.InputStream getRenditionStream(Asset asset, java.lang.String name, boolean needFile) throws java.io.IOException
Get an InputStream to the content of the Asset rendition with name. The stream is automatically closed on release of this cache instance.- Parameters:
 asset- the asset to get the original rendition forname- name of the rendition to get the content forneedFile- if a file based stream is preferred- Returns:
 - stream to original rendition content, closed on release
 - Throws:
 java.io.IOException- if original rendition was not found
 
- 
getStream
java.io.InputStream getStream(Rendition rendition, boolean needFile) throws java.io.IOException
Get an InputStream to the content of the Asset rendition. The stream is automatically closed on release of this cache instance.- Parameters:
 rendition- rendition to get the content forneedFile- if a file based stream is preferred- Returns:
 - stream to original rendition content, closed on release
 - Throws:
 java.io.IOException- if original rendition was not found
 
- 
getFile
java.io.File getFile(Rendition rendition) throws java.io.IOException
Get anFilewith the content of the Asset rendition. The file is temporary and will be deleted on cache release (not necessarily the release of this cache instance).- Parameters:
 rendition- rendition to get the content for- Returns:
 - stream to original rendition content, closed on release
 - Throws:
 java.io.IOException- if original rendition was not found
 
- 
getByteSource
ByteSource getByteSource(Rendition rendition, boolean needFile) throws java.io.IOException
Get aByteSourcefor the renction's content. The source is automatically cleaned up on release of this cache instance.- Parameters:
 rendition- rendition to get the content forneedFile- if a file based stream is preferred- Returns:
 - stream to original rendition content, closed on release
 - Throws:
 java.io.IOException- if original rendition was not found
 
- 
invalidateCache
void invalidateCache(Asset asset)
Notify the cache that an asset has been modified/deleted and that cached data is no longer valid- Parameters:
 asset- asset that was modified/deleted.
 
- 
invalidateCache
void invalidateCache(Rendition rendition)
Notify the cache that an asset rendition has been modified/deleted and that cached data is no longer valid- Parameters:
 rendition- rendition that was modified/deleted.
 
- 
release
void release()
Release this cache instance and cleanup all handed out streams and data. Needs to be invoked at the end of cache use. 
 - 
 
 -