Class EmailNotificationHandler

java.lang.Object
org.openremote.manager.notification.EmailNotificationHandler
All Implemented Interfaces:
NotificationHandler, org.openremote.model.ContainerService

public class EmailNotificationHandler extends Object implements NotificationHandler
  • Field Details

    • defaultFrom

      protected String defaultFrom
    • mailSession

      protected jakarta.mail.Session mailSession
    • mailTransport

      protected jakarta.mail.Transport mailTransport
    • headers

      protected Map<String,String> headers
    • managerIdentityService

      protected ManagerIdentityService managerIdentityService
    • assetStorageService

      protected AssetStorageService assetStorageService
  • Constructor Details

    • EmailNotificationHandler

      public EmailNotificationHandler()
  • Method Details

    • getPriority

      public int getPriority()
      Specified by:
      getPriority in interface org.openremote.model.ContainerService
    • init

      public void init(org.openremote.model.Container container) throws Exception
      Specified by:
      init in interface org.openremote.model.ContainerService
      Throws:
      Exception
    • start

      public void start(org.openremote.model.Container container) throws Exception
      Specified by:
      start in interface org.openremote.model.ContainerService
      Throws:
      Exception
    • stop

      public void stop(org.openremote.model.Container container) throws Exception
      Specified by:
      stop in interface org.openremote.model.ContainerService
      Throws:
      Exception
    • isValid

      public boolean isValid()
      Description copied from interface: NotificationHandler
      Indicates if this handler has a valid configuration and is usable.
      Specified by:
      isValid in interface NotificationHandler
    • getTypeName

      public String getTypeName()
      Description copied from interface: NotificationHandler
      The unique type name; it must correspond with the value set in AbstractNotificationMessage.getType() so that AbstractNotificationMessages can be mapped to a NotificationHandler.
      Specified by:
      getTypeName in interface NotificationHandler
    • isMessageValid

      public boolean isMessageValid(org.openremote.model.notification.AbstractNotificationMessage message)
      Description copied from interface: NotificationHandler
      Allows the handler to validate the specified AbstractNotificationMessage.
      Specified by:
      isMessageValid in interface NotificationHandler
    • getTargets

      public List<org.openremote.model.notification.Notification.Target> getTargets(org.openremote.model.notification.Notification.Source source, String sourceId, List<org.openremote.model.notification.Notification.Target> targets, org.openremote.model.notification.AbstractNotificationMessage message)
      Description copied from interface: NotificationHandler
      Map the requested targets to one or more targets that are compatible with this handler; if there are no compatible targets then return null. If the requested target is already compatible then it can just be returned; handlers are free to determine how the requested target should be mapped (e.g. if requested Notification.TargetType was Notification.TargetType.REALM and this handler only supports targets of type Notification.TargetType.ASSET where the Assets must be ConsoleAsset then the handler needs to find all console assets that belong to the specified realm). Handlers can also add extra Notification.TargetType.CUSTOM handlers extracted from the message.
      Specified by:
      getTargets in interface NotificationHandler
    • sendMessage

      public void sendMessage(long id, org.openremote.model.notification.Notification.Source source, String sourceId, org.openremote.model.notification.Notification.Target target, org.openremote.model.notification.AbstractNotificationMessage message) throws Exception
      Description copied from interface: NotificationHandler
      Send the specified AbstractNotificationMessage to the target; the target supplied would be a target previously returned by NotificationHandler.getTargets(org.openremote.model.notification.Notification.Source, java.lang.String, java.util.List<org.openremote.model.notification.Notification.Target>, org.openremote.model.notification.AbstractNotificationMessage). It is the responsibility of the NotificationHandler to maintain any required cache to ensure this call is as performant as possible (i.e. the handler should avoid making excessive DB calls if possible).

      The ID can be used by the NotificationHandler to update the delivered and/or acknowledged status of the notification by calling NotificationService.setNotificationDelivered(long) or NotificationService.setNotificationAcknowledged(long, java.lang.String)

      Specified by:
      sendMessage in interface NotificationHandler
      Throws:
      Exception
    • sendMessage

      protected void sendMessage(jakarta.mail.Message email) throws Exception
      Throws:
      Exception
    • buildEmail

      protected void buildEmail(long id, org.openremote.model.notification.EmailNotificationMessage emailNotificationMessage, jakarta.mail.internet.MimeMessage email) throws Exception
      Throws:
      Exception
    • convertRecipient

      protected jakarta.mail.internet.InternetAddress convertRecipient(org.openremote.model.notification.EmailNotificationMessage.Recipient recipient)