Search in sources :

Example 1 with EventOperationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.EventOperationType 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 2 with EventOperationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.EventOperationType 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

EventOperationType (com.evolveum.midpoint.xml.ns._public.common.common_3.EventOperationType)2 PipelineItem (com.evolveum.midpoint.model.api.PipelineItem)1 CustomEvent (com.evolveum.midpoint.notifications.api.events.CustomEvent)1 Event (com.evolveum.midpoint.notifications.api.events.Event)1 PrismValue (com.evolveum.midpoint.prism.PrismValue)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 EventHandlerType (com.evolveum.midpoint.xml.ns._public.common.common_3.EventHandlerType)1 EventStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.EventStatusType)1