<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hello,</p>
<p>I'd suggest staying with the delta builder, it's much simpler to
use.</p>
<p>The approach #1 should work, with this change:</p>
<p>def delta = DeltaBuilder.deltaFor(UserType.class, prismContext)<br>
.item("nickName").replace(new
PolyString(alias))<br>
.item(<b>"extension", "aliasEmail"</b>).delete(alias)<br>
.asObjectDelta(input.oid);<br>
</p>
<p>Best regards,<br>
</p>
<pre class="moz-signature" cols="72">Pavol Mederly
Software developer
evolveum.com
</pre>
<div class="moz-cite-prefix">On 31.05.2019 7:19, Jan Vaňáček - AMI
Praha a.s. wrote:<br>
</div>
<blockquote type="cite"
cite="mid:5b2f2d86120fd3ef36a478591ecacb73@mail.gmail.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.gmail-message
{mso-style-name:gmail-message;}
span.StylE-mailovZprvy19
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style>
<div class="WordSection1">
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Here
is an example of deleting extension property:</span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"> </span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">
branchValue = basic.getExtensionPropertyValue(input, '<a
href="http://mhmp.cz/xml/ns/midpoint/schema/extension-3"
moz-do-not-send="true">http://mhmp.cz/xml/ns/midpoint/schema/extension-3</a>'
, 'branch'); </span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"> modifyTypeDelta
=
ObjectDelta.createModificationDeleteProperty(UserType.class,
input.oid, new ItemPath(new
ItemPath(PrismConstants.EXTENSION_LOCAL_NAME),new QName('<a
href="http://mhmp.cz/xml/ns/midpoint/schema/extension-3"
moz-do-not-send="true">http://mhmp.cz/xml/ns/midpoint/schema/extension-3</a>',
'branch')), midpoint.getPrismContext(), branchValue);</span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">
midpoint.executeChanges(modifyTypeDelta);</span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"> </span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Just
use your correct extension namespace.</span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"> </span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">JAVA</span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"> </span></p>
<p class="MsoNormal"><b>From:</b> midPoint <<a
href="mailto:midpoint-bounces@lists.evolveum.com"
moz-do-not-send="true">midpoint-bounces@lists.evolveum.com</a>>
<b>On Behalf Of </b>Alcides Carlos de Moraes Neto<br>
<b>Sent:</b> Thursday, May 30, 2019 10:09 PM<br>
<b>To:</b> midpoint <<a
href="mailto:midpoint@lists.evolveum.com"
moz-do-not-send="true">midpoint@lists.evolveum.com</a>><br>
<b>Subject:</b> [midPoint] How to create delta for extension
properties?</p>
<p class="MsoNormal"> </p>
<div>
<div>
<p class="MsoNormal">Hello list,</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">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</p>
</div>
<div>
<p class="MsoNormal">1)</p>
</div>
<div>
<div>
<p class="MsoNormal">def delta =
DeltaBuilder.deltaFor(UserType.class, prismContext)<br>
.item("nickName").replace(new
PolyString(alias))</p>
</div>
<div>
<p class="MsoNormal">
.item("extension/aliasEmail").delete(alias)</p>
</div>
<div>
<p class="MsoNormal">
.asObjectDelta(input.oid);<br>
midpoint.modifyObject(delta);</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">2)</p>
</div>
</div>
<div>
<p class="MsoNormal">def delta =
DeltaBuilder.deltaFor(UserType.class, prismContext)<br>
.item("nickName").replace(new
PolyString(alias))<br>
.asObjectDelta(input.oid);<br>
delta.addModification(DeltaBuilder.deltaFor(ExtensionType.class,
prismContext).item("aliasEmail")</p>
</div>
<div>
<p class="MsoNormal">
.delete(alias).asItemDelta());<br>
midpoint.modifyObject(delta);</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">The exception:</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"><span class="gmail-message">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</span></p>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
midPoint mailing list
<a class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a>
<a class="moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
</pre>
</blockquote>
</body>
</html>