Class ViewerJspUtil

java.lang.Object
com.saperion.ngc.viewer.ViewerJspUtil

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

    • ViewerJspUtil

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

    • webLocalize

      public String webLocalize(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 String coreLocalize(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 String webLocalizeForHtml(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 String webLocalizeForHtml(String key, Map<String,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 String coreLocalizeForHtml(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 String webLocalizeForJs(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 String coreLocalizeForJs(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 String getBaseUrl()
      Gets the base url.
      Returns:
      the base url
    • getPopupBean

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

      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 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(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(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 String urlEncode(String toEncode) throws UnsupportedEncodingException
      URL-encodes a string.
      Parameters:
      toEncode - String to encode
      Returns:
      encoded string
      Throws:
      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 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