Notifications are used to send information about events that occur within midPoint. They can be related to (e.g.)
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:
When a custom event is processed, first the ad-hoc handler is used (if present), followed by handler(s) from the system configuration object.
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:
<s:pipeline xmlns:s="http://midpoint.evolveum.com/xml/ns/public/model/scripting-3"> <s:expression xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="s:SearchExpressionType"> <s:type>RoleType</s:type> </s:expression> <s:expression xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="s:ActionExpressionType"> <s:type>notify</s:type> <s:parameter> <s:name>subtype</s:name> <c:value xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3">type1</c:value> </s:parameter> <s:parameter> <s:name>handler</s:name> <c:value xsi:type="c:EventHandlerType" xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"> <c:generalNotifier> <c:recipientExpression> <c:value>email@example.com</c:value> </c:recipientExpression> <c:bodyExpression> <c:script> <c:language>http://midpoint.evolveum.com/xml/ns/public/expression/language#velocity</c:language> <c:code>event.object is '$event.object.name' with OID of $event.object.oid</c:code> </c:script> </c:bodyExpression> <c:transport>mail</c:transport> </c:generalNotifier> </c:value> </s:parameter> <!-- Other parameters: forWholeInput, status, operation --> </s:expression> </s:pipeline>
More examples can be found in samples and tests (here and here; see also related system configuration).
These bulk actions can be also generated by the Eclipse plugin, since 0.10.3.
Constructing and submitting custom events is simple; like this:
Event event = new CustomEvent(lightweightIdentifierGenerator, subtype, handler, item, operation, status, channel); notificationManager.processEvent(event, task, result);
Just have a look at NotifyExecutor Java class (implementing "notify" bulk action).