Class EmailNotificationHandler
java.lang.Object
org.openremote.manager.notification.EmailNotificationHandler
- All Implemented Interfaces:
NotificationHandler,org.openremote.model.ContainerService
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AssetStorageServiceprotected Stringprotected jakarta.mail.Sessionprotected jakarta.mail.Transportprotected ManagerIdentityServiceFields inherited from interface org.openremote.model.ContainerService
DEFAULT_PRIORITY, HIGH_PRIORITY, LOW_PRIORITY, MED_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbuildEmail(long id, org.openremote.model.notification.EmailNotificationMessage emailNotificationMessage, jakarta.mail.internet.MimeMessage email) protected jakarta.mail.internet.InternetAddressconvertRecipient(org.openremote.model.notification.EmailNotificationMessage.Recipient recipient) intList<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) Map the requested targets to one or more targets that are compatible with this handler; if there are no compatible targets then return null.The unique type name; it must correspond with the value set inAbstractNotificationMessage.getType()so thatAbstractNotificationMessages can be mapped to aNotificationHandler.voidinit(org.openremote.model.Container container) booleanisMessageValid(org.openremote.model.notification.AbstractNotificationMessage message) Allows the handler to validate the specifiedAbstractNotificationMessage.booleanisValid()Indicates if this handler has a valid configuration and is usable.voidsendMessage(long id, org.openremote.model.notification.Notification.Source source, String sourceId, org.openremote.model.notification.Notification.Target target, org.openremote.model.notification.AbstractNotificationMessage message) Send the specifiedAbstractNotificationMessageto the target; the target supplied would be a target previously returned byNotificationHandler.getTargets(org.openremote.model.notification.Notification.Source, java.lang.String, java.util.List<org.openremote.model.notification.Notification.Target>, org.openremote.model.notification.AbstractNotificationMessage).protected voidsendMessage(jakarta.mail.Message email) voidstart(org.openremote.model.Container container) voidstop(org.openremote.model.Container container)
-
Field Details
-
defaultFrom
-
mailSession
protected jakarta.mail.Session mailSession -
mailTransport
protected jakarta.mail.Transport mailTransport -
headers
-
managerIdentityService
-
assetStorageService
-
-
Constructor Details
-
EmailNotificationHandler
public EmailNotificationHandler()
-
-
Method Details
-
getPriority
public int getPriority()- Specified by:
getPriorityin interfaceorg.openremote.model.ContainerService
-
init
- Specified by:
initin interfaceorg.openremote.model.ContainerService- Throws:
Exception
-
start
- Specified by:
startin interfaceorg.openremote.model.ContainerService- Throws:
Exception
-
stop
- Specified by:
stopin interfaceorg.openremote.model.ContainerService- Throws:
Exception
-
isValid
public boolean isValid()Description copied from interface:NotificationHandlerIndicates if this handler has a valid configuration and is usable.- Specified by:
isValidin interfaceNotificationHandler
-
getTypeName
Description copied from interface:NotificationHandlerThe unique type name; it must correspond with the value set inAbstractNotificationMessage.getType()so thatAbstractNotificationMessages can be mapped to aNotificationHandler.- Specified by:
getTypeNamein interfaceNotificationHandler
-
isMessageValid
public boolean isMessageValid(org.openremote.model.notification.AbstractNotificationMessage message) Description copied from interface:NotificationHandlerAllows the handler to validate the specifiedAbstractNotificationMessage.- Specified by:
isMessageValidin interfaceNotificationHandler
-
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:NotificationHandlerMap 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 requestedNotification.TargetTypewasNotification.TargetType.REALMand this handler only supports targets of typeNotification.TargetType.ASSETwhere theAssets must beConsoleAssetthen the handler needs to find all console assets that belong to the specified realm). Handlers can also add extraNotification.TargetType.CUSTOMhandlers extracted from the message.- Specified by:
getTargetsin interfaceNotificationHandler
-
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:NotificationHandlerSend the specifiedAbstractNotificationMessageto the target; the target supplied would be a target previously returned byNotificationHandler.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 theNotificationHandlerto 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
NotificationHandlerto update the delivered and/or acknowledged status of the notification by callingNotificationService.setNotificationDelivered(long)orNotificationService.setNotificationAcknowledged(long, java.lang.String)- Specified by:
sendMessagein interfaceNotificationHandler- Throws:
Exception
-
sendMessage
- 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)
-