[midPoint] ValidFrom and ValidTo

František Dvořák valtri at civ.zcu.cz
Mon Jan 1 22:38:59 CET 2018


Hello,

just a hint - the problem here is with the locale-dependent
SimpleDateFormat in the groovy script - the "AM" string.

  František

Jan Kaspar píše v Po 01. 01. 2018 v 20:20 +0100:
> Hi All,
> 
> need help with importing date times in MidPoint from CSV.
> 
> In CSV there is date time in format:  "12/31/2000 11:00:00 AM" 
> 
> In resource i have enabled activation capability and I tryed to map
> value as showwn in config bellow:
> 
>          <attribute id="12">
>             <c:ref>ri:StartDate</c:ref>
>             <tolerant>true</tolerant>
>             <exclusiveStrong>false</exclusiveStrong>
>             <inbound id="17">
>                <authoritative>true</authoritative>
>                <exclusive>false</exclusive>
>                <strength>normal</strength>
>                <expression>
>                   <script xmlns:xsi="http://www.w3.org/2001/XMLSchema
> -instance"
>                           xsi:type="c:ScriptExpressionEvaluatorType">
>                      <code>
>        import java.text.SimpleDateFormat;
>        import java.text.DateFormat;
> 
>        DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss a");
> 
>        if (input!=null) {
>            Date convertedValidFrom = df.parse(input);
>      log.info ("convertedValidFrom = " +
>      convertedValidFrom);
> 
>            return
>    
>  com.evolveum.midpoint.util.MiscUtil.asXMLGregorianCalendar(converted
> ValidFrom);
>        }
>        else {
>            return null;
>        }
> 
>                                  </code>
>                   </script>
>                </expression>
>                <target>
>                   <c:path>$focus/activation/validFrom</c:path>
>                </target>
>             </inbound>
>          </attribute>
> 
> But it doesnt work to me. I am getting error messages like here:
> 
> 1001: java.text.ParseException: Unparseable date: "12/31/2000
> 11:00:00 AM" in expression in mapping in inbound expression for {http
> ://midpoint.evolveum.com/xml/ns/public/resource/instance-3}StartDate
> in resource:900dd939-02da-48f2-a7b9-683de6b8d486(HR
> Feed)({.../common/common-3}input=12/31/2000 11:00:00 AM; ) in
> expression in mapping in inbound expression for
> {http://midpoint.evolveum.com/xml/ns/public/resource/instance-
> 3}StartDate in resource:900dd939-02da-48f2-a7b9-683de6b8d486(HR Feed)
> Operation
> Save (GUI)
> Message
> java.text.ParseException: Unparseable date: "12/31/2000 11:00:00 AM"
> in expression in mapping in inbound expression for {http://midpoint.e
> volveum.com/xml/ns/public/resource/instance-3}StartDate in
> resource:900dd939-02da-48f2-a7b9-683de6b8d486(HR
> Feed)({.../common/common-3}input=12/31/2000 11:00:00 AM; ) in
> expression in mapping in inbound expression for
> {http://midpoint.evolveum.com/xml/ns/public/resource/instance-
> 3}StartDate in resource:900dd939-02da-48f2-a7b9-683de6b8d486(HR Feed)
> Error
> java.text.ParseException: Unparseable date: "12/31/2000 11:00:00 AM"
> in expression in mapping in inbound expression for {http://midpoint.e
> volveum.com/xml/ns/public/resource/instance-3}StartDate in
> resource:900dd939-02da-48f2-a7b9-683de6b8d486(HR
> Feed)({.../common/common-3}input=12/31/2000 11:00:00 AM; ) in
> expression in mapping in inbound expression for
> {http://midpoint.evolveum.com/xml/ns/public/resource/instance-
> 3}StartDate in resource:900dd939-02da-48f2-a7b9-683de6b8d486(HR Feed)
> show
> com.evolveum.midpoint.util.exception.ExpressionEvaluationException:
> java.text.ParseException: Unparseable date: "12/31/2000 11:00:00 AM"
> in expression in mapping in inbound expression for {http://midpoint.e
> volveum.com/xml/ns/public/resource/instance-3}StartDate in
> resource:900dd939-02da-48f2-a7b9-683de6b8d486(HR
> Feed)({.../common/common-3}input=12/31/2000 11:00:00 AM; ) in
> expression in mapping in inbound expression for
> {http://midpoint.evolveum.com/xml/ns/public/resource/instance-
> 3}StartDate in resource:900dd939-02da-48f2-a7b9-683de6b8d486(HR Feed)
> 	at
> com.evolveum.midpoint.model.common.expression.evaluator.AbstractValue
> TransformationExpressionEvaluator.lambda$evaluateRelativeExpression$0
> (AbstractValueTransformationExpressionEvaluator.java:433)
> 	at
> com.evolveum.midpoint.util.MiscUtil.carthesian(MiscUtil.java:370)
> 	at
> com.evolveum.midpoint.util.MiscUtil.carthesian(MiscUtil.java:360)
> 	at
> com.evolveum.midpoint.model.common.expression.evaluator.AbstractValue
> TransformationExpressionEvaluator.evaluateRelativeExpression(Abstract
> ValueTransformationExpressionEvaluator.java:457)
> 	at
> com.evolveum.midpoint.model.common.expression.evaluator.AbstractValue
> TransformationExpressionEvaluator.evaluate(AbstractValueTransformatio
> nExpressionEvaluator.java:118)
> 	at
> com.evolveum.midpoint.repo.common.expression.Expression.evaluateExpre
> ssionEvaluators(Expression.java:213)
> 	at
> com.evolveum.midpoint.repo.common.expression.Expression.evaluate(Expr
> ession.java:149)
> 	at
> com.evolveum.midpoint.model.common.mapping.Mapping.evaluateExpression
> (Mapping.java:1055)
> 	at
> com.evolveum.midpoint.model.common.mapping.Mapping.evaluateBody(Mappi
> ng.java:446)
> 	at
> com.evolveum.midpoint.model.common.mapping.Mapping.evaluate(Mapping.j
> ava:372)
> 	at
> com.evolveum.midpoint.model.impl.lens.projector.MappingEvaluator.eval
> uateMapping(MappingEvaluator.java:140)
> 	at
> com.evolveum.midpoint.model.impl.lens.projector.focus.InboundProcesso
> r.evaluateInboundMapping(InboundProcessor.java:836)
> 	at
> com.evolveum.midpoint.model.impl.lens.projector.focus.InboundProcesso
> r.processInboundMappingsForProjection(InboundProcessor.java:293)
> 	at
> com.evolveum.midpoint.model.impl.lens.projector.focus.InboundProcesso
> r.processInboundFocal(InboundProcessor.java:223)
> 	at
> com.evolveum.midpoint.model.impl.lens.projector.focus.InboundProcesso
> r.processInbound(InboundProcessor.java:165)
> 	at
> com.evolveum.midpoint.model.impl.lens.projector.focus.FocusProcessor.
> lambda$processFocusFocus$0(FocusProcessor.java:210)
> 	at
> com.evolveum.midpoint.model.impl.lens.LensUtil.partialExecute(LensUti
> l.java:947)
> 	at
> com.evolveum.midpoint.model.impl.lens.LensUtil.partialExecute(LensUti
> l.java:934)
> 	at
> com.evolveum.midpoint.model.impl.lens.projector.focus.FocusProcessor.
> processFocusFocus(FocusProcessor.java:207)
> 	at
> com.evolveum.midpoint.model.impl.lens.projector.focus.FocusProcessor.
> processFocus(FocusProcessor.java:140)
> 	at
> com.evolveum.midpoint.model.impl.lens.projector.Projector.lambda$proj
> ectInternal$1(Projector.java:229)
> 	at
> com.evolveum.midpoint.model.impl.lens.LensUtil.partialExecute(LensUti
> l.java:947)
> 	at
> com.evolveum.midpoint.model.impl.lens.projector.Projector.projectInte
> rnal(Projector.java:227)
> 	at
> com.evolveum.midpoint.model.impl.lens.projector.Projector.project(Pro
> jector.java:116)
> 	at
> com.evolveum.midpoint.model.impl.lens.Clockwork.click(Clockwork.java:
> 445)
> 	at
> com.evolveum.midpoint.model.impl.lens.Clockwork.run(Clockwork.java:20
> 2)
> 	at
> com.evolveum.midpoint.model.impl.controller.ModelController.executeCh
> anges(ModelController.java:538)
> 	at
> com.evolveum.midpoint.web.component.progress.ProgressPanel$14.callWit
> hContextPrepared(ProgressPanel.java:605)
> 	at
> com.evolveum.midpoint.web.component.progress.ProgressPanel$14.callWit
> hContextPrepared(ProgressPanel.java:591)
> 	at
> com.evolveum.midpoint.web.component.SecurityContextAwareCallable.call
> (SecurityContextAwareCallable.java:59)
> 	at java.util.concurrent.FutureTask.run(Unknown Source)
> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown
> Source)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
> Source)
> 	at java.lang.Thread.run(Unknown Source)
> Caused by:
> com.evolveum.midpoint.util.exception.ExpressionEvaluationException:
> java.text.ParseException: Unparseable date: "12/31/2000 11:00:00 AM"
> in expression in mapping in inbound expression for {http://midpoint.e
> volveum.com/xml/ns/public/resource/instance-3}StartDate in
> resource:900dd939-02da-48f2-a7b9-683de6b8d486(HR Feed)
> 	at
> com.evolveum.midpoint.model.common.expression.script.jsr223.Jsr223Scr
> iptEvaluator.evaluate(Jsr223ScriptEvaluator.java:120)
> 	at
> com.evolveum.midpoint.model.common.expression.script.ScriptExpression
> .evaluate(ScriptExpression.java:107)
> 	at
> com.evolveum.midpoint.model.common.expression.script.ScriptExpression
> Evaluator.transformSingleValue(ScriptExpressionEvaluator.java:63)
> 	at
> com.evolveum.midpoint.model.common.expression.evaluator.AbstractValue
> TransformationExpressionEvaluator.lambda$evaluateRelativeExpression$0
> (AbstractValueTransformationExpressionEvaluator.java:425)
> 	... 33 more
> Caused by: javax.script.ScriptException: java.text.ParseException:
> Unparseable date: "12/31/2000 11:00:00 AM"
> 	at
> org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEn
> gineImpl.java:347)
> 	at
> org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledSc
> ript.java:41)
> 	at javax.script.CompiledScript.eval(Unknown Source)
> 	at
> com.evolveum.midpoint.model.common.expression.script.jsr223.Jsr223Scr
> iptEvaluator.evaluate(Jsr223ScriptEvaluator.java:116)
> 	... 36 more
> Caused by: java.text.ParseException: Unparseable date: "12/31/2000
> 11:00:00 AM"
> 	at java.text.DateFormat.parse(Unknown Source)
> 	at java_text_DateFormat$parse.call(Unknown Source)
> 	at Script41.run(Script41.groovy:8)
> 	at
> org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEn
> gineImpl.java:344)
> 	... 39 more
> 
> Can someone help me with that?
> 
> Thanks Jan
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> http://lists.evolveum.com/mailman/listinfo/midpoint



More information about the midPoint mailing list