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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected 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) getCategory
(String categoryID) Get a categorygetNewsletterProperties
(Content newsletter) Gets newsletter's properties to JSON formatboolean
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 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:
service
in interfaceServiceable
- Throws:
ServiceException
-
contextualize
- Specified by:
contextualize
in 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 content- Returns:
- The subject
-
_getBodyAsHtml
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
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
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
-