<html><head><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"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">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);"><font face="Lucida Sans" size="1" class=""></font></span></div></div></div></div></div>
</div>
<br class=""></div></body></html>