[midPoint] Event notifications for some resource modification only

Pálos Gustáv gustav.palos at evolveum.com
Fri Sep 22 12:31:43 CEST 2017


Hi Oleksandr,

... but do you really need test it to resource name what you (or other
user/admin/...) can easily change also over GUI in some refactoring?
We prefer comparing over resource OID what is static, an example from my
one config used in simpleResourceObjectNotifier:

<expressionFilter>
 <script>
  <code>
    import
com.evolveum.midpoint.notifications.api.events.ResourceObjectEvent
    import
com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType

    (event instanceof ResourceObjectEvent
        && *event.getResourceOid() ==
'feed0000-0000-0000-0004-000000000002'*
        && event.isAdd()
        && event.isShadowKind(ShadowKindType.ACCOUNT))
  </code>
 </script>
</expressionFilter>


Best regards,

Gustav

2017-09-22 12:23 GMT+02:00 Pavol Mederly <mederly at evolveum.com>:

> Oleksandr,
>
> it seems that embedded filters (your expressionFilter in this case) are
> evaluated before so called quick applicability check is done for
> simpleResourceObjectNotifier. So, your filter is invoked with all kinds of
> events, not just with resource-related ones.
>
> If you want it to work, you need to include either
>
> "event.isCategoryType(com.evolveum.midpoint.xml.ns._
> public.common.common_3.EventCategoryType.RESOURCE_OBJECT_EVENT)"
>
> or
>
> "event instanceof com.evolveum.midpoint.notifications.api.events.
> ResourceObjectEvent"
>
> before calling event.getResourceName().
>
> If I would have a bit of time I would try to improve this event handling
> code. But ... it's a question of priorities.
>
> Best regards,
>
> Pavol Mederly
> Software developerevolveum.com
>
> On 22.09.2017 12:12, Oleksandr Nekriach wrote:
>
> Hello,
> Is it possible to filter notification events by resource name?
> My code:
>          <simpleResourceObjectNotifier>
>             <status>success</status>
>             <expressionFilter>
>                <script>
> <code>event.getResourceName().toString().equalsIgnoreCase("
> SomeResourcename")</code>
>                </script>
>             </expressionFilter>
>            <transport>mail</transport>
>          </simpleResourceObjectNotifier>
>
> I have tried this code and it works for me but on user interface and in
> logs I see the errors
>
>
> *2017-09-22 13:08:14,133 [] [Thread-42] ERROR
> (com.evolveum.midpoint.notifications.impl.helpers.BaseHelper): Couldn't
> evaluate event filter expression Caused by:
> com.evolveum.midpoint.util.exception.ExpressionEvaluationException:
> groovy.lang.MissingMethodException: No signature of method:
> com.evolveum.midpoint.notifications.api.events.ModelEvent.getResourceName()
> is applicable for argument types: () values: [] in (new) event filter
> expression*
>
> The same syntax in body section event.getResourceName().toString() works
> perfect without errors .
>
> Error detail:
>
> 2017-09-22 13:08:14,133 [] [Thread-42] ERROR (com.evolveum.midpoint.
> notifications.impl.helpers.BaseHelper): Couldn't evaluate event filter
> expression com.evolveum.midpoint.xml.ns._public.common.common_3.
> ExpressionType at 48e6b9a8[description=<null>,extension=<null>,trace=<null>,
> stringFilter=<null>,variable=<null>,returnMultiplicity=<
> null>,allowEmptyValues=<null>,queryInterpretationOfNoValue=<
> null>,runAsRef=<null>,expressionEvaluator=[javax.
> xml.bind.JAXBElement at 2f408ce4]], reason: groovy.lang.MissingMethodException:
> No signature of method: com.evolveum.midpoint.notifications.api.events.ModelEvent.getResourceName()
> is applicable for argument types: () values: [] in (new) event filter
> expression (class com.evolveum.midpoint.util.exception.
> ExpressionEvaluationException)
> 2017-09-22 13:08:14,248 [] [Thread-42] ERROR (com.evolveum.midpoint.web.
> component.progress.ProgressReporter): Error executing changes.
> com.evolveum.midpoint.util.exception.SystemException:
> com.evolveum.midpoint.util.exception.ExpressionEvaluationException:
> groovy.lang.MissingMethodException: No signature of method:
> com.evolveum.midpoint.notifications.api.events.ModelEvent.getResourceName()
> is applicable for argument types: () values: [] in (new) event filter
> expression
>         at com.evolveum.midpoint.notifications.impl.helpers.BaseHelper.
> evaluateBooleanExpressionChecked(BaseHelper.java:119)
> ~[notifications-impl-3.6.jar:na]
>         at com.evolveum.midpoint.notifications.impl.helpers.
> ExpressionFilterHelper.processEvent(ExpressionFilterHelper.java:51)
> ~[notifications-impl-3.6.jar:na]
>         at com.evolveum.midpoint.notifications.impl.handlers.
> AggregatedEventHandler.processEvent(AggregatedEventHandler.java:126)
> ~[notifications-impl-3.6.jar:na]
>         at com.evolveum.midpoint.notifications.impl.notifiers.
> GeneralNotifier.processEvent(GeneralNotifier.java:90)
> ~[notifications-impl-3.6.jar:na]
>         at com.evolveum.midpoint.notifications.impl.handlers.
> AggregatedEventHandler.processNotifiers(AggregatedEventHandler.java:154)
> ~[notifications-impl-3.6.jar:na]
>         at com.evolveum.midpoint.notifications.impl.handlers.
> AggregatedEventHandler.processEvent(AggregatedEventHandler.java:132)
> ~[notifications-impl-3.6.jar:na]
>         at com.evolveum.midpoint.notifications.impl.
> NotificationManagerImpl.processEvent(NotificationManagerImpl.java:180)
> ~[notifications-impl-3.6.jar:na]
>         at com.evolveum.midpoint.notifications.impl.
> NotificationManagerImpl.processNotifications(NotificationManagerImpl.java:174)
> ~[notifications-impl-3.6.jar:na]
>         at com.evolveum.midpoint.notifications.impl.
> NotificationManagerImpl.processEvent(NotificationManagerImpl.java:165)
> ~[notifications-impl-3.6.jar:na]
>         at com.evolveum.midpoint.notifications.impl.
> NotificationChangeHook.emitModelEvent(NotificationChangeHook.java:139)
> ~[notifications-impl-3.6.jar:na]
>         at com.evolveum.midpoint.notifications.impl.
> NotificationChangeHook.invoke(NotificationChangeHook.java:98)
> ~[notifications-impl-3.6.jar:na]
>         at com.evolveum.midpoint.model.impl.lens.Clockwork.
> invokeHooks(Clockwork.java:424) ~[model-impl-3.6.jar:na]
>         at com.evolveum.midpoint.model.impl.lens.Clockwork.click(Clockwork.java:338)
> ~[model-impl-3.6.jar:na]
>         at com.evolveum.midpoint.model.impl.lens.Clockwork.run(Clockwork.java:203)
> ~[model-impl-3.6.jar:na]
>         at com.evolveum.midpoint.model.impl.controller.ModelController.
> executeChanges(ModelController.java:569) ~[model-impl-3.6.jar:na]
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> ~[na:1.8.0_131]
>         at sun.reflect.NativeMethodAccessorImpl.invoke(
> NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
>         at java.lang.reflect.Method.invoke(Method.java:498)
> ~[na:1.8.0_131]
>         at org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(LazyInitProxyFactory.java:507)
> ~[wicket-ioc-7.6.0.jar:7.6.0]
>         at com.sun.proxy.$Proxy161.executeChanges(Unknown Source) ~[na:na]
>         at com.evolveum.midpoint.web.component.progress.
> ProgressReporter.lambda$executeChangesAsync$0(ProgressReporter.java:187)
> ~[classes/:na]
>         at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_131]
> Caused by: com.evolveum.midpoint.util.exception.ExpressionEvaluationException:
> groovy.lang.MissingMethodException: No signature of method:
> com.evolveum.midpoint.notifications.api.events.ModelEvent.getResourceName()
> is applicable for argument types: () values: [] in (new) event filter
> expression
>         at com.evolveum.midpoint.model.common.expression.script.
> jsr223.Jsr223ScriptEvaluator.evaluate(Jsr223ScriptEvaluator.java:113)
> ~[model-common-3.6.jar:na]
>         at com.evolveum.midpoint.model.common.expression.script.
> ScriptExpression.evaluate(ScriptExpression.java:106)
> ~[model-common-3.6.jar:na]
>         at com.evolveum.midpoint.model.common.expression.script.
> ScriptExpressionEvaluator.transformSingleValue(ScriptExpressionEvaluator.java:61)
> ~[model-common-3.6.jar:na]
>         at com.evolveum.midpoint.model.common.expression.evaluator.
> AbstractValueTransformationExpressionEvaluator.evaluateScriptExpression(
> AbstractValueTransformationExpressionEvaluator.java:261)
> ~[model-common-3.6.jar:na]
>         at com.evolveum.midpoint.model.common.expression.evaluator.
> AbstractValueTransformationExpressionEvaluator.evaluateAbsoluteExpression(
> AbstractValueTransformationExpressionEvaluator.java:191)
> ~[model-common-3.6.jar:na]
>         at com.evolveum.midpoint.model.common.expression.evaluator.
> AbstractValueTransformationExpressionEvaluator.evaluate(
> AbstractValueTransformationExpressionEvaluator.java:95)
> ~[model-common-3.6.jar:na]
>         at com.evolveum.midpoint.repo.common.expression.Expression.
> evaluateExpressionEvaluators(Expression.java:201)
> ~[repo-common-3.6.jar:na]
>         at com.evolveum.midpoint.repo.common.expression.Expression.evaluate(Expression.java:146)
> ~[repo-common-3.6.jar:na]
>         at com.evolveum.midpoint.model.impl.expr.
> ModelExpressionThreadLocalHolder.evaluateExpressionInContext(
> ModelExpressionThreadLocalHolder.java:106) ~[model-impl-3.6.jar:na]
>         at com.evolveum.midpoint.notifications.impl.helpers.BaseHelper.
> evaluateBooleanExpression(BaseHelper.java:130)
> ~[notifications-impl-3.6.jar:na]
>         at com.evolveum.midpoint.notifications.impl.helpers.BaseHelper.
> evaluateBooleanExpressionChecked(BaseHelper.java:108)
> ~[notifications-impl-3.6.jar:na]
>         ... 22 common frames omitted
> Caused by: javax.script.ScriptException: groovy.lang.MissingMethodException:
> No signature of method: com.evolveum.midpoint.notifications.api.events.ModelEvent.getResourceName()
> is applicable for argument types: () values: []
>         at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(
> GroovyScriptEngineImpl.java:347) ~[groovy-all-2.4.0.jar:2.4.0]
>         at org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:41)
> ~[groovy-all-2.4.0.jar:2.4.0]
>         at javax.script.CompiledScript.eval(CompiledScript.java:92)
> ~[na:1.8.0_131]
>         at com.evolveum.midpoint.model.common.expression.script.
> jsr223.Jsr223ScriptEvaluator.evaluate(Jsr223ScriptEvaluator.java:111)
> ~[model-common-3.6.jar:na]
>         ... 32 common frames omitted
>
>
>
>
>
>
>
>
>
> Please help
>
> --
> Best regards,
>
> Oleksandr Nekriach | Identity and access management engineer
>
> Dynatech, Mednieku str. 4a, Riga, LV-1010, Latvia
>
> +37125314685 <+371%2025%20314%20685>
> ,
> o.nekriach at dynatech.lv
> |
> www.dynatech.lv
>
>
>
>
> Stay connected:
> <https://www.facebook.com/DynatechLatvia/?ref=br_rs>
> <https://www.linkedin.com/company-beta/17893047/>
>
>
> Confidentiality Notice: This message contains confidential information and
> is intended only for the named recipient(s). If you are not the addressee
> you may not copy, distribute or perform any other activities with this
> information. If you have received this transmission in error, please notify
> us by e-mail immediately. E-mail transmission cannot be guaranteed to be
> secure or error-free as information could be intercepted, corrupted, lost,
> destroyed, arrive late or incomplete, or contain viruses.
>
>
> _______________________________________________
> midPoint mailing listmidPoint at lists.evolveum.comhttp://lists.evolveum.com/mailman/listinfo/midpoint
>
>
>
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> http://lists.evolveum.com/mailman/listinfo/midpoint
>
>


-- 
Gustáv Pálos
Identity Engineer
evolveum.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20170922/f2b65e9b/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: o.nekriach at dynatech.lv1502777022855-7771
Type: image/png
Size: 790 bytes
Desc: not available
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20170922/f2b65e9b/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: o.nekriach at dynatech.lv1502777022855-7770
Type: image/png
Size: 2602 bytes
Desc: not available
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20170922/f2b65e9b/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: o.nekriach at dynatech.lv1502777022855-7772
Type: image/png
Size: 786 bytes
Desc: not available
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20170922/f2b65e9b/attachment-0002.png>


More information about the midPoint mailing list