Class Util


  • public class Util
    extends Object
    • Field Detail

      • OFFICE_EXTS

        public static String[] OFFICE_EXTS
      • SPREADSHEET_EXTS

        public static String[] SPREADSHEET_EXTS
      • IMAGE_EXTS

        public static String[] IMAGE_EXTS
      • VIDEO_EXTS

        public static String[] VIDEO_EXTS
      • AUDIO_EXTS

        public static String[] AUDIO_EXTS
      • WEBCONTENT_EXTS

        public static String[] WEBCONTENT_EXTS
      • EMAIL_EXTS

        public static String[] EMAIL_EXTS
      • DICOM_EXTS

        public static String[] DICOM_EXTS
    • Constructor Detail

      • Util

        public Util()
    • Method Detail

      • imageHTML

        public static String imageHTML​(String imageName,
                                       String alt,
                                       String style)
        Generates HTML image code with style.
        Parameters:
        imageName - the name of the icon image
        alt - the image alt
        style - CSS style specification
        Returns:
        the resultant HTML
      • downloadAttachmentURL

        public static String downloadAttachmentURL​(long docId,
                                                   String fileVersion,
                                                   String attachmentFileName)
      • downloadURL

        public static String downloadURL​(long docId,
                                         String fileVersion,
                                         String suffix,
                                         boolean open)
      • downloadURL

        public static String downloadURL​(long docId,
                                         String fileVersion,
                                         boolean open)
      • downloadURL

        public static String downloadURL​(long docId,
                                         String fileVersion)
      • downloadURL

        public static String downloadURL​(long docId)
      • download

        public static void download​(String urlToRedirectTo)
      • downloadDoc

        public static void downloadDoc​(long docId)
      • displayURL

        public static String displayURL​(Long docId,
                                        Long folderId)
      • webEditorUrl

        public static String webEditorUrl​(long docId,
                                          String fileName,
                                          int height)
      • webEditorUrl

        public static String webEditorUrl​(int height)
      • videoHTML

        public static String videoHTML​(String mediaUrl,
                                       String width,
                                       String height)
        Generates HTML code for reproducing video files
        Parameters:
        mediaUrl - URL of the media file to reproduce
        width - width specification
        height - height specification
        Returns:
        the HTML content
      • audioHTML

        public static String audioHTML​(String mediaUrl)
        Generates HTML code for reproducing audio files
        Parameters:
        mediaUrl - URL of the media file to reproduce
        Returns:
        the HTML content
      • thumbnailUrl

        public static String thumbnailUrl​(long docId,
                                          String fileVersion)
      • thumbnailImgageHTML

        public static String thumbnailImgageHTML​(long docId,
                                                 String fileVersion,
                                                 Integer width,
                                                 Integer height)
      • tileUrl

        public static String tileUrl​(long docId,
                                     String fileVersion)
      • imageUrl

        public static String imageUrl​(String imageName)
      • fileNameIcon

        public static String fileNameIcon​(String iconName,
                                          int size)
      • iconWithFilename

        public static String iconWithFilename​(String iconName,
                                              String fileName)
      • avatarWithText

        public static String avatarWithText​(String userIdOrName,
                                            String text)
      • avatarWithText

        public static String avatarWithText​(Long userId,
                                            String text)
      • textWithAvatar

        public static String textWithAvatar​(Long userId,
                                            String text)
      • avatarImg

        public static String avatarImg​(Long userId,
                                       int size)
      • avatarImg

        public static String avatarImg​(String userIdOrName,
                                       int size)
      • avatarUrl

        public static String avatarUrl​(long userId)
      • avatarUrl

        public static String avatarUrl​(String userIdOrName)
      • avatarUrl

        public static String avatarUrl​(String userIdOrName,
                                       boolean avoidCaching)
      • licenseUrl

        public static String licenseUrl()
      • websocketUrl

        public static String websocketUrl()
      • toString

        public static String toString​(Object[] elements)
      • contextPath

        public static String contextPath()
      • currentSkin

        public static String currentSkin()
      • imagePrefix

        public static String imagePrefix()
      • imageHTML

        public static String imageHTML​(String imageName)
        Generates HTML image code.
        Parameters:
        imageName - the image name
        Returns:
        the resultant HTML
      • isCommunity

        public static boolean isCommunity()
      • isOfficeFile

        public static boolean isOfficeFile​(String fileName)
      • isSpreadsheetFile

        public static boolean isSpreadsheetFile​(String fileName)
      • isDICOMFile

        public static boolean isDICOMFile​(String fileName)
      • isTextFile

        public static boolean isTextFile​(String fileName)
      • isImageFile

        public static boolean isImageFile​(String fileName)
      • isWebContentFile

        public static boolean isWebContentFile​(String fileName)
      • isMediaFile

        public static boolean isMediaFile​(String fileName)
      • isAudioFile

        public static boolean isAudioFile​(String fileName)
      • isOfficeFileType

        public static boolean isOfficeFileType​(String type)
      • isEmailFile

        public static boolean isEmailFile​(String fileName)
      • formatSize

        public static String formatSize​(double size)
        Format file size in Bytes, KBytes, MBytes or GBytes.
        Parameters:
        size - The file size in bytes.
        Returns:
        The formated file size.
      • formatSizeCompact

        public static String formatSizeCompact​(double size)
        Format file size in Bytes, KB, MB, GB.
        Parameters:
        size - The file size in bytes.
        Returns:
        The formated file size.
      • formatLong

        public static String formatLong​(long number)
      • formatInt

        public static String formatInt​(int number)
      • formatSizeKB

        public static String formatSizeKB​(Object value)
      • formatSizeKB

        public static String formatSizeKB​(double size)
        Format file size in KB.
        Parameters:
        size - The file size in bytes.
        Returns:
        The formated file size.
      • formatSizeW7

        public static String formatSizeW7​(Object value)
        Format file size in Windows 7 Style.
        Parameters:
        value - The file size in bytes(can be Float, Long, Integer or String)
        Returns:
        The formated file size
      • formatSizeW7

        public static String formatSizeW7​(double size)
        Format file size in Windows 7 Style.
        Parameters:
        size - The file size in bytes.
        Returns:
        The formated file size.
      • formatSizeBytes

        public static String formatSizeBytes​(double size)
        Format file size in bytes
        Parameters:
        size - The file size in bytes
        Returns:
        the formatted size
      • formatPercentage

        public static String formatPercentage​(double value,
                                              int fixed)
        Format number percentage.
        Parameters:
        value - The value to be formatted.
        fixed - The number of decimal places.
        Returns:
        The formated value.
      • getBrowserLanguage

        public static String getBrowserLanguage()
        Get browser language
        Returns:
        The language in ISO 639 format.
      • getUserAgent

        public static String getUserAgent()
        Detects the user agent(browser's family)
        Returns:
        'opera', 'safari', 'ie6', 'ie7', 'gecko', or 'unknown'
      • copyToClipboard

        public static void copyToClipboard​(String text)
      • isValidEmail

        public static boolean isValidEmail​(String email)
      • redirect

        public static void redirect​(String url)
      • padLeft

        public static String padLeft​(String s,
                                     int n)
      • uninstallCloseWindowAlert

        public static void uninstallCloseWindowAlert()
        Removes the javascript function used to ask confirmation on window close
      • installCloseWindowAlert

        public static void installCloseWindowAlert()
        Declares the javascript function used to ask confirmation on window close
      • openEditWithOffice

        public static void openEditWithOffice​(long docId)
      • openScan

        public static void openScan()
      • openBulkCheckout

        public static void openBulkCheckout​(List<Long> unlockedIds)
      • isAllowedForUpload

        public static boolean isAllowedForUpload​(String filename)
        Checks if the passed filename can be uploaded or not on the basis of what configured in 'upload.disallow'
        Parameters:
        filename - the file name
        Returns:
        if the extension is allowed
      • detectTenant

        public static String detectTenant()
        Detect tenant specification from the request
        Returns:
        the current tenant's name
      • getLocaleInRequest

        public static String getLocaleInRequest()
      • detectLocale

        public static String detectLocale()
        Detect locale specification from the request
        Returns:
        the locale specification
      • detectKey

        public static String detectKey()
        Detect KEY specification from the request
        Returns:
        the secret KEY
      • getParameter

        public static String getParameter​(String name)
      • redirectToRoot

        public static void redirectToRoot()
      • redirectToRoot

        public static void redirectToRoot​(String moduleName)
      • redirectToSuccessUrl

        public static void redirectToSuccessUrl​(String locale)
        Redirects to the configured page after a successful login (the url specified in the j_successurl javascript variable
        Parameters:
        locale - language specification
      • redirectToLoginUrl

        public static void redirectToLoginUrl​(String tenant)
        Redirects to the configured login page (the url specified in the j_loginurl javascript variable
        Parameters:
        tenant - name of the tenant
      • getLoginUrl

        public static String getLoginUrl​(String tenant)
      • toPrimitives

        public static long[] toPrimitives​(Long[] objects)
      • getBaseName

        public static String getBaseName​(String fileName)
      • getExtension

        public static String getExtension​(String fileName)
      • setupDensity

        public static void setupDensity​(GUIInfo info)
      • waitForUpAndRunning

        public static void waitForUpAndRunning​(String tenant,
                                               String locale)
      • escapeHTML

        public static String escapeHTML​(String originalText)
        Converts some HTML specific cahrd into it's entity
        Parameters:
        originalText - the original string to filter
        Returns:
        the escaped string
      • imageBase64Src

        public static String imageBase64Src​(String imageBase64)
        Manipulates the given Base64 image specification into a Src to be uses in a <img> tag
        Parameters:
        imageBase64 - the Base64 representation of an image
        Returns:
        The Src
      • getTagsHTML

        public static String getTagsHTML​(String[] tags)
        Formats a set of tags into an HTML grid
        Parameters:
        tags - the tags to format
        Returns:
        the HTML content
      • formatDateShortISO

        public static String formatDateShortISO​(Date date)
      • encodeUTF8

        public static String encodeUTF8​(String rawString)
      • getJavascriptVariable

        public static String getJavascriptVariable​(String jsVar)