Class NewsletterUtils


  • public final class NewsletterUtils
    extends java.lang.Object
    This classe provides utility methods for newsletters.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addHeaderResponse​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String strFileName, java.lang.String strFileExtension)
      Addition of information as header of the http response
      static void addParameters​(fr.paris.lutece.util.url.UrlItem urlItem, java.lang.String strParameterName, java.lang.String[] values)
      Adds all parameter values to the urlItem
      static java.lang.String convertForJavascript​(java.lang.String strIn)
      Cleans a string in order to make it usable in a javascript script
      static java.lang.String encodeForURL​(java.lang.String strEntry)
      Encode a string for passage in parameter in URL
      static java.lang.String getHtmlTemplatePath​(int nTemplateId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Retrieve the html template for the given template id
      static java.util.Locale getLocale​(javax.servlet.ServletRequest request)  
      static java.lang.String getStringFromStringArray​(java.lang.String[] strArrayValues)
      Get the first String of a String array.
      static java.lang.String rewriteUrls​(java.lang.String strContent, java.lang.String strBaseUrl)
      Rewrite relatives url to absolutes urls
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getHtmlTemplatePath

        public static java.lang.String getHtmlTemplatePath​(int nTemplateId,
                                                           fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Retrieve the html template for the given template id
        Parameters:
        nTemplateId - the id of the template to retrieve
        plugin - the plugin
        Returns:
        the html template to use of null if no NewsletterTemplate found for this Id
      • convertForJavascript

        public static java.lang.String convertForJavascript​(java.lang.String strIn)
        Cleans a string in order to make it usable in a javascript script
        Parameters:
        strIn - the string to clean
        Returns:
        the javascript escaped String
      • encodeForURL

        public static java.lang.String encodeForURL​(java.lang.String strEntry)
        Encode a string for passage in parameter in URL
        Parameters:
        strEntry - the string entry
        Returns:
        the string encoding
      • addHeaderResponse

        public static void addHeaderResponse​(javax.servlet.http.HttpServletRequest request,
                                             javax.servlet.http.HttpServletResponse response,
                                             java.lang.String strFileName,
                                             java.lang.String strFileExtension)
        Addition of information as header of the http response
        Parameters:
        request - The Http Request
        response - The Http Response
        strFileName - THe filename of the file
        strFileExtension - The file extension
      • addParameters

        public static void addParameters​(fr.paris.lutece.util.url.UrlItem urlItem,
                                         java.lang.String strParameterName,
                                         java.lang.String[] values)
        Adds all parameter values to the urlItem
        Parameters:
        urlItem - the urlItem
        strParameterName - the name of the parameter which has multiple values
        values - parameter values
      • getStringFromStringArray

        public static java.lang.String getStringFromStringArray​(java.lang.String[] strArrayValues)
        Get the first String of a String array. If the array is null, or if it has no element, then return null.
        Parameters:
        strArrayValues - The string array to get the first element of.
        Returns:
        The first element of the array, or null if the array has no element or is null.
      • rewriteUrls

        public static java.lang.String rewriteUrls​(java.lang.String strContent,
                                                   java.lang.String strBaseUrl)
        Rewrite relatives url to absolutes urls
        Parameters:
        strContent - The content to analyze
        strBaseUrl - The base url
        Returns:
        The converted content
      • getLocale

        public static java.util.Locale getLocale​(javax.servlet.ServletRequest request)