Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
devel:documentation:notifications:dev:notification_manager [2018/02/15 07:55] tomiskar created |
devel:documentation:notifications:dev:notification_manager [2020/09/16 09:10] (current) tomiskar [Notification and attachments] |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Notifications ====== | ||
+ | {{tag> notification }} | ||
+ | |||
+ | The notification system supports sending messages via: | ||
+ | |||
+ | * SMS | ||
+ | * Concole (logger) - mainly for testing purpose | ||
+ | * ... other custom channel can be provided by modules | ||
+ | |||
+ | ===== Implemented notification types (channels) ===== | ||
+ | |||
+ | Notification type tells, which channel (=> which [[# | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | Sender names above can be used in sender configuration in '' | ||
+ | |||
+ | ==== Notification system functions ==== | ||
+ | |||
+ | * One message can be sent in more ways (e.g. according to the configuration of a user's account) or sent by a specific channel defined by notification type. | ||
+ | * Messages are saved into the database - there is a notification agenda available for the application administrator | ||
+ | * Sending messages can be disabled by configuration (e.g. for testing purposes) | ||
+ | * If the recipient of the given notification isn't entered (e.g. a blank email), a record of not sending the notification is done in the log with level information | ||
+ | |||
+ | A notification (with message) is represented by entity '' | ||
+ | |||
+ | Sending of notificanions itself is done by '' | ||
+ | |||
+ | '' | ||
+ | |||
+ | ===== Emailer ===== | ||
+ | |||
+ | A concrete implementation of the notification sender via email (a wrapping of the '' | ||
+ | '' | ||
+ | |||
+ | ==== Emailer settings ==== | ||
+ | |||
+ | The emailer can be configured via application.properties or application settings agenda. A functional testing [[..: | ||
+ | |||
+ | ==== Emailer testing ==== | ||
+ | If you want to test some project specific feature with sending email you can use '' | ||
+ | |||
+ | ===== Sms ===== | ||
+ | Currently there is a support for sending sms messages from IdM, but administrator must provide concrete implementation of sender for particular sms gateway. This can be done by extending AbstractSmsNotificationSender and registering this implementation in application context. | ||
+ | |||
+ | ===== Sending notification and processing ===== | ||
+ | Sending messages is done by '' | ||
+ | |||
+ | The priority of evaluation is as follows: | ||
+ | - The text is filled directly into method '' | ||
+ | - sending the [[notification_template|template]] directly via IdmMessage into method '' | ||
+ | - sending the [[notification_template|template]] via topic. The [[notification_template|template]] will be substituted from '' | ||
+ | |||
+ | ===== Notification and attachments ===== | ||
+ | |||
+ | Notification sender can send attachments. The only sender, which supports sending attachment is email sender now. Sent attachments are persisted automatically and it's possible to send them from backend only. Attachments ('' | ||
+ | ===== Configuration ===== | ||
+ | |||
+ | ==== Notification sender ==== | ||
+ | |||
+ | Senders are configurable thanks to interface '' | ||
+ | |||
+ | <note tip> | ||
+ | There can be more senders for the same notification type => the one that is going to be used can be chosen via configuration item '' | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Examples ==== | ||
+ | Everything is explained in the following examples: | ||
+ | |||
+ | === number 1. === | ||
+ | <code java> | ||
+ | notificationManager.send( | ||
+ | AccModuleDescriptor.TOPIC_NEW_PASSWORD, | ||
+ | new IdmMessage.Builder() | ||
+ | .setLevel(NotificationLevel.SUCCESS) | ||
+ | .addParameter(" | ||
+ | .addParameter(" | ||
+ | .addParameter(" | ||
+ | .setSubject(" | ||
+ | .setMessage(" | ||
+ | .build(), | ||
+ | identity); | ||
+ | </ | ||
+ | |||
+ | === number 2. === | ||
+ | <code java> | ||
+ | notificationManager.send( | ||
+ | AccModuleDescriptor.TOPIC_NEW_PASSWORD, | ||
+ | new IdmMessage.Builder() | ||
+ | .setLevel(NotificationLevel.SUCCESS) | ||
+ | .addParameter(" | ||
+ | .addParameter(" | ||
+ | .addParameter(" | ||
+ | .setTemplate(template) | ||
+ | .build(), | ||
+ | identity); | ||
+ | </ | ||
+ | |||
+ | === number 3. === | ||
+ | <code java> | ||
+ | notificationManager.send( | ||
+ | AccModuleDescriptor.TOPIC_NEW_PASSWORD, | ||
+ | new IdmMessage.Builder() | ||
+ | .setLevel(NotificationLevel.SUCCESS) | ||
+ | .addParameter(" | ||
+ | .addParameter(" | ||
+ | .addParameter(" | ||
+ | .build(), | ||
+ | identity); | ||
+ | </ | ||
+ | |||
+ | === number 4. === | ||
+ | <code java> | ||
+ | IdmAttachmentDto attachment = new IdmAttachmentDto(); | ||
+ | attachment.setName(" | ||
+ | attachment.setInputData(IOUtils.toInputStream(" | ||
+ | attachment.setEncoding(AttachableEntity.DEFAULT_ENCODING); | ||
+ | attachment.setMimetype(" | ||
+ | |||
+ | notificationManager.send( | ||
+ | AccModuleDescriptor.TOPIC_NEW_PASSWORD, | ||
+ | new IdmMessage.Builder() | ||
+ | .setLevel(NotificationLevel.SUCCESS) | ||
+ | .addParameter(" | ||
+ | .addParameter(" | ||
+ | .addParameter(" | ||
+ | .build(), | ||
+ | null, | ||
+ | Lists.newArrayList(identity), | ||
+ | Lists.newArrayList(attachment) | ||
+ | ); | ||
+ | </ | ||
+ | |||
+ | If there is no message and [[notification_template|template]], | ||
+ | |||
+ | ==== Disable sending notifications ==== | ||
+ | Feature notification' | ||
+ | While sending notification, | ||
+ | To this algorithm disabled option was added. So now if notification configurations are found, just these, which are disabled are not send: | ||
+ | - search exact topic, level -> if found, send just to not disabled ones and not continue. if not found continue with 2. | ||
+ | - search just with topic for general notification configuration -> if not found, send anonymously, | ||
+ | |||
+ | ==== Add Recipients or redirect sending notifications ==== | ||
+ | Into notification' | ||
+ | |||
+ | ===== Future developement ===== | ||
+ | * It will be possible to configure a testing receiver, where notifications will be sent to instead of the original one. | ||
+ | * Sending a notification will be tied to the configuration of the given entity, which will give the way of sending the notification (channel). |