Search in sources :

Example 1 with EventHandlerType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.EventHandlerType in project midpoint by Evolveum.

the class CategoryFilterHelper method processEvent.

@Override
public boolean processEvent(Event event, EventHandlerType eventHandlerType, NotificationManager notificationManager, Task task, OperationResult result) {
    if (eventHandlerType.getCategory().isEmpty()) {
        return true;
    }
    boolean retval = false;
    logStart(LOGGER, event, eventHandlerType, eventHandlerType.getCategory());
    for (EventCategoryType eventCategoryType : eventHandlerType.getCategory()) {
        if (eventCategoryType == null) {
            LOGGER.warn("Filtering on null EventCategoryType: " + eventHandlerType);
        } else if (event.isCategoryType(eventCategoryType)) {
            retval = true;
            break;
        }
    }
    logEnd(LOGGER, event, eventHandlerType, retval);
    return retval;
}
Also used : EventCategoryType(com.evolveum.midpoint.xml.ns._public.common.common_3.EventCategoryType)

Example 2 with EventHandlerType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.EventHandlerType in project midpoint by Evolveum.

the class StatusFilterHelper method processEvent.

@Override
public boolean processEvent(Event event, EventHandlerType eventHandlerType, NotificationManager notificationManager, Task task, OperationResult result) {
    if (eventHandlerType.getStatus().isEmpty()) {
        return true;
    }
    logStart(LOGGER, event, eventHandlerType, eventHandlerType.getStatus());
    boolean retval = false;
    for (EventStatusType eventStatusType : eventHandlerType.getStatus()) {
        if (eventStatusType == null) {
            LOGGER.warn("Filtering on null eventStatusType; filter = " + eventHandlerType);
        } else if (event.isStatusType(eventStatusType)) {
            retval = true;
            break;
        }
    }
    logEnd(LOGGER, event, eventHandlerType, retval);
    return retval;
}
Also used : EventStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.EventStatusType)

Example 3 with EventHandlerType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.EventHandlerType 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;
}
Also used : ExpressionVariables(com.evolveum.midpoint.repo.common.expression.ExpressionVariables) ProgressInformation(com.evolveum.midpoint.model.api.ProgressInformation) Message(com.evolveum.midpoint.notifications.api.transports.Message) ArrayList(java.util.ArrayList) CustomNotifierType(com.evolveum.midpoint.xml.ns._public.common.common_3.CustomNotifierType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Transport(com.evolveum.midpoint.notifications.api.transports.Transport) CustomTransport(com.evolveum.midpoint.notifications.impl.api.transports.CustomTransport) ModelEvent(com.evolveum.midpoint.notifications.api.events.ModelEvent)

Example 4 with EventHandlerType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.EventHandlerType in project midpoint by Evolveum.

the class ChainHelper method processEvent.

@Override
public boolean processEvent(Event event, EventHandlerType eventHandlerType, NotificationManager notificationManager, Task task, OperationResult result) {
    if (eventHandlerType.getChained().isEmpty()) {
        return true;
    }
    logStart(LOGGER, event, eventHandlerType);
    boolean shouldContinue = true;
    for (EventHandlerType branchHandlerType : eventHandlerType.getChained()) {
        shouldContinue = notificationManager.processEvent(event, branchHandlerType, task, result);
        if (!shouldContinue) {
            break;
        }
    }
    logEnd(LOGGER, event, eventHandlerType, shouldContinue);
    return shouldContinue;
}
Also used : EventHandlerType(com.evolveum.midpoint.xml.ns._public.common.common_3.EventHandlerType)

Example 5 with EventHandlerType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.EventHandlerType in project midpoint by Evolveum.

the class ForkHelper method processEvent.

@Override
public boolean processEvent(Event event, EventHandlerType eventHandlerType, NotificationManager notificationManager, Task task, OperationResult result) {
    if (eventHandlerType.getForked().isEmpty()) {
        return true;
    }
    logStart(LOGGER, event, eventHandlerType);
    for (EventHandlerType branchHandlerType : eventHandlerType.getForked()) {
        notificationManager.processEvent(event, branchHandlerType, task, result);
    }
    logEnd(LOGGER, event, eventHandlerType, true);
    return true;
}
Also used : EventHandlerType(com.evolveum.midpoint.xml.ns._public.common.common_3.EventHandlerType)

Aggregations

EventHandlerType (com.evolveum.midpoint.xml.ns._public.common.common_3.EventHandlerType)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 EventOperationType (com.evolveum.midpoint.xml.ns._public.common.common_3.EventOperationType)2 EventStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.EventStatusType)2 PipelineItem (com.evolveum.midpoint.model.api.PipelineItem)1 ProgressInformation (com.evolveum.midpoint.model.api.ProgressInformation)1 CustomEvent (com.evolveum.midpoint.notifications.api.events.CustomEvent)1 Event (com.evolveum.midpoint.notifications.api.events.Event)1 ModelEvent (com.evolveum.midpoint.notifications.api.events.ModelEvent)1 ResourceObjectEvent (com.evolveum.midpoint.notifications.api.events.ResourceObjectEvent)1 Message (com.evolveum.midpoint.notifications.api.transports.Message)1 Transport (com.evolveum.midpoint.notifications.api.transports.Transport)1 CustomTransport (com.evolveum.midpoint.notifications.impl.api.transports.CustomTransport)1 PrismValue (com.evolveum.midpoint.prism.PrismValue)1 ExpressionVariables (com.evolveum.midpoint.repo.common.expression.ExpressionVariables)1 CustomNotifierType (com.evolveum.midpoint.xml.ns._public.common.common_3.CustomNotifierType)1 EventCategoryType (com.evolveum.midpoint.xml.ns._public.common.common_3.EventCategoryType)1 ExpressionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType)1 ShadowKindType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)1 ArrayList (java.util.ArrayList)1