fr.paris.lutece.plugins.newsletter.service
Class NewsletterService

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

public class NewsletterService
extends Object
implements Serializable

The newsletter service

See Also:
Serialized Form

Field Summary
static String BEAN_NAME
          Name of the bean of this service
 
Constructor Summary
NewsletterService()
           
 
Method Summary
 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
 String getImageFolderPath(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
 String getUnsecuredFolderPath()
          Get the absolute path to the unsecured folder where files should be saved
 String getUnsecuredImagefolder()
          Get the unsecured image folder inside the unsecured folder
 String getUnsecuredWebappUrl()
          Get the absolute url to the unsecured webapp.
 String getUnsubscriptionKey(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, String strObject, String strBaseUrl, fr.paris.lutece.util.html.HtmlTemplate templateNewsletter, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BEAN_NAME

public static final 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,
                     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


Copyright © 2013 Mairie de Paris. All Rights Reserved.