<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hello Jan,</p>
    <p>it is interesting but in my case the script works (invoking it as
      a bulk action, just to test it):</p>
    <p><tt><s:pipeline
xmlns:s=<a class="moz-txt-link-rfc2396E" href="http://midpoint.evolveum.com/xml/ns/public/model/scripting-3">"http://midpoint.evolveum.com/xml/ns/public/model/scripting-3"</a>></tt><tt><br>
      </tt><tt>    <s:expression
        xmlns:xsi=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema-instance">"http://www.w3.org/2001/XMLSchema-instance"</a>
        xsi:type="s:SearchExpressionType"></tt><tt><br>
      </tt><tt>        <s:type>ObjectType</s:type></tt><tt><br>
      </tt><tt>        <s:searchFilter></tt><tt><br>
      </tt><tt>            <q:inOid
        xmlns:q=<a class="moz-txt-link-rfc2396E" href="http://prism.evolveum.com/xml/ns/public/query-3">"http://prism.evolveum.com/xml/ns/public/query-3"</a>></tt><tt><br>
      </tt><tt>               
        <q:value>00000000-0000-0000-0000-000000000002</q:value></tt><tt><br>
      </tt><tt>                <!-- administrator --></tt><tt><br>
      </tt><tt>            </q:inOid></tt><tt><br>
      </tt><tt>        </s:searchFilter></tt><tt><br>
      </tt><tt>    </s:expression></tt><tt><br>
      </tt><tt>    <s:expression
        xmlns:xsi=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema-instance">"http://www.w3.org/2001/XMLSchema-instance"</a>
        xsi:type="s:ActionExpressionType"></tt><tt><br>
      </tt><tt>        <s:type>execute-script</s:type></tt><tt><br>
      </tt><tt>        <s:parameter></tt><tt><br>
      </tt><tt>            <s:name>script</s:name></tt><tt><br>
      </tt><tt>            <c:value
        xsi:type="c:ScriptExpressionEvaluatorType"
        xmlns:c=<a class="moz-txt-link-rfc2396E" href="http://midpoint.evolveum.com/xml/ns/public/common/common-3">"http://midpoint.evolveum.com/xml/ns/public/common/common-3"</a>></tt><tt><br>
      </tt><tt>                <c:code></tt><tt><br>
      </tt><tt>                     import
        com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;</tt><tt><br>
      </tt><tt>           import
com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;</tt><tt><br>
      </tt><tt>           import
        com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType;</tt><tt><br>
      </tt><tt>           import
        com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;</tt><tt><br>
      </tt><tt>           import java.util.*;</tt><tt><br>
      </tt><tt>           </tt><tt><br>
      </tt><tt>           ADGroup = "End user"</tt><tt><br>
      </tt><tt>           log.warn("XXX assigning from SAP role {}",
        ADGroup)</tt><tt><br>
      </tt><tt>           if (ADGroup != null) {</tt><tt><br>
      </tt><tt>                orgName = ADGroup;</tt><tt><br>
      </tt><tt>                </tt><tt><br>
      </tt><tt>                org =
        midpoint.searchObjectByName(RoleType.class, orgName);</tt><tt><br>
      </tt><tt>                if (org != null)</tt><tt><br>
      </tt><tt>                {</tt><tt><br>
      </tt><tt>                    log.info("org {}" , org)</tt><tt><br>
      </tt><tt>                    orgOrt = new ObjectReferenceType();</tt><tt><br>
      </tt><tt>                    orgOrt.setOid(org.getOid());</tt><tt><br>
      </tt><tt>                   
        orgOrt.setType(RoleType.COMPLEX_TYPE);</tt><tt><br>
      </tt><tt><br>
      </tt><tt>                    AssignmentType assignment = new
        AssignmentType();</tt><tt><br>
      </tt><tt>                    assignment.asPrismContainerValue()</tt><tt><br>
      </tt><tt>                    assignment.setTargetRef(orgOrt);</tt><tt><br>
      </tt><tt>                    return assignment</tt><tt><br>
      </tt><tt>                }</tt><tt><br>
      </tt><tt>           }</tt><tt><br>
      </tt><tt>                </c:code></tt><tt><br>
      </tt><tt>            </c:value></tt><tt><br>
      </tt><tt>        </s:parameter></tt><tt><br>
      </tt><tt>   </s:expression></tt><tt><br>
      </tt><tt></s:pipeline></tt><tt><br>
      </tt><br>
    </p>
    <p>Just a few notes (but these have no impact on the exception you
      experience):</p>
    <ol>
      <li>You use orgName/org but you search for RoleType.class - it
        probably should be OrgType.class.</li>
      <li>assignment.asPrismContainerValue() can be probably eliminated;
        it does nothing.</li>
    </ol>
    <p>Maybe you could rewrite your groovy code in a bit different
      way... I really don't know.<br>
    </p>
    <pre class="moz-signature" cols="72">Pavol Mederly
Software developer
evolveum.com
</pre>
    <div class="moz-cite-prefix">On 23.01.2018 7:32, Jan Kaspar wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:71X.vQU.4puiiecPnT3.1QPjRW@seznam.cz">Hi Oskar, all,
      <div><br>
      </div>
      <div>Yes i tryed this, but it didnt work. with that code:</div>
      <div><br>
      </div>
      <div>
        <div>            <code></div>
        <div><span style="white-space:pre">               </span>   import
          com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;</div>
        <div><span style="white-space:pre">               </span>   import
com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;</div>
        <div><span style="white-space:pre">               </span>   import
          com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType;</div>
        <div><span style="white-space:pre">               </span>   import
          com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;</div>
        <div><span style="white-space:pre">               </span>   import
          java.util.*;</div>
        <div><span style="white-space:pre">               </span>   </div>
        <div><span style="white-space:pre">               </span>   log.warn("XXX
          assigning from SAP role {}" , ADGroup)</div>
        <div><span style="white-space:pre">               </span>   if (ADGroup !=
          null){</div>
        <div><span style="white-space:pre">                               </span>orgName = ADGroup;</div>
        <div><span style="white-space:pre">                       </span>    </div>
        <div>                org =
          midpoint.searchObjectByName(RoleType.class, orgName);</div>
        <div>                if (org != null)</div>
        <div>                {</div>
        <div>                    log.info("org {}" , org)</div>
        <div>                    orgOrt = new ObjectReferenceType();</div>
        <div><span style="white-space:pre">                       </span>       
          orgOrt.setOid(org.getOid());</div>
        <div><span style="white-space:pre">                       </span>       
          orgOrt.setType(RoleType.COMPLEX_TYPE);</div>
        <div><br>
        </div>
        <div><span style="white-space:pre">                       </span>       
          AssignmentType assignment = new AssignmentType();</div>
        <div><span style="white-space:pre">                       </span>       
          assignment.asPrismContainerValue()</div>
        <div><span style="white-space:pre">                       </span>       
          assignment.setTargetRef(orgOrt);</div>
        <div><span style="white-space:pre">                       </span>        return
          assignment</div>
        <div><span style="white-space:pre">                       </span>    }</div>
        <div><span style="white-space:pre">               </span>   }</div>
        <div><span style="white-space:pre">               </span>   </code></div>
      </div>
      <div><br>
      </div>
      <div>I got error:</div>
      <div><br>
      </div>
      <div>
        <div><br>
        </div>
        <div><dt
style="box-sizing:border-box;line-height:1.42857;font-weight:700;float:left;width:100px;overflow:hidden;clear:left;text-align:right;text-overflow:ellipsis;white-space:nowrap;color:rgb(51,51,51);font-family:'Source
            Sans Pro','Helvetica
            Neue',Helvetica,Arial,sans-serif;font-size:14px">Operation</dt>
          <dd
style="box-sizing:border-box;line-height:1.42857;margin-left:130px;word-break:break-word;color:rgb(51,51,51);font-family:'Source
            Sans Pro','Helvetica
            Neue',Helvetica,Arial,sans-serif;font-size:14px"><span
              style="box-sizing:border-box;font-weight:700">Reconcile
              user (Gui): {0}</span></dd>
          <dt
style="box-sizing:border-box;line-height:1.42857;font-weight:700;float:left;width:100px;overflow:hidden;clear:left;text-align:right;text-overflow:ellipsis;white-space:nowrap;color:rgb(51,51,51);font-family:'Source
            Sans Pro','Helvetica
            Neue',Helvetica,Arial,sans-serif;font-size:14px">Message</dt>
          <dd
style="box-sizing:border-box;line-height:1.42857;margin-left:130px;word-break:break-word;color:rgb(51,51,51);font-family:'Source
            Sans Pro','Helvetica
            Neue',Helvetica,Arial,sans-serif;font-size:14px">Couldn't
            reconcile user
            user:08c284d4-8bc8-4b1a-a598-785773c51d62(ales.levinsky).</dd>
          <dd
style="box-sizing:border-box;line-height:1.42857;margin-left:130px;word-break:break-word;color:rgb(51,51,51);font-family:'Source
            Sans Pro','Helvetica
            Neue',Helvetica,Arial,sans-serif;font-size:14px">
            <table
style="box-sizing:border-box;border-spacing:0px;border-collapse:collapse;background-color:transparent;border:0px">
            </table>
          </dd>
          <dd
style="box-sizing:border-box;line-height:1.42857;margin-left:130px;word-break:break-word;color:rgb(51,51,51);font-family:'Source
            Sans Pro','Helvetica
            Neue',Helvetica,Arial,sans-serif;font-size:14px">
            <table
style="box-sizing:border-box;border-spacing:0px;border-collapse:collapse;background-color:transparent;border:0px">
            </table>
          </dd>
          <dt
style="box-sizing:border-box;line-height:1.42857;font-weight:700;float:left;width:100px;overflow:hidden;clear:left;text-align:right;text-overflow:ellipsis;white-space:nowrap;color:rgb(51,51,51);font-family:'Source
            Sans Pro','Helvetica
            Neue',Helvetica,Arial,sans-serif;font-size:14px">Error</dt>
          <dd
style="box-sizing:border-box;line-height:1.42857;margin-left:130px;word-break:break-word;color:rgb(51,51,51);font-family:'Source
            Sans Pro','Helvetica
            Neue',Helvetica,Arial,sans-serif;font-size:14px">groovy.lang.MissingMethodException:
            No signature of method:
            org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.If() is
            applicable for argument types: (java.lang.Boolean,
            Script31$_run_closure1) values: [true,
            Script31$_run_closure1@2eb5683] Possible solutions: find(),
            any(), is(java.lang.Object), wait(), dump(), grep() in
            expression in mapping in inbound expression for
            {<a class="moz-txt-link-freetext" href="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3">http://midpoint.evolveum.com/xml/ns/public/resource/instance-3</a>}memberOf
            in <a class="moz-txt-link-freetext" href="resource:746ecf5e-3e8c-11e6-b2f9-3c970e44b9e2(BLUED">resource:746ecf5e-3e8c-11e6-b2f9-3c970e44b9e2(BLUED</a>
(LDAP))({.../common/common-3}input=CN=POS_AX_ADMINS,OU=Groups,OU=CZ,DC=domain,DC=local;
            ) in expression in mapping in inbound expression for
            {<a class="moz-txt-link-freetext" href="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3">http://midpoint.evolveum.com/xml/ns/public/resource/instance-3</a>}memberOf
            in <a class="moz-txt-link-freetext" href="resource:746ecf5e-3e8c-11e6-b2f9-3c970e44b9e2(BLUED">resource:746ecf5e-3e8c-11e6-b2f9-3c970e44b9e2(BLUED</a>
            (LDAP))</dd>
        </div>
      </div>
      <div><br>
      </div>
      <div>Any idea? I fouind some things on internet about bug in
        groovy. But without solution for now.</div>
      <div><br>
      </div>
      <div>Jan</div>
      <div><br>
      </div>
      <div><br>
      </div>
      <div><dd
style="box-sizing:border-box;line-height:1.42857;margin-left:130px;word-break:break-word;color:rgb(51,51,51);font-family:'Source
          Sans Pro','Helvetica
          Neue',Helvetica,Arial,sans-serif;font-size:14px"><br>
        </dd>
        <dd
style="box-sizing:border-box;line-height:1.42857;margin-left:130px;word-break:break-word;color:rgb(51,51,51);font-family:'Source
          Sans Pro','Helvetica
          Neue',Helvetica,Arial,sans-serif;font-size:14px"><br>
        </dd>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
midPoint mailing list
<a class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a>
<a class="moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>