[midPoint] Issue with simple inbound mapping.
Deepak Natarajan
dnataraj at trilobytesystems.com
Tue Aug 26 17:44:11 CEST 2014
Hi Ivan -
I would like to discuss a bit about this issue since I've been running
into it over the past year (and I believe we have also had a few email
exchanges!).
I am doing EXACTLY as you are doing below (I tried just now without the
ri: namespace, same result).
My CSV Feed looks like this :
"id";"encoded-attributes"
"foo";"bar"
My CSV Resource Conf is :
<icfccsvfile:filePath>/Users/dnataraj/dev/axapoint/apos-home/apos-test-encoded.csv</icfccsvfile:filePath>
<icfccsvfile:encoding>utf-8</icfccsvfile:encoding><icfccsvfile:valueQualifier>"</icfccsvfile:valueQualifier><icfccsvfile:fieldDelimiter>;</icfccsvfile:fieldDelimiter><icfccsvfile:multivalueDelimiter>,</icfccsvfile:multivalueDelimiter><icfccsvfile:usingMultivalue>false</icfccsvfile:usingMultivalue><icfccsvfile:uniqueAttribute>id</icfccsvfile:uniqueAttribute>
And my attribute mapping looks like :
<attribute>
<ref>ri:encoded-attributes</ref>
<inbound>
<source>
<name>encodedAttrs</name>
<path>$account/attributes/encoded-attributes</path>
</source>
<expression>
<script>
<code>
...
</code>
</script>
</expression>
<target>
<path>extension/apos:encoded</path>
</target>
</inbound>
<inbound>
<source>
<name>encodedAttrs</name>
<path>$account/attributes/encoded-attributes</path>
</source>
<source>
<name>id</name>
<path>$account/attributes/id</path>
</source>
<expression>
<script>
...
</script>
</expression>
<target>
<path>$user/givenName</path>
</target>
</inbound>
Something that I have to do (and it works...) is have two or even more
<inbound> elements for the same resource attributes since I often have
to map and transform the same incoming field to different attributes in
MPT (This seems natural, and I guess it is supported)
In the above example, encodedAttrs is not null, but id is !
Over the past year I have been running into these strange periods when
the attributes I refer to in script expressions are NULL, but usually
they seem to work. It's as if I have a bug lurking somewhere, or these
variables go out of scope or something.
A good example is 'input' - here is my usage :
<attribute>
<ref>icfs:name</ref>
<inbound>
<c:expression>
<c:script>
<c:code>
input + '-apos'
</c:code>
</c:script>
</c:expression>
<target>
<path>$user/name</path>
</target>
</inbound>
</attribute>
And this works! But 'input' seems to be null (to be fair, the error
refers to the earlier mapping I have shown):
Caused by:
com.evolveum.midpoint.util.exception.ExpressionEvaluationException:
java.lang.NullPointerException expression in mapping in inbound
expression for
{http://midpoint.evolveum.com/xml/ns/public/resource/instance-3}encoded-attributes
in resource:036f0100-2fe8-49e1-a8fd-5548374f8703(APOS CSV Feeder
Resource Definition)({.../common/common-3}input=null;
{.../common/common-3}id=null;
{.../common/common-3}encodedAttrs=PPV(String:bar) in expression in
mapping in inbound expression for
{http://midpoint.evolveum.com/xml/ns/public/resource/instance-3}encoded-attributes
in resource:036f0100-2fe8-49e1-a8fd-5548374f8703(APOS CSV Feeder
Resource Definition)
at
com.evolveum.midpoint.model.common.expression.evaluator.AbstractValueTransformationExpressionEvaluator$1.process(AbstractValueTransformationExpressionEvaluator.java:423)
~[model-common-3.0.jar:na]
at
com.evolveum.midpoint.model.common.expression.evaluator.AbstractValueTransformationExpressionEvaluator$1.process(AbstractValueTransformationExpressionEvaluator.java:350)
~[model-common-3.0.jar:na]
at
I actually have a working resource configuration, where 'input' works in
this case :
<attribute>
<ref>ri:managerGroups</ref>
<displayName>Managers Group</displayName>
<inbound>
<expression>
<script>
<code>
return input ? input.tokenize(',') : []
</code>
</script>
</expression>
<target>
<path>extension/apos:managerGroupMembership</path>
</target>
</inbound>
</attribute>
But it does not work in another mapping in the same resource! (I could
not use 'input' in the script expression, so had to create an explicit var :
<attribute>
<ref>ri:unitchain</ref>
<limitations>
<layer>presentation</layer>
<ignore>true</ignore>
</limitations>
<inbound>
<source>
<name>unitChain</name>
<path>$account/attributes/ri:unitchain</path>
</source>
<expression>
<script>
<code>
return
unitChain.split('/').reverse().join("/")
</code>
</script>
</expression>
<target>
<path>extension/apos:aposUnitUuidPathToRoot</path>
</target>
</inbound>
</attribute>
But above, you can see that $account/attributes/ri:unitchain works! (And
I have a similar expression that does not work now).
Also, I have to first set another variable to 'input' before I can use
it, like so :
<attribute>
<ref>ri:email</ref>
<inbound>
<c:expression>
<c:script>
<c:code>
def email = input
return email ? email.split('@')[0] + '-apos@' +
email.split('@')[1] : ''
</c:code>
</c:script>
</c:expression>
<target>
<path>$user/emailAddress</path>
</target>
</inbound>
</attribute>
Using input directly in the expression, results in a NPE.
It's quite baffling imo, but luckily can be worked around.
But now I'm stuck with account attributes being null, plain and simple :(
Ivan Noris wrote:
> Hi Deepak,
>
> I've just checked one of my customer objects for 3.0.x
>
> I'm using this:
>
> <attribute>
> <ref>ri:P0000_ATTR1</ref>
> <displayName>Attr1</displayName>
> <inbound>
> <source>
> <name>ATTRX</name>
>
> <path>$account/attributes/P0001_ATTRX</path>
> </source>
> <source>
> <name>ATTRY</name>
> <path>$account/attributes/ATTRY</path>
> </source>
> <expression>
> . . .
>
> But it should also work with "ri:" prefixes, if the "ri" namespace is
> defined and correct
> (xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"
> - I define it usually at the resource level).
>
> How are you referencing your "input" implicit variable?
> In my expression (Groovy) it is:
>
> if (*input* == '0') return 'FormerEmployee'
>
> Are you perhaps referencing it as "$input" instead of "input"... ?
> Also, the source attributes in my sample would be referenced as "ATTRX"
> / "ATTRY" in the Groovy expressions.
>
>
> Regards,
> Ivan
>
>
> On 08/26/2014 11:35 AM, Deepak Natarajan wrote:
>> Hi -
>>
>> I find some simple inbound mapping behaving inconsistently (I'm
>> obviously doing something wrong)
>>
>> My source feed (CSV) :
>>
>> <icfccsvfile:encoding>utf-8</icfccsvfile:encoding>
>> <icfccsvfile:valueQualifier>"</icfccsvfile:valueQualifier>
>> <icfccsvfile:fieldDelimiter>;</icfccsvfile:fieldDelimiter>
>>
>> <icfccsvfile:multivalueDelimiter>,</icfccsvfile:multivalueDelimiter>
>>
>> <icfccsvfile:usingMultivalue>false</icfccsvfile:usingMultivalue>
>>
>> <icfccsvfile:uniqueAttribute>id</icfccsvfile:uniqueAttribute>
>>
>> "id";"encoded-attributes"
>> "foo";"3AARpkJyaXR0YalSYXNtdXN"
>>
>> and my mappings :
>>
>> <attribute>
>> <ref>icfs:uid</ref>
>> <limitations>
>> <access>
>> <read>true</read>
>> </access>
>> </limitations>
>> </attribute>
>>
>> <attribute>
>> <ref>icfs:name</ref>
>> <inbound>
>> <c:expression>
>> <c:script>
>> <c:code>
>> input + '-suffix'
>> </c:code>
>> </c:script>
>> </c:expression>
>> <target>
>> <path>$user/name</path>
>> </target>
>> </inbound>
>> </attribute>
>>
>> <attribute>
>> <ref>ri:encoded-attributes</ref>
>> <inbound>
>> <source>
>> <name>encodedAttrs</name>
>>
>> <path>$account/attributes/ri:encoded-attributes</path>
>> </source>
>> <source>
>> <name>id</name>
>> <path>$account/attributes/ri:id</path>
>> </source>
>> ....
>> ....
>> </inbound>
>>
>> Is this incorrect?
>>
>> The thing is, I have used this configuration before, without any
>> changes, and it used to work. Today it fails (my VCS system shows my
>> working version had these mappings)
>>
>> Caused by:
>> com.evolveum.midpoint.util.exception.ExpressionEvaluationException:
>> java.lang.NullPointerException expression in mapping in inbound
>> expression for
>> {http://midpoint.evolveum.com/xml/ns/public/resource/instance-3}encoded-attributes
>> in resource:036f0100-2fe8-49e1-a8fd-5548374f8703(APOS CSV Feeder
>> Resource Definition)({.../common/common-3}input=null;
>> {.../common/common-3}id=null;
>> {.../common/common-3}encodedAttrs=PPV(String:3AARpkJyaXR0YalSYXNtdXN );
>> ) in expression in mapping in inbound expression for
>> {http://midpoint.evolveum.com/xml/ns/public/resource/instance-3}encoded-attributes
>> in resource:036f0100-2fe8-49e1-a8fd-5548374f8703(APOS CSV Feeder
>> Resource Definition)
>>
>> Why is "input" implicit variable and id both null?
>>
>> Thanks for any help!
>>
>> -
>> Deepak Natarajan
>>
>> _______________________________________________
>> midPoint mailing list
>> midPoint at lists.evolveum.com
>> http://lists.evolveum.com/mailman/listinfo/midpoint
>
> --
> Ing. Ivan Noris
> Senior Identity Management Engineer
> evolveum.com
> ___________________________________________
> "Idem per idem - semper idem Vix."
>
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> http://lists.evolveum.com/mailman/listinfo/midpoint
--
Deepak Natarajan
Director
Trilobyte Systems ApS
Falkoner Alle 1, 3 Fredrikinkatu 61A, 6th Floor
2000 Frederiksberg Business Center Papula
Denmark 00100 Helsinki
Finland
Tel : +45 29375068
http://www.trilobytesystems.com
More information about the midPoint
mailing list