Class TemporaryDocumentPreviewService
- java.lang.Object
-
- com.saperion.ngc.viewer.temporary.TemporaryDocumentPreviewService
-
- All Implemented Interfaces:
java.io.Serializable
public final class TemporaryDocumentPreviewService extends java.lang.Object implements java.io.SerializableThis service class is used to cache the binary content of uploaded documents in order to be displayed by a indexing masks viewer.- Author:
- sts
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static TemporaryDocumentIdcacheDocument(byte[] document)Caches the document represented by the given byte array.static TemporaryDocumentIdcacheDocument(java.io.InputStream stream)Caches the document represented by the given input stream.static TemporaryDocumentIdcacheDocument(org.zkoss.util.media.Media media)Caches the document represented by the given media.static voiddisable()Disables the temporary document preview service.static booleanenable(long maxViewSizeInBytes)Enables the temporary document preview service.static java.io.InputStreamgetDocument(TemporaryDocumentId id)Returns a previously cached document as anInputStream.static byte[]getDocumentAsByteArray(TemporaryDocumentId id)Returns a previously cached document as a byte array.static booleanisEnabled()Indicates if this services is enabled and if temporary documents can be cached.
-
-
-
Method Detail
-
enable
public static boolean enable(long maxViewSizeInBytes)
Enables the temporary document preview service.- Parameters:
maxViewSizeInBytes- maximum size of viewable documents- Returns:
- true, if enabling was successful, false otherwise.
-
disable
public static void disable()
Disables the temporary document preview service.
-
isEnabled
public static boolean isEnabled()
Indicates if this services is enabled and if temporary documents can be cached.- Returns:
- true, if this services is enabled, false otherwise.
-
cacheDocument
public static TemporaryDocumentId cacheDocument(java.io.InputStream stream) throws ViewSizeException, NotEnabledException, InternalCacheException
Caches the document represented by the given input stream.- Parameters:
stream- The document stream to cache.- Returns:
- a
TemporaryDocumentIdidentifying the cached document. - Throws:
ViewSizeException- when the document is too large to cacheInternalCacheException- if the caching of the temporary content failedNotEnabledException- if this service is not enabled or a failure occurred.
-
cacheDocument
public static TemporaryDocumentId cacheDocument(byte[] document) throws ViewSizeException, NotEnabledException, InternalCacheException
Caches the document represented by the given byte array.- Parameters:
document- The document to cache.- Returns:
- a
TemporaryDocumentIdidentifying the cached document. - Throws:
ViewSizeException- when the document is too large to cacheInternalCacheException- if the caching of the temporary content failedNotEnabledException- if this service is not enabled or a failure occurred.
-
cacheDocument
public static TemporaryDocumentId cacheDocument(org.zkoss.util.media.Media media) throws ViewSizeException, NotEnabledException, InternalCacheException
Caches the document represented by the given media.- Parameters:
media- The document to cache.- Returns:
- a
TemporaryDocumentIdidentifying the cached document. - Throws:
ViewSizeException- when the document is too large to cacheInternalCacheException- if the caching of the temporary content failedNotEnabledException- if this service is not enabled or a failure occurred.java.io.IOException- if reading from the media failed
-
getDocumentAsByteArray
public static byte[] getDocumentAsByteArray(TemporaryDocumentId id) throws java.lang.Exception
Returns a previously cached document as a byte array.- Parameters:
id- The id of a previously cached document.- Returns:
- the cached document as a byte array.
- Throws:
java.lang.Exception- if this service is not enabled, the requested document is not available in cache or a failure occurred.
-
getDocument
public static java.io.InputStream getDocument(TemporaryDocumentId id) throws NotEnabledException, com.saperion.cache.exception.ElementNotFoundException, InternalCacheException
Returns a previously cached document as anInputStream.- Parameters:
id- The id of a previously cached document.- Returns:
- the cached document as an
InputStream. - Throws:
NotEnabledException- if this service is not enabled,com.saperion.cache.exception.ElementNotFoundException- if the requested document is not available in cacheInternalCacheException- if an error occurred while reading from the cache
-
-