Class AbstractNotifyMentionsObserver<T extends AmetysObject>
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.cms.repository.comment.contributor.AbstractNotifyMentionsObserver<T>
- Type Parameters:
T- type of theAmetysObject
- All Implemented Interfaces:
AsyncObserver,Observer,LogEnabled,Component,Serviceable
- Direct Known Subclasses:
NotifyContentMentionsObserver
public abstract class AbstractNotifyMentionsObserver<T extends AmetysObject>
extends AbstractLogEnabled
implements Component, Serviceable, AsyncObserver
Abstract observer to send mails to mentioned users in contributor comments of
AmetysObject-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordLink to the ametys object -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CurrentUserProviderThe current user providerprotected I18nUtilsThe i18n utils.protected Map<UserIdentity,User> Cache for resolved usersprotected AmetysObjectResolverThe ametys object resolverprotected UserManagerThe user managerFields inherited from interface org.ametys.core.observation.Observer
MAX_PRIORITY, MIN_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String_getAmetysObjectTitle(T ametysObject) Retrieves the string to use to display the ametys object in the emailprotected String_getCommentContentWithReplacedMentions(String commentContent, UserIdentity recipient, Collection<UserIdentity> allMentionedUsers) Retrieves the given comment content with mentioned replaced by the version to display in notificationprotected abstract String_getLanguage(T ametysObject) Retrieves the language to use in sent mailsprotected abstract AbstractNotifyMentionsObserver.LinkToAmetysObject_getLinkToAmetysObject(T ametysObject) Retrieves the notification mail's body link to ametys objectprotected I18nizableText_getMailSubject(T ametysObject) Retrieves the notification mail's subject_getUserFromIdentity(UserIdentity userIdentity) Retrieves theUserobject from the givenUserIdentityintgetPriority(Event event) Retrieves the priority to observe this event.
This can be used to process a supported event before others observers.voidObserves an event.voidservice(ServiceManager manager) Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLoggerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.ametys.core.observation.AsyncObserver
parallelizable
-
Field Details
-
_resolver
The ametys object resolver -
_userManager
The user manager -
_currentUserProvider
The current user provider -
_i18nUtils
The i18n utils. -
_resolvedUsers
Cache for resolved users
-
-
Constructor Details
-
AbstractNotifyMentionsObserver
public AbstractNotifyMentionsObserver()
-
-
Method Details
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
getPriority
Description copied from interface:ObserverRetrieves the priority to observe this event.
This can be used to process a supported event before others observers.- Specified by:
getPriorityin interfaceObserver- Parameters:
event- the event.- Returns:
- the priority where 0 the max priority and Integer.MAX_VALUE the min priority.
-
observe
Description copied from interface:ObserverObserves an event.- Specified by:
observein interfaceObserver- Parameters:
event- the event.transientVars- transientVars passed from one Observer to another when processing a single Event. This may allow optimizations between observers.- Throws:
Exception- if an error occurs. All exceptions will be logged but not propagated, as the observation mechanism should never fail.
-
_getMailSubject
Retrieves the notification mail's subject- Parameters:
ametysObject- the ametys object- Returns:
- the notification mail's subject
-
_getAmetysObjectTitle
Retrieves the string to use to display the ametys object in the email- Parameters:
ametysObject- the ametysObject- Returns:
- the ametys object's title
-
_getLinkToAmetysObject
protected abstract AbstractNotifyMentionsObserver.LinkToAmetysObject _getLinkToAmetysObject(T ametysObject) Retrieves the notification mail's body link to ametys object- Parameters:
ametysObject- the ametys object- Returns:
- the notification mail's body link
-
_getCommentContentWithReplacedMentions
protected String _getCommentContentWithReplacedMentions(String commentContent, UserIdentity recipient, Collection<UserIdentity> allMentionedUsers) Retrieves the given comment content with mentioned replaced by the version to display in notification- Parameters:
commentContent- the original comment contentrecipient- the recipient user identityallMentionedUsers- all the users mentioned in the comment- Returns:
- the content with replaced mentioned
-
_getUserFromIdentity
Retrieves theUserobject from the givenUserIdentity- Parameters:
userIdentity- the user identity- Returns:
- the corresponding
Userobject, or an empty optional if the user does not exists
-
_getLanguage
Retrieves the language to use in sent mails- Parameters:
ametysObject- the ametys object- Returns:
- the language to use in sent mails
-