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;
}
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;
}
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;
}
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;
}
Aggregations