<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Hi,<br>
      <br>
      I'm not sure if I understand what you are trying to do. But
      perhaps one clarification is needed:<br>
      <br>
      In midPoint the roles are for giving access rights and
      organizations are for grouping identities. This is sometimes the
      same, but in some cases there is a big difference. It is explained
      here:<br>
      <br>
      <a class="moz-txt-link-freetext" href="https://wiki.evolveum.com/display/midPoint/Roles+and+Orgs">https://wiki.evolveum.com/display/midPoint/Roles+and+Orgs</a><br>
      <br>
      So, if you want to have a role that have multiple approvers then
      the easiest way is to put all the approvers in one Org and then
      use the Org as an approver. (Remember: a user may belong to any
      number of Orgs in midPoint).<br>
      <br>
      <pre class="moz-signature" cols="72">-- 
Radovan Semancik
Software Architect
evolveum.com</pre>
      <br>
      <br>
      On 09/15/2015 12:45 PM, Fabio Contessi wrote:<br>
    </div>
    <blockquote cite="mid:3586FA04-61C5-4DCB-9A19-4F1531047654@nsr.it"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      Hi,
      <div class="">I have a problem with the approver expression in
        midpoint 3.2, in the xml object "System Configuration".</div>
      <div class=""><br class="">
      </div>
      <div class="">I need to identify the approver by role assignment.
        So, I’m using this code snippet:</div>
      <div class=""><br class="">
      </div>
      <div class="">
        <div class=""><approverExpression></div>
        <div class="">    <description></description></div>
        <div class="">    <script></div>
        <div class="">        <code></div>
        <div class="">            import
          com.evolveum.midpoint.prism.query.RefFilter</div>
        <div class="">            import
          com.evolveum.midpoint.prism.PrismContext</div>
        <div class="">            import
          com.evolveum.midpoint.prism.query.ObjectQuery</div>
        <div class="">            import javax.xml.namespace.QName</div>
        <div class="">            import
          com.evolveum.midpoint.prism.path.ItemPath</div>
        <div class="">            import
          com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType</div>
        <div class="">            import
          com.evolveum.midpoint.xml.ns._public.common.common_3.UserType</div>
        <div class="">          </div>
        <div class="">            String[] names =
          ["Role-Approvatore-AD-XXX"]</div>
        <div class="">            PrismContext prismContext =
midpoint.createEmptyObject(UserType.class).asPrismObject().getPrismContext() </div>
        <div class="">            RefFilter filter =
RefFilter.createReferenceEqual(UserType.F_ASSIGNMENT,UserType.class,prismContext,names)</div>
        <div class="">            ObjectQuery query =
          ObjectQuery.createObjectQuery(filter)</div>
        <div class="">            list =
          midpoint.searchObjects(UserType.class, query)</div>
        <div class="">            for (def i = 0; i &lt;
          list.size(); i++) {</div>
        <div class="">                def oid = list.get(i).getOid()</div>
        <div class="">                lOut.add(oid)</div>
        <div class="">            }</div>
        <div class="">            return lOut</div>
        <div class="">        </code></div>
        <div class="">    </script></div>
        <div class=""></approverExpression></div>
        <div class=""><br class="">
        </div>
        <div class="">but I get this error:</div>
        <div class=""><br class="">
        </div>
        <div class="">
          <div class="">Error:
            com.evolveum.midpoint.util.exception.ExpressionEvaluationException:
            java.lang.ClassCastException:
            com.evolveum.midpoint.prism.PrismContainerDefinition cannot
            be cast to
            com.evolveum.midpoint.prism.PrismReferenceDefinition (new)
            approverExpression</div>
          <div class="">2015-09-15 12:37:04,163 [MODEL] [Thread-57]
            ERROR
            (com.evolveum.midpoint.model.common.expression.Expression):
            Error evaluating expression in approverExpression:
            java.lang.ClassCastException:
            com.evolveum.midpoint.prism.PrismContainerDefinition cannot
            be cast to
            com.evolveum.midpoint.prism.PrismReferenceDefinition (new)
            approverExpression</div>
          <div class="">com.evolveum.midpoint.util.exception.ExpressionEvaluationException:
            java.lang.ClassCastException:
            com.evolveum.midpoint.prism.PrismContainerDefinition cannot
            be cast to
            com.evolveum.midpoint.prism.PrismReferenceDefinition (new)
            approverExpression</div>
        </div>
        <div class=""><br class="">
        </div>
        <div class="">Maybe I’m doing something wrong. Anyone could help
          me?</div>
        <div class=""><br class="">
        </div>
        <div class="">Thanks and regards.</div>
        <div class=""><br class="">
        </div>
        <div class="">  Fabio</div>
        <div class=""><br class="">
        </div>
        <div apple-content-edited="true" class="">
          <div style="color: rgb(0, 0, 0); letter-spacing: normal;
            orphans: auto; text-align: start; text-indent: 0px;
            text-transform: none; white-space: normal; widows: auto;
            word-spacing: 0px; -webkit-text-stroke-width: 0px;
            word-wrap: break-word; -webkit-nbsp-mode: space;
            -webkit-line-break: after-white-space;" class="">
            <div style="color: rgb(0, 0, 0); letter-spacing: normal;
              orphans: auto; text-align: start; text-indent: 0px;
              text-transform: none; white-space: normal; widows: auto;
              word-spacing: 0px; -webkit-text-stroke-width: 0px;
              word-wrap: break-word; -webkit-nbsp-mode: space;
              -webkit-line-break: after-white-space;" class="">
              <div style="color: rgb(0, 0, 0); letter-spacing: normal;
                orphans: auto; text-align: start; text-indent: 0px;
                text-transform: none; white-space: normal; widows: auto;
                word-spacing: 0px; -webkit-text-stroke-width: 0px;
                word-wrap: break-word; -webkit-nbsp-mode: space;
                -webkit-line-break: after-white-space;" class="">
                <div style="color: rgb(0, 0, 0); letter-spacing: normal;
                  orphans: auto; text-align: start; text-indent: 0px;
                  text-transform: none; white-space: normal; widows:
                  auto; word-spacing: 0px; -webkit-text-stroke-width:
                  0px; word-wrap: break-word; -webkit-nbsp-mode: space;
                  -webkit-line-break: after-white-space;" class="">
                  <div class=""><br class="">
                  </div>
                  <div class=""><span class="" style="orphans: 2;
                      widows: 2; color: rgb(17, 52, 80);"></span></div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <br class="">
      </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>
    <br>
    <pre class="moz-signature" cols="72">
</pre>
  </body>
</html>