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 the AmetysObject
All Implemented Interfaces:
AsyncObserver, Observer, LogEnabled, Component, Serviceable
Direct Known Subclasses:
NotifyContentMentionsObserver

Abstract observer to send mails to mentioned users in contributor comments of AmetysObject
  • Field Details

  • Constructor Details

  • Method Details

    • service

      public void service(ServiceManager manager) throws ServiceException
      Specified by:
      service in interface Serviceable
      Throws:
      ServiceException
    • getPriority

      public int getPriority(Event event)
      Description copied from interface: Observer
      Retrieves the priority to observe this event.
      This can be used to process a supported event before others observers.
      Specified by:
      getPriority in interface Observer
      Parameters:
      event - the event.
      Returns:
      the priority where 0 the max priority and Integer.MAX_VALUE the min priority.
    • observe

      public void observe(Event event, Map<String,Object> transientVars) throws Exception
      Description copied from interface: Observer
      Observes an event.
      Specified by:
      observe in interface Observer
      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

      protected I18nizableText _getMailSubject(T ametysObject)
      Retrieves the notification mail's subject
      Parameters:
      ametysObject - the ametys object
      Returns:
      the notification mail's subject
    • _getAmetysObjectTitle

      protected String _getAmetysObjectTitle(T ametysObject)
      Retrieves the string to use to display the ametys object in the email
      Parameters:
      ametysObject - the ametysObject
      Returns:
      the ametys object's title
    • _getLinkToAmetysObject

      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 content
      recipient - the recipient user identity
      allMentionedUsers - all the users mentioned in the comment
      Returns:
      the content with replaced mentioned
    • _getUserFromIdentity

      protected Optional<User> _getUserFromIdentity(UserIdentity userIdentity)
      Retrieves the User object from the given UserIdentity
      Parameters:
      userIdentity - the user identity
      Returns:
      the corresponding User object, or an empty optional if the user does not exists
    • _getLanguage

      protected abstract String _getLanguage(T ametysObject)
      Retrieves the language to use in sent mails
      Parameters:
      ametysObject - the ametys object
      Returns:
      the language to use in sent mails