use of com.evolveum.midpoint.xml.ns._public.common.common_3.CustomNotifierType in project midpoint by Evolveum.
the class CustomNotifier method processEvent.
@Override
public boolean processEvent(Event event, EventHandlerType eventHandlerType, NotificationManager notificationManager, Task task, OperationResult parentResult) throws SchemaException {
OperationResult result = parentResult.createSubresult(CustomNotifier.class.getName() + ".processEvent");
logStart(getLogger(), event, eventHandlerType);
boolean applies = aggregatedEventHandler.processEvent(event, eventHandlerType, notificationManager, task, result);
if (applies) {
CustomNotifierType config = (CustomNotifierType) eventHandlerType;
ExpressionVariables variables = getDefaultVariables(event, result);
if (event instanceof ModelEvent) {
((ModelEvent) event).getModelContext().reportProgress(new ProgressInformation(NOTIFICATIONS, ENTERING));
}
List<String> transports = new ArrayList<>(config.getTransport());
if (transports.isEmpty()) {
transports.add(customTransport.getName());
}
try {
for (String transportName : config.getTransport()) {
variables.addVariableDefinition(SchemaConstants.C_TRANSPORT_NAME, transportName);
Transport transport = notificationManager.getTransport(transportName);
Message message = getMessageFromExpression(config, variables, task, result);
if (message != null) {
getLogger().trace("Sending notification via transport {}:\n{}", transportName, message);
transport.send(message, transportName, event, task, result);
} else {
getLogger().debug("No message for transport {}, won't send anything", transportName);
}
}
} finally {
if (event instanceof ModelEvent) {
((ModelEvent) event).getModelContext().reportProgress(new ProgressInformation(NOTIFICATIONS, result));
}
}
}
logEnd(getLogger(), event, eventHandlerType, applies);
result.computeStatusIfUnknown();
// not-applicable notifiers do not stop processing of other notifiers
return true;
}
Aggregations