[midPoint] How to create delta for extension properties?

Alcides Carlos de Moraes Neto alcides.neto at gmail.com
Fri May 31 16:19:32 CEST 2019


Thank you all, it worked with Pavol's suggestion,

Em sex, 31 de mai de 2019 às 03:58, Pavol Mederly <mederly at evolveum.com>
escreveu:

> Hello,
>
> I'd suggest staying with the delta builder, it's much simpler to use.
>
> The approach #1 should work, with this change:
>
> def delta = DeltaBuilder.deltaFor(UserType.class, prismContext)
>                         .item("nickName").replace(new PolyString(alias))
>                         .item(*"extension", "aliasEmail"*).delete(alias)
>                         .asObjectDelta(input.oid);
>
> Best regards,
>
> Pavol Mederly
> Software developerevolveum.com
>
> On 31.05.2019 7:19, Jan Vaňáček - AMI Praha a.s. wrote:
>
> Here is an example of deleting extension property:
>
>
>
>                  branchValue = basic.getExtensionPropertyValue(input, '
> http://mhmp.cz/xml/ns/midpoint/schema/extension-3' , 'branch');
>
>                  modifyTypeDelta =
> ObjectDelta.createModificationDeleteProperty(UserType.class, input.oid, new
> ItemPath(new ItemPath(PrismConstants.EXTENSION_LOCAL_NAME),new QName('
> http://mhmp.cz/xml/ns/midpoint/schema/extension-3', 'branch')),
> midpoint.getPrismContext(), branchValue);
>
>                  midpoint.executeChanges(modifyTypeDelta);
>
>
>
> Just use your correct extension namespace.
>
>
>
> JAVA
>
>
>
> *From:* midPoint <midpoint-bounces at lists.evolveum.com> *On Behalf Of *Alcides
> Carlos de Moraes Neto
> *Sent:* Thursday, May 30, 2019 10:09 PM
> *To:* midpoint <midpoint at lists.evolveum.com>
> *Subject:* [midPoint] How to create delta for extension properties?
>
>
>
> Hello list,
>
>
>
> I need to check and clear some invalid values in our user extension
> properties. I have done a bulk action script for this, but I'm failing at
> creating the delta. I have tried two approaches, but they both fail with an
> IllegalArgumentException
>
> 1)
>
> def delta = DeltaBuilder.deltaFor(UserType.class, prismContext)
>                         .item("nickName").replace(new PolyString(alias))
>
>                         .item("extension/aliasEmail").delete(alias)
>
>                         .asObjectDelta(input.oid);
> midpoint.modifyObject(delta);
>
>
>
> 2)
>
> def delta = DeltaBuilder.deltaFor(UserType.class, prismContext)
>                         .item("nickName").replace(new PolyString(alias))
>                         .asObjectDelta(input.oid);
> delta.addModification(DeltaBuilder.deltaFor(ExtensionType.class,
> prismContext).item("aliasEmail")
>
>                          .delete(alias).asItemDelta());
> midpoint.modifyObject(delta);
>
>
>
> The exception:
>
>
>
> 2019-05-30T17:07:23.644 ERROR
> [com.evolveum.midpoint.model.common.expression.script.ScriptExpression]
> (http-nio-8080-exec-5) Expression error:
> java.lang.IllegalArgumentException: Undefined or dynamic path: aliasEmail
> in: CTD ({.../common/common-3}ExtensionType) in in 'execute-script' action
>
> _______________________________________________
> midPoint mailing listmidPoint at lists.evolveum.comhttp://lists.evolveum.com/mailman/listinfo/midpoint
>
> _______________________________________________
> 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/20190531/b704ad47/attachment.htm>


More information about the midPoint mailing list