[midPoint] How to create delta for extension properties?

Pavol Mederly mederly at evolveum.com
Fri May 31 08:58:38 CEST 2019


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 developer
evolveum.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 
> <mailto: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 
> <mailto: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 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/d32bc653/attachment.htm>


More information about the midPoint mailing list