Class AbstractNotifyCommentAuthorObserver
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.web.repository.comment.AbstractNotifyCommentAuthorObserver
- All Implemented Interfaces:
Observer,LogEnabled,PluginAware,Prioritizable,Supporter<Event>,Contextualizable,Serviceable
- Direct Known Subclasses:
NotifyCommentAuthorWhenReplyingObserver,SendMailToVisitorCommentListener
public abstract class AbstractNotifyCommentAuthorObserver
extends AbstractLogEnabled
implements Observer, Serviceable, PluginAware, Contextualizable
Abstract observer to notify comment authors when a comment is created or updated.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CommentsDAOThe DAO for commentsprotected ContentHelperThe content helperprotected ContextThe avalon contextprotected I18nUtilsThe i18n utils of runtimeprotected StringThe pluginprotected PopulationContextHelperThe population context helperprotected SiteManagerThe site managerprotected UserLanguagesManagerThe user languages managerprotected UserManagerThe user managerFields inherited from interface org.ametys.core.observation.Observer
MAX_PRIORITY, MIN_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcontextualize(Context context) protected StringgetMailLanguage(Content content, Comment comment) Get the language to use for the mail notification of a commentprotected StringgetMailLanguage(Content content, User user) Get the language to use for the mail notification of a commentprotected StringgetMailLanguage(Content content, UserIdentity commentAuthor, String commentAuthorEmail) Get the language to use for the mail notification of a commentprotected StringgetMailRecipient(Comment comment) Get the email recipient for the mail notification of a commentprotected StringgetMailSender(Content content) Get the email sender for the mail notification of a commentintGet the priority for the component.protected UserresolveCommentAuthor(Content content, Comment comment) Try to resolve the user author of the comment as a User from author or email provided in the commentprotected UserresolveCommentAuthor(Content content, UserIdentity commentAuthor, String commentAuthorEmail) Try to resolve the user author of the comment as a User from author or email provided in the commentvoidservice(ServiceManager manager) voidsetPluginInfo(String pluginName, String featureName, String id) Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
_i18nUtils
The i18n utils of runtime -
_contentHelper
The content helper -
_pluginName
The plugin -
_commentsDAO
The DAO for comments -
_userManager
The user manager -
_userLanguagesManager
The user languages manager -
_populationContextHelper
The population context helper -
_siteManager
The site manager -
_context
The avalon context
-
-
Constructor Details
-
AbstractNotifyCommentAuthorObserver
public AbstractNotifyCommentAuthorObserver()
-
-
Method Details
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
contextualize
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
setPluginInfo
Description copied from interface:PluginAwareSets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.- Specified by:
setPluginInfoin interfacePluginAware- Parameters:
pluginName- Unique identifier for the plugin hosting the extensionfeatureName- Unique feature identifier (unique for a given pluginName)id- Unique identifier of this component
-
getPriority
Description copied from interface:PrioritizableGet the priority for the component. On components usingPrioritizableinterface, each implementation define the order. In most cases, less is the number, more prior is the component.- Specified by:
getPriorityin interfacePrioritizable- Returns:
- the priority
-
getMailLanguage
Get the language to use for the mail notification of a comment- Parameters:
content- The content commentedcomment- The comment it self- Returns:
- The language to use for the mail notification of a comment
-
getMailLanguage
protected String getMailLanguage(Content content, UserIdentity commentAuthor, String commentAuthorEmail) Get the language to use for the mail notification of a comment- Parameters:
content- The content commentedcommentAuthor- The user identity of the comment's author if it exists (null for unauthenticated comment), used to get the user's languagecommentAuthorEmail- The email of the comment's author, used to find a user with this email on the content's site and get its language if the author user identity is not provided- Returns:
- The language to use for the mail notification of a comment
-
getMailLanguage
Get the language to use for the mail notification of a comment- Parameters:
content- The content commenteduser- The user to notify. Can be null, in this case the content's language or the default language will be used- Returns:
- The language to use for the mail notification of a comment
-
resolveCommentAuthor
Try to resolve the user author of the comment as a User from author or email provided in the comment- Parameters:
content- the commented contentcomment- the comment- Returns:
- The user author or null if not found
-
resolveCommentAuthor
protected User resolveCommentAuthor(Content content, UserIdentity commentAuthor, String commentAuthorEmail) Try to resolve the user author of the comment as a User from author or email provided in the comment- Parameters:
content- The content commentedcommentAuthor- The user identity of the comment's author if it exists (null for unauthenticated comment), used to get the user's languagecommentAuthorEmail- The email of the comment's author, used to find a user with this email on the content's site and get its language if the author user identity is not provided- Returns:
- The user author or null if not found
-
getMailSender
Get the email sender for the mail notification of a comment- Parameters:
content- The content commented- Returns:
- The email sender for the mail notification of a comment
-
getMailRecipient
Get the email recipient for the mail notification of a comment- Parameters:
comment- The comment- Returns:
- The email recipient for the mail notification of a comment. Can be null or empty.
-