[midPoint] Event notifications for some resource modification only
Oleksandr Nekriach
o.nekriach at dynatech.lv
Fri Sep 22 13:11:42 CEST 2017
Hello Gustav,
Gustav thank you for advice. Sure work with oid better than just with name.
In case working with few midpoint instances in different environments (test
and dev) I will use something middle like this.
<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.getResourceName().**toString().equalsIgnoreCase("*
*SomeResourcename"))*
&& event.isAdd()
&& event.isShadowKind(ShadowKindType.ACCOUNT)
</code>
</script>
</expressionFilter>
2017-09-22 13:31 GMT+03:00 Pálos Gustáv <gustav.palos at evolveum.com>:
> 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.notifica
>> tions.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("S
>> omeResourcename")</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>,queryI
>> nterpretationOfNoValue=<null>,runAsRef=<null>,expressionEval
>> uator=[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.exc
>> eption.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.ExpressionF
>> ilterHelper.processEvent(ExpressionFilterHelper.java:51)
>> ~[notifications-impl-3.6.jar:na]
>> at com.evolveum.midpoint.notifications.impl.handlers.Aggregated
>> EventHandler.processEvent(AggregatedEventHandler.java:126)
>> ~[notifications-impl-3.6.jar:na]
>> at com.evolveum.midpoint.notifications.impl.notifiers.GeneralNo
>> tifier.processEvent(GeneralNotifier.java:90)
>> ~[notifications-impl-3.6.jar:na]
>> at com.evolveum.midpoint.notifications.impl.handlers.Aggregated
>> EventHandler.processNotifiers(AggregatedEventHandler.java:154)
>> ~[notifications-impl-3.6.jar:na]
>> at com.evolveum.midpoint.notifications.impl.handlers.Aggregated
>> EventHandler.processEvent(AggregatedEventHandler.java:132)
>> ~[notifications-impl-3.6.jar:na]
>> at com.evolveum.midpoint.notifications.impl.NotificationManager
>> Impl.processEvent(NotificationManagerImpl.java:180)
>> ~[notifications-impl-3.6.jar:na]
>> at com.evolveum.midpoint.notifications.impl.NotificationManager
>> Impl.processNotifications(NotificationManagerImpl.java:174)
>> ~[notifications-impl-3.6.jar:na]
>> at com.evolveum.midpoint.notifications.impl.NotificationManager
>> Impl.processEvent(NotificationManagerImpl.java:165)
>> ~[notifications-impl-3.6.jar:na]
>> at com.evolveum.midpoint.notifications.impl.NotificationChangeH
>> ook.emitModelEvent(NotificationChangeHook.java:139)
>> ~[notifications-impl-3.6.jar:na]
>> at com.evolveum.midpoint.notifications.impl.NotificationChangeH
>> ook.invoke(NotificationChangeHook.java:98) ~[notifications-impl-3.6.jar:n
>> a]
>> 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.ProgressReporte
>> r.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.ScriptE
>> xpression.evaluate(ScriptExpression.java:106) ~[model-common-3.6.jar:na]
>> at com.evolveum.midpoint.model.common.expression.script.ScriptE
>> xpressionEvaluator.transformSingleValue(ScriptExpressionEvaluator.java:61)
>> ~[model-common-3.6.jar:na]
>> at com.evolveum.midpoint.model.common.expression.evaluator.Abst
>> ractValueTransformationExpressionEvaluator.evaluateScriptExp
>> ression(AbstractValueTransformationExpressionEvaluator.java:261)
>> ~[model-common-3.6.jar:na]
>> at com.evolveum.midpoint.model.common.expression.evaluator.Abst
>> ractValueTransformationExpressionEvaluator.evaluateAbsoluteE
>> xpression(AbstractValueTransformationExpressionEvaluator.java:191)
>> ~[model-common-3.6.jar:na]
>> at com.evolveum.midpoint.model.common.expression.evaluator.Abst
>> ractValueTransformationExpressionEvaluator.evaluate(Abstract
>> ValueTransformationExpressionEvaluator.java:95)
>> ~[model-common-3.6.jar:na]
>> at com.evolveum.midpoint.repo.common.expression.Expression.eval
>> uateExpressionEvaluators(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.ModelExpressionThreadL
>> ocalHolder.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.notifica
>> tions.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
>
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> http://lists.evolveum.com/mailman/listinfo/midpoint
>
>
--
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20170922/12dbac6d/attachment.htm>
-------------- 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/12dbac6d/attachment.png>
-------------- 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/12dbac6d/attachment-0001.png>
-------------- 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/12dbac6d/attachment-0002.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/12dbac6d/attachment-0003.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/12dbac6d/attachment-0004.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/12dbac6d/attachment-0005.png>
More information about the midPoint
mailing list