Class ViewerJspUtil


  • public class ViewerJspUtil
    extends java.lang.Object
    Utility class with common helper methods for the viewer-JSPs.
    • Constructor Detail

      • ViewerJspUtil

        public ViewerJspUtil​(javax.servlet.http.HttpServletRequest request)
        Instantiates a new viewer jsp util.
        Parameters:
        request - the request
    • Method Detail

      • webLocalize

        public java.lang.String webLocalize​(java.lang.String key)
        Returns the localized resource with the specified key. Uses the WebClient's resource bundle.
        Parameters:
        key - the key
        Returns:
        the localized string
      • coreLocalize

        public java.lang.String coreLocalize​(java.lang.String key)
        Returns the localized resource with the specified key. Uses the CoreServer's resource bundle.
        Parameters:
        key - the key
        Returns:
        the localized string
      • webLocalizeForHtml

        public java.lang.String webLocalizeForHtml​(java.lang.String key)
        Returns the localized resource with the specified key. Uses the WebClient's resource bundle. The string will be escaped for usage in HTML.
        Parameters:
        key - the key
        Returns:
        the localized string
      • webLocalizeForHtml

        public java.lang.String webLocalizeForHtml​(java.lang.String key,
                                                   java.util.Map<java.lang.String,​java.lang.String> replacements)
        Returns the localized resource with the specified key. Uses the WebClient's resource bundle. The string will be escaped for usage in HTML.
        Parameters:
        key - the key
        replacements - strings to replace in the localized string
        Returns:
        the localized string
      • coreLocalizeForHtml

        public java.lang.String coreLocalizeForHtml​(java.lang.String key)
        Returns the localized resource with the specified key. Uses the CoreServer's resource bundle. The string will be escaped for usage in HTML.
        Parameters:
        key - the key
        Returns:
        the localized string
      • webLocalizeForJs

        public java.lang.String webLocalizeForJs​(java.lang.String key)
        Returns the localized resource with the specified key. Uses the WebClient's resource bundle. The string will be escaped for usage in JavaScript.
        Parameters:
        key - the key
        Returns:
        the localized string
      • coreLocalizeForJs

        public java.lang.String coreLocalizeForJs​(java.lang.String key)
        Returns the localized resource with the specified key. Uses the CoreServer's resource bundle. The string will be escaped for usage in JavaScript.
        Parameters:
        key - the key
        Returns:
        the localized string
      • getBaseUrl

        public java.lang.String getBaseUrl()
        Gets the base url.
        Returns:
        the base url
      • getPopupBean

        public OpenDocumentBean getPopupBean​(java.lang.String popupId)
        Gets the popup-bean for this viewer-popup.
        Parameters:
        popupId - id of the popup
        Returns:
        popup-bean
      • getFileName

        public java.lang.String getFileName​(DocumentArchiveMetaInfo.ElementArchiveMetaInfo element)
        Returns the file name for the specified element. If no name is present, a default name will be returned. The filename will be escaped so that it can be used in JavaScript.
        Parameters:
        element - structure element
        Returns:
        file name
      • getFileNameWithPageNr

        public java.lang.String getFileNameWithPageNr​(DocumentArchiveMetaInfo.ElementArchiveMetaInfo element)
        Returns the file name for the specified element. If the element is a multipage tiff the name will contain the page number. If no name is present, a default name will be returned. The string will be escaped so that it can be used in HTML.
        Parameters:
        element - structure element
        Returns:
        file name
      • collectDocumentsWithoutSize

        public void collectDocumentsWithoutSize​(java.util.List<DocumentArchiveMetaInfo.ElementArchiveMetaInfo> elements)
        Collects all Elements of a given list of elements that have no file size.
        Parameters:
        elements - List of elements to check for file size existance.
      • getFileSize

        public long getFileSize​(java.lang.String hDoc,
                                int element)
        Gets the file size of a given element number for a given hDoc.
        Parameters:
        hDoc - hDoc that holds the documents.
        element - number of the element we want to know the file size of.
        Returns:
        file size of the element or 0 if an exception is thrown.
      • isViewable

        public boolean isViewable​(OpenDocumentBean bean,
                                  long maxSize)
        Checks if a specific element is viewable.
        Parameters:
        bean - OpenDocumentBean for the viewer-jsp
        maxSize - maximum allowed size
        Returns:
        true, if element's size is below maximum or if size cannot be determined
      • urlEncode

        public java.lang.String urlEncode​(java.lang.String toEncode)
                                   throws java.io.UnsupportedEncodingException
        URL-encodes a string.
        Parameters:
        toEncode - String to encode
        Returns:
        encoded string
        Throws:
        java.io.UnsupportedEncodingException - when encoding with UTF-8 failed
      • isViewerSessionMapEnabled

        public boolean isViewerSessionMapEnabled()
        Returns:
        true if the viewer-session-map is enabled (only for VirtualViewer)
      • getLocales

        public java.lang.String getLocales()
        Returns the locales as defined in the Accept-Language header. If this header is not present, the default-locale of the server is returned.
        Returns:
        the locales as requested by the client