Package org.ametys.plugins.newsletter
Class NewsletterDAO
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.newsletter.NewsletterDAO
-
- All Implemented Interfaces:
LogEnabled
,Component
,Contextualizable
,Serviceable
public class NewsletterDAO extends AbstractLogEnabled implements Serviceable, Component, Contextualizable
DAO for manipulating newsletter
-
-
Field Summary
Fields Modifier and Type Field Description static String
__NEWSLETTER_CONTENT_TYPE
Newsletter content typestatic String
__SEND_TESTING_RIGHT
Right to send a test newsletterstatic String
__TEST_UNIQUE_ID_METADATA
Metadata test-unique-idstatic String
ROLE
The Avalon role
-
Constructor Summary
Constructors Constructor Description NewsletterDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
_getBodyAsHtml(DefaultWebContent content, String dataHolderId)
Get the newsletter HTML bodyprotected String
_getBodyAsText(DefaultWebContent content, String dataHolderId)
Get the newsletter text bodyprotected String
_getSubject(DefaultWebContent content)
Get the newsletter mail subjectvoid
contextualize(Context context)
Category
getCategory(String categoryID)
Get a categoryMap<String,Object>
getNewsletterProperties(Content newsletter)
Gets newsletter's properties to JSON formatboolean
isSent(String newsletterId)
Determines if the newsletter was already sentvoid
removeTestNewsletter(WebContent content, Site site)
Remove the test newsletter if it exists in live workspacevoid
sendNewsletter(DefaultWebContent content, Map<String,String> recipients)
Send the newsletter to the recipientsvoid
sendNewsletter(DefaultWebContent content, Map<String,String> recipients, String dataHolderId)
Send the newsletter to the recipientsboolean
sendTestNewsletter(String newsletterId, String recipientEmail)
Send the newsletter to a single recipient, while ignoring the subscribers or the workflow statevoid
service(ServiceManager smanager)
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
__SEND_TESTING_RIGHT
public static final String __SEND_TESTING_RIGHT
Right to send a test newsletter- See Also:
- Constant Field Values
-
__NEWSLETTER_CONTENT_TYPE
public static final String __NEWSLETTER_CONTENT_TYPE
Newsletter content type- See Also:
- Constant Field Values
-
__TEST_UNIQUE_ID_METADATA
public static final String __TEST_UNIQUE_ID_METADATA
Metadata test-unique-id- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NewsletterDAO
public NewsletterDAO()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
isSent
public boolean isSent(String newsletterId)
Determines if the newsletter was already sent- Parameters:
newsletterId
- the id of newsletter- Returns:
- true if the newsletter was already sent
-
getNewsletterProperties
public Map<String,Object> getNewsletterProperties(Content newsletter)
Gets newsletter's properties to JSON format- Parameters:
newsletter
- The newsletter- Returns:
- The newsletter's properties
-
sendTestNewsletter
public boolean sendTestNewsletter(String newsletterId, String recipientEmail) throws IllegalAccessException
Send the newsletter to a single recipient, while ignoring the subscribers or the workflow state- Parameters:
newsletterId
- The newsletter idrecipientEmail
- The recipient- Returns:
- True if the newsletter was sent
- Throws:
IllegalAccessException
- If a user tried to send a newsletter with insufficient rights
-
sendNewsletter
public void sendNewsletter(DefaultWebContent content, Map<String,String> recipients) throws IOException
Send the newsletter to the recipients- Parameters:
content
- The newsletterrecipients
- The recipients of the newsletter- Throws:
IOException
- If an error occurred
-
sendNewsletter
public void sendNewsletter(DefaultWebContent content, Map<String,String> recipients, String dataHolderId) throws IOException
Send the newsletter to the recipients- Parameters:
content
- The newsletterrecipients
- The recipients of the newsletterdataHolderId
- The content to use as a data holder proxy for images. Can be null- Throws:
IOException
- If an error occurred
-
_getSubject
protected String _getSubject(DefaultWebContent content)
Get the newsletter mail subject- Parameters:
content
- The content- Returns:
- The subject
-
_getBodyAsHtml
protected String _getBodyAsHtml(DefaultWebContent content, String dataHolderId) throws IOException
Get the newsletter HTML body- Parameters:
content
- The contentdataHolderId
- The data holder content to use as proxy images- Returns:
- The body
- Throws:
IOException
- if an I/O error occurred
-
_getBodyAsText
protected String _getBodyAsText(DefaultWebContent content, String dataHolderId) throws IOException
Get the newsletter text body- Parameters:
content
- The contentdataHolderId
- The data holder content to use as proxy images- Returns:
- The body
- Throws:
IOException
- if an I/O error occurred
-
getCategory
public Category getCategory(String categoryID)
Get a category- Parameters:
categoryID
- The category id- Returns:
- The category
-
removeTestNewsletter
public void removeTestNewsletter(WebContent content, Site site) throws RepositoryException
Remove the test newsletter if it exists in live workspace- Parameters:
content
- The contentsite
- The site of the content- Throws:
RepositoryException
- If an error occurred
-
-