<html><body><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000"><div>Hello MiSo,<br></div><div><br></div><div>basic.getExtensionPropertyValue(requestee, NS_FOO, INTERNSHIP_NAME) should work in 3.0. I've just looked in the sources.<br></div><div><br></div><div>You could even leave out NS_FOO from this call (by replacing with an empty string), and it should still work.<br></div><div><br></div><div>Actually I'm quite surprised that the call results in null. Could you try to log the value of the requestee object? Use something like this:<br></div><div><br></div><div>log.info("Requestee = {}", requestee.asPrismObject().debugDump());<br></div><div><br></div><div>Best regards,<br></div><div>Pavol<br></div><div><br></div><div><br></div><hr id="zwchr"><div style="color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"Steklac Michal" <Michal_Steklac@datalan.sk><br><b>To: </b>"midPoint General Discussion" <midpoint@lists.evolveum.com><br><b>Sent: </b>Sunday, May 10, 2015 7:23:06 PM<br><b>Subject: </b>Re: [midPoint] get extended attribute in notification<br><div><br></div>
Hi,<br>
<br>
I modified the code<br>
...<br>
INTERNSHIP_NAME = 'internship';<br>
INTERNSHIP_QNAME = new QName(NS_FOO, INTERNSHIP_NAME);<br>
INTERNSHIP_PATH = new ItemPath(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType.F_EXTENSION, INTERNSHIP_QNAME);<br>
log.info("delta.findPropertyDelta(INTERNSHIP_PATH) != null " + (delta.findPropertyDelta(INTERNSHIP_PATH)!=null));<br>
if (delta.findPropertyDelta(INTERNSHIP_PATH)!=null) {<br>
log.info("internship="+basic.getExtensionPropertyValue(requestee, NS_FOO, INTERNSHIP_NAME));<br>
}<br>
...<br>
it works better. Only when I call basic.getExtensionPropertyValue(requestee, NS_FOO, INTERNSHIP_NAME) get null. It is possible get value for extension property in midpoint 3.0??<br>
<br>
Thanks,<br>
MiSo<br>
<br>
On Po, 2015-05-04 at 20:10 +0200, Pavol Mederly wrote:
<blockquote>Hello,<br>
<br>
3.0 is quite old, and many things work differently there. <br>
<br>
In particular, ItemPath(String... names) constructor is not available; you have to provide the QNames.<br>
<br>
So, something like this:<br>
<br>
INTERNSHIP_QNAME = new QName(NS_FOO, INTERNSHIP_PATH)<br>
INTERNSHIP_PATH = new ItemPath( com.evolveum.midpoint.xml.ns._public.common.common_3.UserType.F_EXTENSION, INTERNSHIP_QNAME)<br>
...<br>
<br>
should be needed.<br>
<br>
But I'm not sure if the other methods would work. (They probably will.)<br>
<br>
If possible, upgrade to 3.1.1. :-)<br>
<br>
Best regards,<br>
Pavol<br>
<br>
On 4. 5. 2015 19:56, Steklac Michal wrote:<br>
<br>
</blockquote>
<blockquote>
<blockquote>Hi,<br>
<br>
when call this code i got exception<br>
...<br>
INTERNSHIP_NAME = 'internship';<br>
log.info('INTERNSHIP_NAME='+INTERNSHIP_NAME);<br>
INTERNSHIP_PATH = new ItemPath('extension', INTERNSHIP_NAME);<br>
log.info('INTERNSHIP_PATH='+INTERNSHIP_PATH.toString());<br>
log.info("delta.findPropertyDelta(INTERNSHIP_PATH) != null " + (delta.findPropertyDelta(INTERNSHIP_PATH)!=null));<br>
if (delta.findPropertyDelta(INTERNSHIP_PATH)!=null) {<br>
log.info("internship="+basic.getExtensionPropertyValue(requestee, NS_FOO, INTERNSHIP_NAME));<br>
}<br>
...<br>
2015-05-04 19:46:41,976 [RESOURCEOBJECTCHANGELISTENER] [midPointScheduler_Worker-4] INFO (com.evolveum.midpoint.expression): INTERNSHIP_NAME=internship<br>
2015-05-04 19:46:41,980 [RESOURCEOBJECTCHANGELISTENER] [midPointScheduler_Worker-4] ERROR (com.evolveum.midpoint.model.common.expression.script.ScriptExpression): Expression error: groovy.lang.GroovyRuntimeE<br>
xception: Could not find matching constructor for: com.evolveum.midpoint.prism.path.ItemPath(java.lang.String, java.lang.String) (new) event filter expression<br>
com.evolveum.midpoint.util.exception.ExpressionEvaluationException: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: com.evolveum.midpoint.prism.path.ItemPath(java.lang.String, ja<br>
va.lang.String) (new) event filter expression<br>
at com.evolveum.midpoint.model.common.expression.script.jsr223.Jsr223ScriptEvaluator.evaluate(Jsr223ScriptEvaluator.java:124) ~[model-common-3.0.jar:na]<br>
at com.evolveum.midpoint.model.common.expression.script.ScriptExpression.evaluate(ScriptExpression.java:108) ~[model-common-3.0.jar:na]<br>
at com.evolveum.midpoint.model.common.expression.script.ScriptExpressionEvaluator.transformSingleValue(ScriptExpressionEvaluator.java:58) [model-common-3.0.jar:na]<br>
at com.evolveum.midpoint.model.common.expression.evaluator.AbstractValueTransformationExpressionEvaluator.evaluateScriptExpression(AbstractValueTransformationExpressionEvaluator.java:276) [model-comm<br>
on-3.0.jar:na]<br>
<br>
I try it in midpoint 3.0. <br>
<br>
Thanks,<br>
MiSo<br>
<br>
On Po, 2015-05-04 at 12:38 +0200, Pavol Mederly wrote: <br>
<blockquote>Miso,<br>
<br>
the problem is primarily in this line:<br>
<br>
QName USER_INTERNSHIP_QNAME = new QName(NS_FOO, "internship", "extension");<br>
<br>
because what is required, is not simply a QName, but a two-name item path (extension/internship). You have to use new ItemPath(...) constructor to create the path. Arguments are either QNames or (when there is no ambiguity) simple strings.<br>
<br>
This code works - note that I've put the code into <subjectExpression> just as an example. Tested with 'piracy' sample - changes names to match your situation.<br>
<br>
<notificationConfiguration><br>
<handler><br>
<simpleUserNotifier><br>
<subjectExpression><br>
<script><br>
<code><br>
import javax.xml.namespace.QName<br>
import com.evolveum.midpoint.prism.path.ItemPath<br>
import com.evolveum.midpoint.prism.delta.ObjectDelta<br>
import com.evolveum.midpoint.notifications.api.events.ModelEvent<br>
<br>
NS_FOO = '<a href="http://whatever.com/my" target="_blank">http://whatever.com/my</a>'<br>
INTERNSHIP_NAME = 'shipName'<br>
INTERNSHIP_PATH = new ItemPath('extension', INTERNSHIP_NAME)<br>
<br>
delta = ((ModelEvent) event).getSummarizedFocusDeltas()<br>
<br>
log.info("delta.findPropertyDelta(INTERNSHIP_PATH) != null " + (delta.findPropertyDelta(INTERNSHIP_PATH)!=null))<br>
if (delta.findPropertyDelta(INTERNSHIP_PATH)!=null) {<br>
log.info("internship="+basic.getExtensionPropertyValue(requestee, NS_FOO, INTERNSHIP_NAME))<br>
}<br>
<br>
'abcdef'<br>
</code><br>
</script><br>
</subjectExpression><br>
<transport>mail</transport><br>
</simpleUserNotifier><br>
</handler><br>
<mail><br>
<debug>false</debug><br>
<redirectToFile>d:\midpoint\home\mail-notifications.log</redirectToFile><br>
</mail><br>
</notificationConfiguration><br>
<br>
Best regards,<br>
Pavol<br>
<br>
On 3. 5. 2015 15:52, Steklac Michal wrote:<br>
<br>
<blockquote>Hi,<br>
<br>
I made an example in which obtains the value of the attribute family name and attribute internship. Attribute value family name received. When I trying to get the value for attribute internship, then I get null.<br>
<br>
----------------------------------------------------------------------<br>
* code to get family name<br>
...<br>
def NS_FOO = '<a href="http://midpoint.evolveum.com/xml/ns/test/foo-1.xsd%27;" target="_blank">http://midpoint.evolveum.com/xml/ns/test/foo-1.xsd';</a><br>
delta = ObjectDelta.summarize(((ModelEvent) event).getUserDeltas()); <br>
if(delta != null){<br>
log.info("delta = " + delta.toString());<br>
QName USER_FAMILYNAME_QNAME = new QName(NS_FOO,"familyName");<br>
if(delta.findPropertyDelta(USER_FAMILYNAME_QNAME)!=null){<br>
log.info("familyname="+requestee.getFamilyName()); <br>
}<br>
}<br>
...<br>
* output<br>
...<br>
2015-05-03 15:24:43,391 [RESOURCEOBJECTCHANGELISTENER] [midPointScheduler_Worker-5] INFO (com.evolveum.midpoint.expression): delta = ObjectDelta(UserType:cbd8aee0-802e-43ef-a1c7-30cb79c811f0,MODIFY: Property<br>
Delta( / fullName, REPLACE), PropertyDelta( / familyName, REPLACE), PropertyDelta(metadata / {.../common/common-3}modifyChannel, REPLACE), PropertyDelta(metadata / {.../common/common-3}modifyTimestamp, REPLA<br>
CE), ReferenceDelta(metadata / {.../common/common-3}modifierRef, REPLACE))<br>
2015-05-03 15:24:43,397 [RESOURCEOBJECTCHANGELISTENER] [midPointScheduler_Worker-5] INFO (com.evolveum.midpoint.expression): familyname=Malá<br>
...<br>
----------------------------------------------------------------------<br>
<br>
----------------------------------------------------------------------<br>
* code to get intership, which is extension attribute<br>
...<br>
def NS_FOO = '<a href="http://midpoint.evolveum.com/xml/ns/test/foo-1.xsd%27;" target="_blank">http://midpoint.evolveum.com/xml/ns/test/foo-1.xsd';</a><br>
delta = ObjectDelta.summarize(((ModelEvent) event).getUserDeltas()); <br>
if(delta != null){<br>
log.info("delta = " + delta.toString());<br>
QName USER_INTERNSHIP_QNAME = new QName(NS_FOO, "internship", "extension");<br>
log.info("delta.findPropertyDelta(USER_INTERNSHIP_QNAME)!=null " + (delta.findPropertyDelta(USER_INTERNSHIP_QNAME)!=null).toString());<br>
if(delta.findPropertyDelta(USER_INTERNSHIP_QNAME)!=null){<br>
log.info("internship="+basic.getExtensionPropertyValue(requestee, '<a href="http://evolveum.com/my%27," target="_blank">http://evolveum.com/my',</a> 'internship'));
<br>
}<br>
}<br>
... <br>
* output<br>
...<br>
2015-05-03 15:32:57,490 [RESOURCEOBJECTCHANGELISTENER] [midPointScheduler_Worker-4] INFO (com.evolveum.midpoint.expression): delta = ObjectDelta(UserType:cbd8aee0-802e-43ef-a1c7-30cb79c811f0,MODIFY: Property<br>
Delta(extension / internship, REPLACE), PropertyDelta(metadata / {.../common/common-3}modifyChannel, REPLACE), PropertyDelta(metadata / {.../common/common-3}modifyTimestamp, REPLACE), ReferenceDelta(metadata<br>
/ {.../common/common-3}modifierRef, REPLACE))<br>
2015-05-03 15:32:57,491 [RESOURCEOBJECTCHANGELISTENER] [midPointScheduler_Worker-4] INFO (com.evolveum.midpoint.expression): delta.findPropertyDelta(USER_INTERNSHIP_QNAME)!=null false<br>
...<br>
----------------------------------------------------------------------<br>
<br>
Please tell me what I'm doing wrong.<br>
<br>
Thanks,<br>
Miso<br>
<br>
On So, 2015-05-02 at 20:51 +0000, Steklac Michal wrote:<br>
<blockquote>Hi,<br>
<br>
i have extend schema with attribute internship. It is possible get their value in notification.<br>
<br>
This works for me for attribute givenName<br>
...<br>
QName USER_GIVENNAME_QNAME = new QName(NS_FOO,"givenName");<br>
if(delta.findPropertyDelta(USER_GIVENNAME_QNAME)!=null){<br>
attr = attr+'\nmeno='+requestee.getGivenName(); <br>
}<br>
...<br>
<br>
Thanks<br>
MiSo<br>
</blockquote>
<br>
<br>
<br>
<pre>_______________________________________________
midPoint mailing list
<a href="mailto:midPoint@lists.evolveum.com" target="_blank">midPoint@lists.evolveum.com</a>
<a href="http://lists.evolveum.com/mailman/listinfo/midpoint" target="_blank">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
</pre>
</blockquote>
<br>
</blockquote>
<br>
<br>
<br>
<pre>_______________________________________________
midPoint mailing list
<a href="mailto:midPoint@lists.evolveum.com" target="_blank">midPoint@lists.evolveum.com</a>
<a href="http://lists.evolveum.com/mailman/listinfo/midpoint" target="_blank">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
</pre>
</blockquote>
<br>
</blockquote>
<br>
<br>_______________________________________________<br>midPoint mailing list<br>midPoint@lists.evolveum.com<br>http://lists.evolveum.com/mailman/listinfo/midpoint<br></div><div><br></div></div></body></html>