[midPoint] Re. Referring to resource variable inside expression.

Ivan Noris ivan.noris at evolveum.com
Thu Jan 2 15:03:32 CET 2014


Hi Deepak,

just a blind shot - try to use implicit variable named "input" (it is
mapped to the "source" of the inbound expression, in your case, ri:orgdesc).

See an example (adapted from my customer's resource) written in Groovy
(not XPath):

<attribute>
    <ref>ri:orgUnitHierarchy</ref>
    <displayName>Organizational Hierarchy</displayName>
    <access>read</access>
    <inbound>
    <expression>
        <script>
            <code>
String[] tmpHierarchyList = *input* ? *input*?.split('\\.') : []
tmpHierarchyListNew = []

<!-- some processing skipped here . . . -->

return tmpHierarchyListNew.join(':')
</code>
        </script>
    </expression>
      <target>
    <path>$user/extension/mycustomer:ouPath</path>
      </target>
    </inbound>
</attribute>

I do not use XPath in expressions unless absolutely necessary because
the debugging is quite _challenging_ ;) and it's lot easier to debug
Groovy statements.

Regards,
Ivan

On 01/02/2014 02:50 PM, Deepak Natarajan wrote:
>
> Hi -
>
> I'm struggling with a simple evaluation (I've removed namespace
> declarations for readability) :
>
>                 <attribute>
>                     <ref>ri:orgdesc</ref>
>                     <inbound>
>                         <expression>
>                             <script>
>                                
> <language>http://www.w3.org/TR/xpath/</language>
>                                 <code ...>
>                                    
> tokenize($account/attributes/ri:orgdesc,"/")[last()]
>                                 </code>
>                             </script>
>                         </expression>
>                         <target>
>                            
> <path>$user/extension/apos:aposUnitAttributes</path>
>                         </target>
>                     </inbound>
>                 </attribute>
>
> I've tried everything, but the variable passed to the XPath tokenize
> function is always nil (I know the function works correctly, since I
> use it elsewhere, and using a literal string above produces the
> correct results)
>
> I've tried including a <source> before the expression with an explicit
> <name> but that doesn't seem to work either.
>
> Thanks for any input! - I'm using build Version: 2.3-SNAPSHOT,
> describe: git-v2.3devel-383-g6ef8f72
>
> BR/Deepak
>
>
>
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> http://lists.evolveum.com/mailman/listinfo/midpoint

-- 
  Ing. Ivan Noris
  Consultant
  Evolveum, s.r.o
  ___________________________________________________
  "Semper cautus - semper paratus - semper idem Vix."

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20140102/82172af5/attachment.htm>


More information about the midPoint mailing list