Notifications are used to send information about events that occur within midPoint. They can be related to (e.g.)
- model: like adding, modifying or deleting a user,
- resource objects: like adding, modifying or deleting an account,
- workflows: like starting or completing work item or process,
- certifications: like opening or closing a campaign,
- tasks: e.g. when a task is starting or finishing.
Besides these, midPoint has a special kind of event: custom events. These can be used to send "any other" notifications, not covered by the above types.
A custom event has the following attributes:
|subtype||Free-text information about category (type) of this custom event. For example, "passwordResetRequest" (if used for self-service functionality).|
|operation||Add / modify / delete - if relevant for a given type of custom events.|
|status||Success / alsoSuccess / failure / onlyFailure / inProgress - if relevant for a given type of custom events.|
|object||Object to which is given event related. It can be a PrismObject or any other object (Item, PrismValue, plain Java object, or even a collection of objects).|
|adHocHandler||Event handler that should be used to process this event.|
These custom events can be processed in one or both of the following ways:
- Using standard notification configuration in system configuration object. I.e. they might be filtered and eventually translated into messages using a notifier. Because no out-of-the-box notifier exists for custom events, a generalNotifier has to be used. This notifier has to specify the recipient(s), subject, and body of created message.
- Using ad-hoc event handler, specified within the event itself. Definition of this handler is exactly the same as definition of handlers in system configuration.
When a custom event is processed, first the ad-hoc handler is used (if present), followed by handler(s) from the system configuration object.
How to submit custom events
Using bulk actions
In order to easily send custom events there is the notify scripting (bulk) action. It takes the input from the pipe - usually a list of PrismObjects - and creates an event for each one of them. (Alternatively, for the whole list, if forWholeInput parameter is set to "true".)
The following parameters are available:
|subtype||Subtype of the event created.|
|operation||Operation to be put into event (add, modify, delete). Default is "add".|
|status||Status to be put into event (success, failure, inProgress, alsoSuccess, onlyFailure). Default is "success".|
|handler||Ad-hoc event handler that should be used to process the event.|
|forWholeInput||Whole input (i.e. all items in the pipeline) should be sent as event object. The default behavior is to generate one event for each input object.|
All of them are optional.
An example of such bulk action:
These bulk actions can be also generated by the Eclipse plugin, since 0.10.3.
Using Java code
Constructing and submitting custom events is simple; like this:
Just have a look at NotifyExecutor Java class (implementing "notify" bulk action).