Search in sources :

Example 6 with EventHandlerType

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

the class OperationFilterHelper method processEvent.

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

Example 7 with EventHandlerType

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

the class ExpressionFilterHelper method processEvent.

@Override
public boolean processEvent(Event event, EventHandlerType eventHandlerType, NotificationManager notificationManager, Task task, OperationResult result) {
    if (eventHandlerType.getExpressionFilter().isEmpty()) {
        return true;
    }
    logStart(LOGGER, event, eventHandlerType, eventHandlerType.getExpressionFilter());
    boolean retval = true;
    for (ExpressionType expressionType : eventHandlerType.getExpressionFilter()) {
        if (!evaluateBooleanExpressionChecked(expressionType, getDefaultVariables(event, result), "event filter expression", task, result)) {
            retval = false;
            break;
        }
    }
    logEnd(LOGGER, event, eventHandlerType, retval);
    return retval;
}
Also used : ExpressionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType)

Example 8 with EventHandlerType

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

the class KindIntentFilterHelper method processEvent.

@Override
public boolean processEvent(Event event, EventHandlerType eventHandlerType, NotificationManager notificationManager, Task task, OperationResult result) {
    if (eventHandlerType.getObjectKind().isEmpty() && eventHandlerType.getObjectIntent().isEmpty()) {
        return true;
    }
    if (!(event instanceof ResourceObjectEvent)) {
        // or should we return false?
        return true;
    }
    ResourceObjectEvent resourceObjectEvent = (ResourceObjectEvent) event;
    logStart(LOGGER, event, eventHandlerType, eventHandlerType.getStatus());
    boolean retval = true;
    if (!eventHandlerType.getObjectKind().isEmpty()) {
        retval = false;
        for (ShadowKindType shadowKindType : eventHandlerType.getObjectKind()) {
            if (shadowKindType == null) {
                LOGGER.warn("Filtering on null shadowKindType; filter = " + eventHandlerType);
            } else if (resourceObjectEvent.isShadowKind(shadowKindType)) {
                retval = true;
                break;
            }
        }
    }
    if (retval) {
        // now check the intent
        if (!eventHandlerType.getObjectIntent().isEmpty()) {
            retval = false;
            for (String intent : eventHandlerType.getObjectIntent()) {
                if (intent == null) {
                    LOGGER.warn("Filtering on null intent; filter = " + eventHandlerType);
                } else if (resourceObjectEvent.isShadowIntent(intent)) {
                    retval = true;
                    break;
                }
            }
        }
    }
    logEnd(LOGGER, event, eventHandlerType, retval);
    return retval;
}
Also used : ResourceObjectEvent(com.evolveum.midpoint.notifications.api.events.ResourceObjectEvent) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)

Example 9 with EventHandlerType

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

the class NotifyExecutor method execute.

@Override
public PipelineData execute(ActionExpressionType expression, PipelineData input, ExecutionContext context, OperationResult globalResult) throws ScriptExecutionException {
    String subtype = expressionHelper.getArgumentAsString(expression.getParameter(), PARAM_SUBTYPE, input, context, null, PARAM_SUBTYPE, globalResult);
    EventHandlerType handler = expressionHelper.getSingleArgumentValue(expression.getParameter(), PARAM_HANDLER, false, false, PARAM_HANDLER, input, context, EventHandlerType.class, globalResult);
    EventStatusType status = expressionHelper.getSingleArgumentValue(expression.getParameter(), PARAM_STATUS, false, false, PARAM_STATUS, input, context, EventStatusType.class, globalResult);
    EventOperationType operation = expressionHelper.getSingleArgumentValue(expression.getParameter(), PARAM_OPERATION, false, false, PARAM_OPERATION, input, context, EventOperationType.class, globalResult);
    boolean forWholeInput = expressionHelper.getArgumentAsBoolean(expression.getParameter(), PARAM_FOR_WHOLE_INPUT, input, context, false, PARAM_SUBTYPE, globalResult);
    if (handler != null) {
        // TODO explain that the reason is that handler is not null
        checkRootAuthorization(globalResult, NAME);
    }
    if (status == null) {
        status = EventStatusType.SUCCESS;
    }
    if (operation == null) {
        operation = EventOperationType.ADD;
    }
    if (notificationManager == null) {
        throw new IllegalStateException("Notification manager is unavailable");
    }
    int eventCount = 0;
    if (forWholeInput) {
        Event event = new CustomEvent(lightweightIdentifierGenerator, subtype, handler, input.getData(), operation, status, context.getChannel());
        notificationManager.processEvent(event, context.getTask(), globalResult);
        eventCount++;
    } else {
        for (PipelineItem item : input.getData()) {
            PrismValue value = item.getValue();
            OperationResult result = operationsHelper.createActionResult(item, this, context, globalResult);
            context.checkTaskStop();
            Event event = new CustomEvent(lightweightIdentifierGenerator, subtype, handler, value, operation, status, context.getChannel());
            notificationManager.processEvent(event, context.getTask(), result);
            eventCount++;
            operationsHelper.trimAndCloneResult(result, globalResult, context);
        }
    }
    context.println("Produced " + eventCount + " event(s)");
    return input;
}
Also used : CustomEvent(com.evolveum.midpoint.notifications.api.events.CustomEvent) PipelineItem(com.evolveum.midpoint.model.api.PipelineItem) EventHandlerType(com.evolveum.midpoint.xml.ns._public.common.common_3.EventHandlerType) EventStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.EventStatusType) Event(com.evolveum.midpoint.notifications.api.events.Event) CustomEvent(com.evolveum.midpoint.notifications.api.events.CustomEvent) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) EventOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.EventOperationType) PrismValue(com.evolveum.midpoint.prism.PrismValue)

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