Package com.saperion.ngc.viewer
Class ViewerJspUtil
java.lang.Object
com.saperion.ngc.viewer.ViewerJspUtil
Utility class with common helper methods for the viewer-JSPs.
-
Constructor Summary
ConstructorsConstructorDescriptionViewerJspUtil
(jakarta.servlet.http.HttpServletRequest request) Instantiates a new viewer jsp util. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Collects all Elements of a given list of elements that have no file size.coreLocalize
(String key) Returns the localized resource with the specified key.Returns the localized resource with the specified key.coreLocalizeForJs
(String key) Returns the localized resource with the specified key.Gets the base url.Returns the file name for the specified element.Returns the file name for the specified element.long
getFileSize
(String hDoc, int element) Gets the file size of a given element number for a given hDoc.Returns the locales as defined in the Accept-Language header.getPopupBean
(String popupId) Gets the popup-bean for this viewer-popup.boolean
isViewable
(OpenDocumentBean bean, long maxSize) Checks if a specific element is viewable.boolean
URL-encodes a string.webLocalize
(String key) Returns the localized resource with the specified key.webLocalizeForHtml
(String key) Returns the localized resource with the specified key.webLocalizeForHtml
(String key, Map<String, String> replacements) Returns the localized resource with the specified key.webLocalizeForJs
(String key) Returns the localized resource with the specified key.
-
Constructor Details
-
ViewerJspUtil
public ViewerJspUtil(jakarta.servlet.http.HttpServletRequest request) Instantiates a new viewer jsp util.- Parameters:
request
- the request
-
-
Method Details
-
webLocalize
Returns the localized resource with the specified key. Uses the WebClient's resource bundle.- Parameters:
key
- the key- Returns:
- the localized string
-
coreLocalize
Returns the localized resource with the specified key. Uses the CoreServer's resource bundle.- Parameters:
key
- the key- Returns:
- the localized string
-
webLocalizeForHtml
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
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 keyreplacements
- strings to replace in the localized string- Returns:
- the localized string
-
coreLocalizeForHtml
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
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
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
Gets the base url.- Returns:
- the base url
-
getPopupBean
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
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
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
Checks if a specific element is viewable.- Parameters:
bean
- OpenDocumentBean for the viewer-jspmaxSize
- maximum allowed size- Returns:
- true, if element's size is below maximum or if size cannot be determined
-
urlEncode
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
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
-