Class TemporaryDocumentPreviewService

  • All Implemented Interfaces:
    java.io.Serializable

    public final class TemporaryDocumentPreviewService
    extends java.lang.Object
    implements java.io.Serializable
    This 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 TemporaryDocumentId cacheDocument​(byte[] document)
      Caches the document represented by the given byte array.
      static TemporaryDocumentId cacheDocument​(java.io.InputStream stream)
      Caches the document represented by the given input stream.
      static TemporaryDocumentId cacheDocument​(org.zkoss.util.media.Media media)
      Caches the document represented by the given media.
      static void disable()
      Disables the temporary document preview service.
      static boolean enable​(long maxViewSizeInBytes)
      Enables the temporary document preview service.
      static java.io.InputStream getDocument​(TemporaryDocumentId id)
      Returns a previously cached document as an InputStream.
      static byte[] getDocumentAsByteArray​(TemporaryDocumentId id)
      Returns a previously cached document as a byte array.
      static boolean isEnabled()
      Indicates if this services is enabled and if temporary documents can be cached.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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.
      • 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 an InputStream.
        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 cache
        InternalCacheException - if an error occurred while reading from the cache