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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String_getBodyAsHtml(DefaultWebContent content, String dataHolderId, String language) Get the newsletter HTML bodyprotected String_getBodyAsText(DefaultWebContent content, String dataHolderId, String language) Get the newsletter text bodyprotected String_getSubject(DefaultWebContent content, String language) Get the newsletter mail subjectvoidcontextualize(Context context) getCategory(String categoryID) Get a categorygetNewsletterProperties(Content newsletter) Gets newsletter's properties to JSON formatbooleanDetermines if the newsletter was already sentvoidremoveTestNewsletter(WebContent content, Site site) Remove the test newsletter if it exists in live workspacevoidsendNewsletter(DefaultWebContent content, Map<String, String> recipients) Send the newsletter to the recipientsvoidsendNewsletter(DefaultWebContent content, Map<String, String> recipients, String dataHolderId) Send the newsletter to the recipientsbooleansendTestNewsletter(String newsletterId, String recipientEmail) Send the newsletter to a single recipient, while ignoring the subscribers or the workflow statevoidservice(ServiceManager smanager) Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The Avalon role -
__SEND_TESTING_RIGHT
Right to send a test newsletter- See Also:
-
__NEWSLETTER_CONTENT_TYPE
Newsletter content type- See Also:
-
__TEST_UNIQUE_ID_METADATA
Metadata test-unique-id- See Also:
-
-
Constructor Details
-
NewsletterDAO
public NewsletterDAO()
-
-
Method Details
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
contextualize
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
isSent
Determines if the newsletter was already sent- Parameters:
newsletterId- the id of newsletter- Returns:
- true if the newsletter was already sent
-
getNewsletterProperties
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 IOExceptionSend 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 IOExceptionSend 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
Get the newsletter mail subject- Parameters:
content- The contentlanguage- The language to use- Returns:
- The subject
-
_getBodyAsHtml
protected String _getBodyAsHtml(DefaultWebContent content, String dataHolderId, String language) throws IOException Get the newsletter HTML body- Parameters:
content- The contentdataHolderId- The data holder content to use as proxy imageslanguage- The language to use- Returns:
- The body
- Throws:
IOException- if an I/O error occurred
-
_getBodyAsText
protected String _getBodyAsText(DefaultWebContent content, String dataHolderId, String language) throws IOException Get the newsletter text body- Parameters:
content- The contentdataHolderId- The data holder content to use as proxy imageslanguage- The language to use- Returns:
- The body
- Throws:
IOException- if an I/O error occurred
-
getCategory
Get a category- Parameters:
categoryID- The category id- Returns:
- The category
-
removeTestNewsletter
public void removeTestNewsletter(WebContent content, Site site) throws javax.jcr.RepositoryException Remove the test newsletter if it exists in live workspace- Parameters:
content- The contentsite- The site of the content- Throws:
javax.jcr.RepositoryException- If an error occurred
-