<div dir="ltr"><div><div>Hello Gustav,<br><br></div>Gustav thank you for advice. Sure work with oid better than just with name. <br></div>In case working with few midpoint instances in different environments (test and dev)  I will use something middle like this. <br><br><div><expressionFilter></div><div> <script></div><div>  <code></div><div>    import com.evolveum.midpoint.<wbr>notifications.api.events.<wbr>ResourceObjectEvent</div><div>    import com.evolveum.midpoint.xml.ns._<wbr>public.common.common_3.<wbr>ShadowKindType</div><div><br></div><div>    (event instanceof ResourceObjectEvent)<br></div><div>        &amp;&amp; <b>(event.getResourceOid() == 'feed0000-0000-0000-0004-</b><wbr><b>000000000002' || event.getResourceName().</b><wbr><b>toString().equalsIgnoreCase("</b><wbr><b>SomeResourcename"))</b></div><div>        &amp;&amp; event.isAdd() </div><div>        &amp;&amp; event.isShadowKind(<wbr>ShadowKindType.ACCOUNT)</div><div>  </code></div><div> </script></div><div></expressionFilter></div><div><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-09-22 13:31 GMT+03:00 Pálos Gustáv <span dir="ltr"><<a href="mailto:gustav.palos@evolveum.com" target="_blank">gustav.palos@evolveum.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Oleksandr,<div><br></div><div>... 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?</div><div>We prefer comparing over resource OID what is static, an example from my one config used in simpleResourceObjectNotifier:</div><div><div><div><br></div><div><expressionFilter></div><div> <script></div><div>  <code></div><div>    import com.evolveum.midpoint.<wbr>notifications.api.events.<wbr>ResourceObjectEvent</div><div>    import com.evolveum.midpoint.xml.ns._<wbr>public.common.common_3.<wbr>ShadowKindType</div><div><br></div><div>    (event instanceof ResourceObjectEvent <br></div><div>        &amp;&amp; <b>event.getResourceOid() == 'feed0000-0000-0000-0004-<wbr>000000000002'</b></div><div></div><div>        &amp;&amp; event.isAdd() </div><div></div><div>        &amp;&amp; event.isShadowKind(<wbr>ShadowKindType.ACCOUNT))</div><div></div><div>  </code></div><div> </script></div><div></expressionFilter></div></div><div><br></div><div><br></div><div>Best regards,</div><div><br></div><div>Gustav</div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">2017-09-22 12:23 GMT+02:00 Pavol Mederly <span dir="ltr"><<a href="mailto:mederly@evolveum.com" target="_blank">mederly@evolveum.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF">
    <p>Oleksandr,</p>
    <p>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.</p>
    <p>If you want it to work, you need to include either </p>
    <p>"event.isCategoryType(com.evol<wbr>veum.midpoint.xml.ns._public.<wbr>common.common_3.EventCategoryT<wbr>ype.RESOURCE_OBJECT_EVENT)"
      <br>
    </p>
    <p>or</p>
    <p>"event instanceof
      com.evolveum.midpoint.notifica<wbr>tions.api.events.ResourceObjec<wbr>tEvent"</p>
    <p>before calling event.getResourceName().</p>
    <p>If I would have a bit of time I would try to improve this event
      handling code. But ... it's a question of priorities.</p>
    <p>Best regards,<br>
    </p>
    <pre class="m_5957642960629361867gmail-m_3726000040802528383moz-signature" cols="72">Pavol Mederly
Software developer
<a href="http://evolveum.com" target="_blank">evolveum.com</a>
</pre><div><div class="m_5957642960629361867gmail-h5">
    <div class="m_5957642960629361867gmail-m_3726000040802528383moz-cite-prefix">On 22.09.2017 12:12, Oleksandr Nekriach
      wrote:<br>
    </div>
    </div></div><blockquote type="cite"><div><div class="m_5957642960629361867gmail-h5">
      <div dir="ltr">
        <div>
          <div>Hello,<br>
          </div>
          Is it possible to filter notification events by resource name?<br>
        </div>
        <div>My code:<br>
                   <simpleResourceObjectNotifier><br>
                      <status>success</status><br>
                      <expressionFilter><br>
                         <script>                             
<code>event.getResourceName().<wbr>toString().equalsIgnoreCase("S<wbr>omeResourcename")</code><br>
                         </script><br>
                      </expressionFilter><br>
                     <transport>mail</transport><br>
                   </simpleResourceObjectNotifier<wbr>><br>
                   <br>
          <div>I have tried this code and it works for me but on user
            interface and in logs I see the errors<br>
            <br>
            <i>2017-09-22 13:08:14,133 [] [Thread-42] ERROR
              (com.evolveum.midpoint.notific<wbr>ations.impl.helpers.BaseHelper<wbr>):
              Couldn't evaluate event filter expression <br>
              Caused by:
              com.evolveum.midpoint.util.exc<wbr>eption.ExpressionEvaluationExc<wbr>eption:
              groovy.lang.MissingMethodExcep<wbr>tion: No signature of
              method:
com.evolveum.midpoint.notifica<wbr>tions.api.events.ModelEvent.<wbr>getResourceName()
              is applicable for argument types: () values: [] in (new)
              event filter expression</i><br>
            <br>
          </div>
          <div>The same syntax in body section
            event.getResourceName().toStri<wbr>ng() works perfect without
            errors .<br>
            <br>
            Error detail:<br>
            <br>
            2017-09-22 13:08:14,133 [] [Thread-42] ERROR
            (com.evolveum.midpoint.notific<wbr>ations.impl.helpers.BaseHelper<wbr>):
            Couldn't evaluate event filter expression
com.evolveum.midpoint.xml.ns._<wbr>public.common.common_3.Express<wbr>ionType@48e6b9a8[description=<<wbr>null>,extension=<null>,trace=<<wbr>null>,stringFilter=<null>,<wbr>variable=<null>,<wbr>returnMultiplicity=<null>,<wbr>allowEmptyValues=<null>,queryI<wbr>nterpretationOfNoValue=<null>,<wbr>runAsRef=<null>,expressionEval<wbr>uator=[javax.xml.bind.<wbr>JAXBElement@2f408ce4]],
            reason: groovy.lang.MissingMethodExcep<wbr>tion: No signature of
            method:
com.evolveum.midpoint.notifica<wbr>tions.api.events.ModelEvent.<wbr>getResourceName()
            is applicable for argument types: () values: [] in (new)
            event filter expression (class
            com.evolveum.midpoint.util.exc<wbr>eption.ExpressionEvaluationExc<wbr>eption)<br>
            2017-09-22 13:08:14,248 [] [Thread-42] ERROR
            (<a href="http://com.evolveum.midpoint.web.com">com.evolveum.midpoint.web.com</a><wbr>ponent.progress.ProgressReport<wbr>er):
            Error executing changes.<br>
            com.evolveum.midpoint.util.exc<wbr>eption.SystemException:
            com.evolveum.midpoint.util.exc<wbr>eption.ExpressionEvaluationExc<wbr>eption:
            groovy.lang.MissingMethodExcep<wbr>tion: No signature of method:
com.evolveum.midpoint.notifica<wbr>tions.api.events.ModelEvent.<wbr>getResourceName()
            is applicable for argument types: () values: [] in (new)
            event filter expression<br>
                    at
com.evolveum.midpoint.notifica<wbr>tions.impl.helpers.BaseHelper.<wbr>evaluateBooleanExpressionCheck<wbr>ed(BaseHelper.java:119)
            ~[notifications-impl-3.6.jar:n<wbr>a]<br>
                    at
com.evolveum.midpoint.notifica<wbr>tions.impl.helpers.ExpressionF<wbr>ilterHelper.processEvent(Expre<wbr>ssionFilterHelper.java:51)
            ~[notifications-impl-3.6.jar:n<wbr>a]<br>
                    at
com.evolveum.midpoint.notifica<wbr>tions.impl.handlers.Aggregated<wbr>EventHandler.processEvent(Aggr<wbr>egatedEventHandler.java:126)
            ~[notifications-impl-3.6.jar:n<wbr>a]<br>
                    at
com.evolveum.midpoint.notifica<wbr>tions.impl.notifiers.GeneralNo<wbr>tifier.processEvent(GeneralNot<wbr>ifier.java:90)
            ~[notifications-impl-3.6.jar:n<wbr>a]<br>
                    at
com.evolveum.midpoint.notifica<wbr>tions.impl.handlers.Aggregated<wbr>EventHandler.processNotifiers(<wbr>AggregatedEventHandler.java:15<wbr>4)
            ~[notifications-impl-3.6.jar:n<wbr>a]<br>
                    at
com.evolveum.midpoint.notifica<wbr>tions.impl.handlers.Aggregated<wbr>EventHandler.processEvent(Aggr<wbr>egatedEventHandler.java:132)
            ~[notifications-impl-3.6.jar:n<wbr>a]<br>
                    at
com.evolveum.midpoint.notifica<wbr>tions.impl.NotificationManager<wbr>Impl.processEvent(Notification<wbr>ManagerImpl.java:180)
            ~[notifications-impl-3.6.jar:n<wbr>a]<br>
                    at
com.evolveum.midpoint.notifica<wbr>tions.impl.NotificationManager<wbr>Impl.processNotifications(Noti<wbr>ficationManagerImpl.java:174)
            ~[notifications-impl-3.6.jar:n<wbr>a]<br>
                    at
com.evolveum.midpoint.notifica<wbr>tions.impl.NotificationManager<wbr>Impl.processEvent(Notification<wbr>ManagerImpl.java:165)
            ~[notifications-impl-3.6.jar:n<wbr>a]<br>
                    at
com.evolveum.midpoint.notifica<wbr>tions.impl.NotificationChangeH<wbr>ook.emitModelEvent(Notificatio<wbr>nChangeHook.java:139)
            ~[notifications-impl-3.6.jar:n<wbr>a]<br>
                    at
com.evolveum.midpoint.notifica<wbr>tions.impl.NotificationChangeH<wbr>ook.invoke(NotificationChangeH<wbr>ook.java:98)
            ~[notifications-impl-3.6.jar:n<wbr>a]<br>
                    at
<a href="http://com.evolveum.midpoint.model.im">com.evolveum.midpoint.model.im</a><wbr>pl.lens.Clockwork.invokeHooks(<wbr>Clockwork.java:424)
            ~[model-impl-3.6.jar:na]<br>
                    at
<a href="http://com.evolveum.midpoint.model.im">com.evolveum.midpoint.model.im</a><wbr>pl.lens.Clockwork.click(Clockw<wbr>ork.java:338)
            ~[model-impl-3.6.jar:na]<br>
                    at
            <a href="http://com.evolveum.midpoint.model.im">com.evolveum.midpoint.model.im</a><wbr>pl.lens.Clockwork.run(Clockwor<wbr>k.java:203)
            ~[model-impl-3.6.jar:na]<br>
                    at
<a href="http://com.evolveum.midpoint.model.im">com.evolveum.midpoint.model.im</a><wbr>pl.controller.ModelController.<wbr>executeChanges(ModelController<wbr>.java:569)
            ~[model-impl-3.6.jar:na]<br>
                    at
            sun.reflect.NativeMethodAccess<wbr>orImpl.invoke0(Native Method)
            ~[na:1.8.0_131]<br>
                    at
sun.reflect.NativeMethodAccess<wbr>orImpl.invoke(NativeMethodAcce<wbr>ssorImpl.java:62)
            ~[na:1.8.0_131]<br>
                    at
sun.reflect.DelegatingMethodAc<wbr>cessorImpl.invoke(DelegatingMe<wbr>thodAccessorImpl.java:43)
            ~[na:1.8.0_131]<br>
                    at java.lang.reflect.Method.invok<wbr>e(Method.java:498)
            ~[na:1.8.0_131]<br>
                    at
org.apache.wicket.proxy.LazyIn<wbr>itProxyFactory$JdkHandler.<wbr>invoke(LazyInitProxyFactory.<wbr>java:507)
            ~[wicket-ioc-7.6.0.jar:7.6.0]<br>
                    at com.sun.proxy.$Proxy161.execut<wbr>eChanges(Unknown
            Source) ~[na:na]<br>
                    at
com.evolveum.midpoint.web.comp<wbr>onent.progress.ProgressReporte<wbr>r.lambda$executeChangesAsync$<wbr>0(ProgressReporter.java:187)
            ~[classes/:na]<br>
                    at java.lang.Thread.run(Thread.ja<wbr>va:748)
            ~[na:1.8.0_131]<br>
            Caused by:
            com.evolveum.midpoint.util.exc<wbr>eption.ExpressionEvaluationExc<wbr>eption:
            groovy.lang.MissingMethodExcep<wbr>tion: No signature of method:
com.evolveum.midpoint.notifica<wbr>tions.api.events.ModelEvent.<wbr>getResourceName()
            is applicable for argument types: () values: [] in (new)
            event filter expression<br>
                    at
<a href="http://com.evolveum.midpoint.model.co">com.evolveum.midpoint.model.co</a><wbr>mmon.expression.script.jsr223.<wbr>Jsr223ScriptEvaluator.evaluate<wbr>(Jsr223ScriptEvaluator.java:11<wbr>3)
            ~[model-common-3.6.jar:na]<br>
                    at
<a href="http://com.evolveum.midpoint.model.co">com.evolveum.midpoint.model.co</a><wbr>mmon.expression.script.ScriptE<wbr>xpression.evaluate(ScriptExpre<wbr>ssion.java:106)
            ~[model-common-3.6.jar:na]<br>
                    at
<a href="http://com.evolveum.midpoint.model.co">com.evolveum.midpoint.model.co</a><wbr>mmon.expression.script.ScriptE<wbr>xpressionEvaluator.transformSi<wbr>ngleValue(ScriptExpressionEval<wbr>uator.java:61)
            ~[model-common-3.6.jar:na]<br>
                    at
<a href="http://com.evolveum.midpoint.model.co">com.evolveum.midpoint.model.co</a><wbr>mmon.expression.evaluator.Abst<wbr>ractValueTransformationExpress<wbr>ionEvaluator.evaluateScriptExp<wbr>ression(AbstractValueTransform<wbr>ationExpressionEvaluator.java:<wbr>261)
            ~[model-common-3.6.jar:na]<br>
                    at
<a href="http://com.evolveum.midpoint.model.co">com.evolveum.midpoint.model.co</a><wbr>mmon.expression.evaluator.Abst<wbr>ractValueTransformationExpress<wbr>ionEvaluator.evaluateAbsoluteE<wbr>xpression(AbstractValueTransfo<wbr>rmationExpressionEvaluator.<wbr>java:191)
            ~[model-common-3.6.jar:na]<br>
                    at
<a href="http://com.evolveum.midpoint.model.co">com.evolveum.midpoint.model.co</a><wbr>mmon.expression.evaluator.Abst<wbr>ractValueTransformationExpress<wbr>ionEvaluator.evaluate(Abstract<wbr>ValueTransformationExpressionE<wbr>valuator.java:95)
            ~[model-common-3.6.jar:na]<br>
                    at
<a href="http://com.evolveum.midpoint.repo.com">com.evolveum.midpoint.repo.com</a><wbr>mon.expression.Expression.eval<wbr>uateExpressionEvaluators(Expre<wbr>ssion.java:201)
            ~[repo-common-3.6.jar:na]<br>
                    at
<a href="http://com.evolveum.midpoint.repo.com">com.evolveum.midpoint.repo.com</a><wbr>mon.expression.Expression.eval<wbr>uate(Expression.java:146)
            ~[repo-common-3.6.jar:na]<br>
                    at
<a href="http://com.evolveum.midpoint.model.im">com.evolveum.midpoint.model.im</a><wbr>pl.expr.ModelExpressionThreadL<wbr>ocalHolder.evaluateExpressionI<wbr>nContext(ModelExpressionThread<wbr>LocalHolder.java:106)
            ~[model-impl-3.6.jar:na]<br>
                    at
com.evolveum.midpoint.notifica<wbr>tions.impl.helpers.BaseHelper.<wbr>evaluateBooleanExpression(Base<wbr>Helper.java:130)
            ~[notifications-impl-3.6.jar:n<wbr>a]<br>
                    at
com.evolveum.midpoint.notifica<wbr>tions.impl.helpers.BaseHelper.<wbr>evaluateBooleanExpressionCheck<wbr>ed(BaseHelper.java:108)
            ~[notifications-impl-3.6.jar:n<wbr>a]<br>
                    ... 22 common frames omitted<br>
            Caused by: javax.script.ScriptException:
            groovy.lang.MissingMethodExcep<wbr>tion: No signature of method:
com.evolveum.midpoint.notifica<wbr>tions.api.events.ModelEvent.<wbr>getResourceName()
            is applicable for argument types: () values: []<br>
                    at
org.codehaus.groovy.jsr223.Gro<wbr>ovyScriptEngineImpl.eval(Groov<wbr>yScriptEngineImpl.java:347)
            ~[groovy-all-2.4.0.jar:2.4.0]<br>
                    at
org.codehaus.groovy.jsr223.Gro<wbr>ovyCompiledScript.eval(GroovyC<wbr>ompiledScript.java:41)
            ~[groovy-all-2.4.0.jar:2.4.0]<br>
                    at
            javax.script.CompiledScript.ev<wbr>al(CompiledScript.java:92)
            ~[na:1.8.0_131]<br>
                    at
<a href="http://com.evolveum.midpoint.model.co">com.evolveum.midpoint.model.co</a><wbr>mmon.expression.script.jsr223.<wbr>Jsr223ScriptEvaluator.evaluate<wbr>(Jsr223ScriptEvaluator.java:11<wbr>1)
            ~[model-common-3.6.jar:na]<br>
                    ... 32 common frames omitted<br>
            <br>
            <br>
            <br>
            <br>
            <br>
            <br>
            <br>
            <br>
            <br>
          </div>
          <div>Please help<br>
            <br>
          </div>
          <div>
            <div>-- <br>
              <div class="m_5957642960629361867gmail-m_3726000040802528383gmail_signature">
                <div dir="ltr">
                  <div>
                    <div dir="ltr"><span style="color:rgb(76,76,76)">Best
                        regards, <br>
                        <br>
                        Oleksandr Nekriach | Identity and access
                        management engineer <br>
                        <br>
                        Dynatech, Mednieku str. 4a, Riga, LV-1010,
                        Latvia <br>
                        <br>
                        <div style="display:inline-block"><a href="tel:+371%2025%20314%20685" value="+37125314685" target="_blank">+37125314685</a></div>
                        ,
                        <div style="display:inline-block"><a href="mailto:o.nekriach@dynatech.lv" target="_blank">o.nekriach@dynatech.lv</a></div>
                        |
                        <div style="display:inline-block"><a href="http://www.dynatech.lv" target="_blank">www.dynatech.lv</a></div>
                        <br>
                        <br>
                        <img src="cid:part4.7E9E61FF.9EB33839@evolveum.com"> <br>
                        <br>
                        Stay connected: <br>
                        <div style="display:inline-block;margin:5px 5px 0px 0px"><a href="https://www.facebook.com/DynatechLatvia/?ref=br_rs" target="_blank"><img src="cid:part5.205CBE2C.BB122E61@evolveum.com"></a></div>
                        <div style="display:inline-block;margin:5px 0px 0px"><a href="https://www.linkedin.com/company-beta/17893047/" target="_blank"><img src="cid:part7.1169B1B0.7AE13D44@evolveum.com"></a></div>
                        <br>
                        <br>
                        <span style="font-size:11px;color:rgb(161,161,161)">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.</span></span></div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="m_5957642960629361867gmail-m_3726000040802528383mimeAttachmentHeader"></fieldset>
      <br>
      </div></div><pre>______________________________<wbr>_________________
midPoint mailing list
<a class="m_5957642960629361867gmail-m_3726000040802528383moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com" target="_blank">midPoint@lists.evolveum.com</a>
<a class="m_5957642960629361867gmail-m_3726000040802528383moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint" target="_blank">http://lists.evolveum.com/mail<wbr>man/listinfo/midpoint</a>
</pre>
    </blockquote>
    <br>
  </div>

<br>______________________________<wbr>_________________<br>
midPoint mailing list<br>
<a href="mailto:midPoint@lists.evolveum.com" target="_blank">midPoint@lists.evolveum.com</a><br>
<a href="http://lists.evolveum.com/mailman/listinfo/midpoint" rel="noreferrer" target="_blank">http://lists.evolveum.com/mail<wbr>man/listinfo/midpoint</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div class="m_5957642960629361867gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Gustáv Pálos</div><div>Identity Engineer</div><a href="http://evolveum.com/" rel="noreferrer" style="color:rgb(17,85,204);font-size:12.8px" target="_blank">evolveum.com</a><br></div></div>

</font></span></div></div></div>
<br>______________________________<wbr>_________________<br>
midPoint mailing list<br>
<a href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a><br>
<a href="http://lists.evolveum.com/mailman/listinfo/midpoint" rel="noreferrer" target="_blank">http://lists.evolveum.com/<wbr>mailman/listinfo/midpoint</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><span style="color:#4c4c4c">Best regards, <br><br>Oleksandr Nekriach | Identity and access management engineer <br><br>Dynatech, Mednieku str. 4a, Riga, LV-1010, Latvia <br><br><div style="display:inline-block"><a href="tel:+371%2025%20314%20685" value="+37125314685" target="_blank">+37125314685</a></div>, <div style="display:inline-block"><a href="mailto:o.nekriach@dynatech.lv" target="_blank">o.nekriach@dynatech.lv</a></div> | <div style="display:inline-block"><a href="http://www.dynatech.lv" target="_blank">www.dynatech.lv</a></div> <br><br><img src="cid:o.nekriach@dynatech.lv1502777022855-7770"> <br><br>Stay connected: <br><div style="display:inline-block;margin:5px 5px 0 0"><a href="https://www.facebook.com/DynatechLatvia/?ref=br_rs" target="_blank"><img src="cid:o.nekriach@dynatech.lv1502777022855-7771"></a></div><div style="display:inline-block;margin:5px 0 0 0"><a href="https://www.linkedin.com/company-beta/17893047/" target="_blank"><img src="cid:o.nekriach@dynatech.lv1502777022855-7772"></a></div><br><br><span style="font-size:11px;color:#a1a1a1">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.</span></span></div></div></div></div>
</div>