[midPoint] Template modification

Pavol Mederly mederly at evolveum.com
Fri Jan 26 12:35:12 CET 2018


Hello Jan,

it is interesting but in my case the script works (invoking it as a bulk 
action, just to test it):

<s:pipeline 
xmlns:s="http://midpoint.evolveum.com/xml/ns/public/model/scripting-3">
     <s:expression xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:type="s:SearchExpressionType">
         <s:type>ObjectType</s:type>
         <s:searchFilter>
             <q:inOid 
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3">
<q:value>00000000-0000-0000-0000-000000000002</q:value>
                 <!-- administrator -->
             </q:inOid>
         </s:searchFilter>
     </s:expression>
     <s:expression xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:type="s:ActionExpressionType">
         <s:type>execute-script</s:type>
         <s:parameter>
             <s:name>script</s:name>
             <c:value xsi:type="c:ScriptExpressionEvaluatorType" 
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3">
                 <c:code>
                      import 
com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
            import 
com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
            import 
com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType;
            import 
com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;
            import java.util.*;

            ADGroup = "End user"
            log.warn("XXX assigning from SAP role {}", ADGroup)
            if (ADGroup != null) {
                 orgName = ADGroup;

                 org = midpoint.searchObjectByName(RoleType.class, orgName);
                 if (org != null)
                 {
                     log.info("org {}" , org)
                     orgOrt = new ObjectReferenceType();
                     orgOrt.setOid(org.getOid());
orgOrt.setType(RoleType.COMPLEX_TYPE);

                     AssignmentType assignment = new AssignmentType();
                     assignment.asPrismContainerValue()
                     assignment.setTargetRef(orgOrt);
                     return assignment
                 }
            }
                 </c:code>
             </c:value>
         </s:parameter>
    </s:expression>
</s:pipeline>

Just a few notes (but these have no impact on the exception you experience):

 1. You use orgName/org but you search for RoleType.class - it probably
    should be OrgType.class.
 2. assignment.asPrismContainerValue() can be probably eliminated; it
    does nothing.

Maybe you could rewrite your groovy code in a bit different way... I 
really don't know.

Pavol Mederly
Software developer
evolveum.com

On 23.01.2018 7:32, Jan Kaspar wrote:
> Hi Oskar, all,
>
> Yes i tryed this, but it didnt work. with that code:
>
>             <code>
>    import 
> com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
>    import 
> com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
>    import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType;
>    import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;
>    import java.util.*;
>    log.warn("XXX assigning from SAP role {}" , ADGroup)
>    if (ADGroup != null){
> orgName = ADGroup;
>                 org = midpoint.searchObjectByName(RoleType.class, 
> orgName);
>                 if (org != null)
>                 {
>                     log.info("org {}" , org)
>                     orgOrt = new ObjectReferenceType();
> orgOrt.setOid(org.getOid());
> orgOrt.setType(RoleType.COMPLEX_TYPE);
>
> AssignmentType assignment = new AssignmentType();
> assignment.asPrismContainerValue()
> assignment.setTargetRef(orgOrt);
>         return assignment
>     }
>    }
>    </code>
>
> I got error:
>
>
> Operation
>     Reconcile user (Gui): {0}
> Message
>     Couldn't reconcile user
>     user:08c284d4-8bc8-4b1a-a598-785773c51d62(ales.levinsky).
>
> Error
>     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 at 2eb5683] Possible solutions: find(), any(),
>     is(java.lang.Object), wait(), dump(), grep() in expression in
>     mapping in inbound expression for
>     {http://midpoint.evolveum.com/xml/ns/public/resource/instance-3}memberOf
>     in resource:746ecf5e-3e8c-11e6-b2f9-3c970e44b9e2(BLUED
>     (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
>     {http://midpoint.evolveum.com/xml/ns/public/resource/instance-3}memberOf
>     in resource:746ecf5e-3e8c-11e6-b2f9-3c970e44b9e2(BLUED (LDAP))
>
> Any idea? I fouind some things on internet about bug in groovy. But 
> without solution for now.
>
> Jan
>
>
>
>
>
>
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> http://lists.evolveum.com/mailman/listinfo/midpoint

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20180126/103bf3c9/attachment.htm>


More information about the midPoint mailing list