Class NewsletterService

java.lang.Object
fr.paris.lutece.plugins.newsletter.service.NewsletterService
All Implemented Interfaces:
Serializable

public class NewsletterService extends Object implements Serializable
The newsletter service
See Also:
  • Field Details

  • Constructor Details

    • NewsletterService

      public NewsletterService()
  • Method Details

    • getService

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

      public void sendMail(NewsLetter newsletter, String strObject, String strBaseUrl, fr.paris.lutece.util.html.HtmlTemplate templateNewsletter, 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 String generateNewsletterHtmlCode(NewsLetter newsletter, int nTemplateNewsLetterId, String strBaseUrl, fr.paris.lutece.portal.business.user.AdminUser user, 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 String getImageFolderPath(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 String getUnsecuredImagefolder()
      Get the unsecured image folder inside the unsecured folder
      Returns:
      The unsecured image folder inside the unsecured folder
    • getUnsecuredFolderPath

      public 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 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 String getUnsubscriptionKey(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, Locale locale)
      Copy existing newsletter without its subscribers.
      Parameters:
      newsletter - newsletter to copy
      user - the current user
      locale - The locale