Class FileServerUtils


  • public class FileServerUtils
    extends Object
    Version:
    Author:
    NEY
    • Constructor Detail

      • FileServerUtils

        public FileServerUtils()
    • Method Detail

      • replaceSpecialChars

        public static String replaceSpecialChars​(String toParse)
        Replace chars that have special meanings in url by their http substitute.
        Parameters:
        toParse - the string which chars that have special meanings in url by their http substitute.
        Returns:
        a string without url meaning chars.
      • replaceAccentChars

        public static String replaceAccentChars​(String toParse)
        Replace accented chars from a string.
        Parameters:
        toParse - the string which accented chars are replaced by non-accented chars.
        Returns:
        a string with all its accented chars replaced.
      • getWebUrl

        public static String getWebUrl​(String componentId,
                                       String logicalName,
                                       String physicalName,
                                       String mimeType,
                                       String subDirectory)
        Return the full url to access an attachment from web site
        Parameters:
        componentId -
        logicalName -
        physicalName -
        mimeType -
        subDirectory -
        Returns:
      • getImageURL

        public static String getImageURL​(String originalImageURL,
                                         String sizeParams)
        Gets the URL of the specified image with the specified size.

        Each image uploaded in Silverpeas are kept with their original size. From them, a set of resized images are computed. This method is to get the URL of the resized version of an uploaded image.

        Parameters:
        originalImageURL - the URL of the original, non-resized, image.
        sizeParams - the size of the image to get. The size can be specified either a key in the org.silverpeas.lookAndFeel.generalLook bundle or as a dimension. The keys of the properties indicating an image size are always prefixed by the 'image.size' term. The dimension of an image must be in the form of WIDTHxHEIGHT with WIDTH the width in pixels of the image and HEIGHT the height in pixels of the image. WIDTH or HEIGHT can be omitted but the 'x' character is required. If null, empty or or not well formed, the original image URL is then returned.
        Returns:
        the URL of the image with the specified size.
      • getUrlToTempDir

        public static String getUrlToTempDir​(String logicalName)
      • replaceInvalidPathChars

        public static String replaceInvalidPathChars​(String toParse)
        Replace chars from filename String which can't be used in a file name with '_'.
        Parameters:
        toParse - the name of the file.
        Returns:
        the name of the file with incorrect chars replaced by '_'.
      • getApplicationContext

        public static String getApplicationContext()