[midPoint] get extended attribute in notification
Steklac Michal
Michal_Steklac at datalan.sk
Mon May 4 19:56:47 CEST 2015
Hi,
when call this code i got exception
...
INTERNSHIP_NAME = 'internship';
log.info('INTERNSHIP_NAME='+INTERNSHIP_NAME);
INTERNSHIP_PATH = new ItemPath('extension', INTERNSHIP_NAME);
log.info('INTERNSHIP_PATH='+INTERNSHIP_PATH.toString());
log.info("delta.findPropertyDelta(INTERNSHIP_PATH) != null " + (delta.findPropertyDelta(INTERNSHIP_PATH)!=null));
if (delta.findPropertyDelta(INTERNSHIP_PATH)!=null) {
log.info("internship="+basic.getExtensionPropertyValue(requestee, NS_FOO, INTERNSHIP_NAME));
}
...
2015-05-04 19:46:41,976 [RESOURCEOBJECTCHANGELISTENER] [midPointScheduler_Worker-4] INFO (com.evolveum.midpoint.expression): INTERNSHIP_NAME=internship
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
xception: Could not find matching constructor for: com.evolveum.midpoint.prism.path.ItemPath(java.lang.String, java.lang.String) (new) event filter expression
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
va.lang.String) (new) event filter expression
at com.evolveum.midpoint.model.common.expression.script.jsr223.Jsr223ScriptEvaluator.evaluate(Jsr223ScriptEvaluator.java:124) ~[model-common-3.0.jar:na]
at com.evolveum.midpoint.model.common.expression.script.ScriptExpression.evaluate(ScriptExpression.java:108) ~[model-common-3.0.jar:na]
at com.evolveum.midpoint.model.common.expression.script.ScriptExpressionEvaluator.transformSingleValue(ScriptExpressionEvaluator.java:58) [model-common-3.0.jar:na]
at com.evolveum.midpoint.model.common.expression.evaluator.AbstractValueTransformationExpressionEvaluator.evaluateScriptExpression(AbstractValueTransformationExpressionEvaluator.java:276) [model-comm
on-3.0.jar:na]
I try it in midpoint 3.0.
Thanks,
MiSo
On Po, 2015-05-04 at 12:38 +0200, Pavol Mederly wrote:
Miso,
the problem is primarily in this line:
QName USER_INTERNSHIP_QNAME = new QName(NS_FOO, "internship", "extension");
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.
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.
<notificationConfiguration>
<handler>
<simpleUserNotifier>
<subjectExpression>
<script>
<code>
import javax.xml.namespace.QName
import com.evolveum.midpoint.prism.path.ItemPath
import com.evolveum.midpoint.prism.delta.ObjectDelta
import com.evolveum.midpoint.notifications.api.events.ModelEvent
NS_FOO = 'http://whatever.com/my'
INTERNSHIP_NAME = 'shipName'
INTERNSHIP_PATH = new ItemPath('extension', INTERNSHIP_NAME)
delta = ((ModelEvent) event).getSummarizedFocusDeltas()
log.info("delta.findPropertyDelta(INTERNSHIP_PATH) != null " + (delta.findPropertyDelta(INTERNSHIP_PATH)!=null))
if (delta.findPropertyDelta(INTERNSHIP_PATH)!=null) {
log.info("internship="+basic.getExtensionPropertyValue(requestee, NS_FOO, INTERNSHIP_NAME))
}
'abcdef'
</code>
</script>
</subjectExpression>
<transport>mail</transport>
</simpleUserNotifier>
</handler>
<mail>
<debug>false</debug>
<redirectToFile>d:\midpoint\home\mail-notifications.log</redirectToFile>
</mail>
</notificationConfiguration>
Best regards,
Pavol
On 3. 5. 2015 15:52, Steklac Michal wrote:
Hi,
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.
----------------------------------------------------------------------
* code to get family name
...
def NS_FOO = 'http://midpoint.evolveum.com/xml/ns/test/foo-1.xsd';<http://midpoint.evolveum.com/xml/ns/test/foo-1.xsd%27;>
delta = ObjectDelta.summarize(((ModelEvent) event).getUserDeltas());
if(delta != null){
log.info("delta = " + delta.toString());
QName USER_FAMILYNAME_QNAME = new QName(NS_FOO,"familyName");
if(delta.findPropertyDelta(USER_FAMILYNAME_QNAME)!=null){
log.info("familyname="+requestee.getFamilyName());
}
}
...
* output
...
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
Delta( / fullName, REPLACE), PropertyDelta( / familyName, REPLACE), PropertyDelta(metadata / {.../common/common-3}modifyChannel, REPLACE), PropertyDelta(metadata / {.../common/common-3}modifyTimestamp, REPLA
CE), ReferenceDelta(metadata / {.../common/common-3}modifierRef, REPLACE))
2015-05-03 15:24:43,397 [RESOURCEOBJECTCHANGELISTENER] [midPointScheduler_Worker-5] INFO (com.evolveum.midpoint.expression): familyname=Malá
...
----------------------------------------------------------------------
----------------------------------------------------------------------
* code to get intership, which is extension attribute
...
def NS_FOO = 'http://midpoint.evolveum.com/xml/ns/test/foo-1.xsd';<http://midpoint.evolveum.com/xml/ns/test/foo-1.xsd%27;>
delta = ObjectDelta.summarize(((ModelEvent) event).getUserDeltas());
if(delta != null){
log.info("delta = " + delta.toString());
QName USER_INTERNSHIP_QNAME = new QName(NS_FOO, "internship", "extension");
log.info("delta.findPropertyDelta(USER_INTERNSHIP_QNAME)!=null " + (delta.findPropertyDelta(USER_INTERNSHIP_QNAME)!=null).toString());
if(delta.findPropertyDelta(USER_INTERNSHIP_QNAME)!=null){
log.info("internship="+basic.getExtensionPropertyValue(requestee, 'http://evolveum.com/my',<http://evolveum.com/my%27,> 'internship'));
}
}
...
* output
...
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
Delta(extension / internship, REPLACE), PropertyDelta(metadata / {.../common/common-3}modifyChannel, REPLACE), PropertyDelta(metadata / {.../common/common-3}modifyTimestamp, REPLACE), ReferenceDelta(metadata
/ {.../common/common-3}modifierRef, REPLACE))
2015-05-03 15:32:57,491 [RESOURCEOBJECTCHANGELISTENER] [midPointScheduler_Worker-4] INFO (com.evolveum.midpoint.expression): delta.findPropertyDelta(USER_INTERNSHIP_QNAME)!=null false
...
----------------------------------------------------------------------
Please tell me what I'm doing wrong.
Thanks,
Miso
On So, 2015-05-02 at 20:51 +0000, Steklac Michal wrote:
Hi,
i have extend schema with attribute internship. It is possible get their value in notification.
This works for me for attribute givenName
...
QName USER_GIVENNAME_QNAME = new QName(NS_FOO,"givenName");
if(delta.findPropertyDelta(USER_GIVENNAME_QNAME)!=null){
attr = attr+'\nmeno='+requestee.getGivenName();
}
...
Thanks
MiSo
_______________________________________________
midPoint mailing list
midPoint at lists.evolveum.com<mailto: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/20150504/cc0f4c38/attachment.htm>
More information about the midPoint
mailing list