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_TYPENewsletter content typestatic String__SEND_TESTING_RIGHTRight to send a test newsletterstatic String__TEST_UNIQUE_ID_METADATAMetadata test-unique-idprivate CategoryProviderExtensionPoint_categoryProviderEPprivate Context_contextprivate CurrentUserProvider_currentUserProviderprivate RenderingContextHandler_renderingContextHandlerprivate Repository_repositoryprivate AmetysObjectResolver_resolverprivate SiteManager_siteManagerprivate SourceResolver_sourceResolverstatic StringROLEThe Avalon role
-
Constructor Summary
Constructors Constructor Description NewsletterDAO()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private String_createDataHolderContent(Site site, WebContent realContent, String uid, RichText richText)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 subjectprivate String_useDataHolderContent(Site site, WebContent realContent, String uid)voidcontextualize(Context context)CategorygetCategory(String categoryID)Get a categoryMap<String,Object>getNewsletterProperties(Content newsletter)Gets newsletter's properties to JSON formatbooleanisSent(String newsletterId)Determines 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 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
-
_resolver
private AmetysObjectResolver _resolver
-
_currentUserProvider
private CurrentUserProvider _currentUserProvider
-
_renderingContextHandler
private RenderingContextHandler _renderingContextHandler
-
_sourceResolver
private SourceResolver _sourceResolver
-
_categoryProviderEP
private CategoryProviderExtensionPoint _categoryProviderEP
-
_siteManager
private SiteManager _siteManager
-
_repository
private Repository _repository
-
-
Constructor Detail
-
NewsletterDAO
public NewsletterDAO()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualizein 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
-
_useDataHolderContent
private String _useDataHolderContent(Site site, WebContent realContent, String uid)
-
_createDataHolderContent
private String _createDataHolderContent(Site site, WebContent realContent, String uid, RichText richText) throws RepositoryException, IOException
- Throws:
RepositoryExceptionIOException
-
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
-
-