Class NewsletterService

  • All Implemented Interfaces:
    java.io.Serializable

    public class NewsletterService
    extends java.lang.Object
    implements java.io.Serializable
    The newsletter service
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String BEAN_NAME
      Name of the bean of this service
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void copyExistingNewsletter​(NewsLetter newsletter, fr.paris.lutece.portal.business.user.AdminUser user, java.util.Locale locale)
      Copy existing newsletter without its subscribers.
      java.lang.String generateNewsletterHtmlCode​(NewsLetter newsletter, int nTemplateNewsLetterId, java.lang.String strBaseUrl, fr.paris.lutece.portal.business.user.AdminUser user, java.util.Locale locale)
      Generate the html code of the newsletter according to the document and newsletter templates
      java.lang.String getImageFolderPath​(java.lang.String strBaseUrl)
      Get the url of the image folder used by templates
      static NewsletterService getService()
      Returns the instance of the singleton
      byte[] getSubscribersCsvExport​(int nNewsletterId)
      Fetches the list of subscribers on a specific newsletter
      java.lang.String getUnsecuredFolderPath()
      Get the absolute path to the unsecured folder where files should be saved
      java.lang.String getUnsecuredImagefolder()
      Get the unsecured image folder inside the unsecured folder
      java.lang.String getUnsecuredWebappUrl()
      Get the absolute url to the unsecured webapp.
      java.lang.String getUnsubscriptionKey​(java.lang.String strEmail)
      Get the unsubscription key associated with the given email address.
      boolean isAbsoluteUrl()
      Check the property in property file to know if url must be absolutes or relatives
      boolean isMhtmlActivated()
      Determine if mails must be sent in MHTML
      void modifySectionNumber​(int nOldSectionNumber, int nNewSectionNumber, int nTemplateId)
      Modify the number of sections of a newsletter template
      void removeSubscriberFromNewsletter​(Subscriber subscriber, int nNewsletterId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Remove a known suscriber from a newsletter
      void sendMail​(NewsLetter newsletter, java.lang.String strObject, java.lang.String strBaseUrl, fr.paris.lutece.util.html.HtmlTemplate templateNewsletter, java.util.Collection<Subscriber> listSubscribers)
      Send the newsletter to a list of subscribers
      boolean useUnsecuredImages()
      Check if images of the newsletter should be transfered on an unsecured webapp or not
      • Methods inherited from class java.lang.Object

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

      • BEAN_NAME

        public static final java.lang.String BEAN_NAME
        Name of the bean of this service
        See Also:
        Constant Field Values
    • Constructor Detail

      • NewsletterService

        public NewsletterService()
    • Method Detail

      • getService

        public static NewsletterService getService()
        Returns the instance of the singleton
        Returns:
        The instance of the singleton
      • sendMail

        public void sendMail​(NewsLetter newsletter,
                             java.lang.String strObject,
                             java.lang.String strBaseUrl,
                             fr.paris.lutece.util.html.HtmlTemplate templateNewsletter,
                             java.util.Collection<Subscriber> listSubscribers)
        Send the newsletter to a list of subscribers
        Parameters:
        newsletter - The newsletter to send
        strObject - The email object
        strBaseUrl - The baseUrl (can be prod url)
        templateNewsletter - The generated template
        listSubscribers - The list of subscribers (date and id can be null, only email is used)
      • isAbsoluteUrl

        public boolean isAbsoluteUrl()
        Check the property in property file to know if url must be absolutes or relatives
        Returns:
        true if absolute or false else
      • isMhtmlActivated

        public boolean isMhtmlActivated()
        Determine if mails must be sent in MHTML
        Returns:
        true whether MHTML is needed
      • getSubscribersCsvExport

        public byte[] getSubscribersCsvExport​(int nNewsletterId)
        Fetches the list of subscribers on a specific newsletter
        Parameters:
        nNewsletterId - The id of the newsletter
        Returns:
        The byte representation of the list of subscribers
      • removeSubscriberFromNewsletter

        public void removeSubscriberFromNewsletter​(Subscriber subscriber,
                                                   int nNewsletterId,
                                                   fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Remove a known suscriber from a newsletter
        Parameters:
        subscriber - the subscriber to remove
        nNewsletterId - the newsletter id from which to remove the subscriber
        plugin - The plugin object
      • generateNewsletterHtmlCode

        public java.lang.String generateNewsletterHtmlCode​(NewsLetter newsletter,
                                                           int nTemplateNewsLetterId,
                                                           java.lang.String strBaseUrl,
                                                           fr.paris.lutece.portal.business.user.AdminUser user,
                                                           java.util.Locale locale)
        Generate the html code of the newsletter according to the document and newsletter templates
        Parameters:
        newsletter - the newsletter to generate the HTML of
        nTemplateNewsLetterId - the newsletter template id
        strBaseUrl - The base url of the portal
        user - the current user
        locale - The locale
        Returns:
        the html code for the newsletter content of null if no template available
      • getImageFolderPath

        public java.lang.String getImageFolderPath​(java.lang.String strBaseUrl)
        Get the url of the image folder used by templates
        Parameters:
        strBaseUrl - The base url
        Returns:
        The absolute url of the folder containing images of templates.
      • useUnsecuredImages

        public boolean useUnsecuredImages()
        Check if images of the newsletter should be transfered on an unsecured webapp or not
        Returns:
        True if images of the newsletter should be transfered on an unsecured webapp, false otherwise
      • getUnsecuredImagefolder

        public java.lang.String getUnsecuredImagefolder()
        Get the unsecured image folder inside the unsecured folder
        Returns:
        The unsecured image folder inside the unsecured folder
      • getUnsecuredFolderPath

        public java.lang.String getUnsecuredFolderPath()
        Get the absolute path to the unsecured folder where files should be saved
        Returns:
        The absolute path to the unsecured folder where files should be saved, or the webapp path if none is defined
      • getUnsecuredWebappUrl

        public java.lang.String getUnsecuredWebappUrl()
        Get the absolute url to the unsecured webapp.
        Returns:
        The absolute url to the unsecured webapp, or the base url of this webapp if none is defined
      • getUnsubscriptionKey

        public java.lang.String getUnsubscriptionKey​(java.lang.String strEmail)
        Get the unsubscription key associated with the given email address.
        Parameters:
        strEmail - The email to get the unsubscription key of.
        Returns:
        The unsubscription key of the email
      • modifySectionNumber

        public void modifySectionNumber​(int nOldSectionNumber,
                                        int nNewSectionNumber,
                                        int nTemplateId)
        Modify the number of sections of a newsletter template
        Parameters:
        nOldSectionNumber - The old number of sections
        nNewSectionNumber - The new number of sections
        nTemplateId - The id of the template
      • copyExistingNewsletter

        public void copyExistingNewsletter​(NewsLetter newsletter,
                                           fr.paris.lutece.portal.business.user.AdminUser user,
                                           java.util.Locale locale)
        Copy existing newsletter without its subscribers.
        Parameters:
        newsletter - newsletter to copy
        user - the current user
        locale - The locale