<div dir="ltr">Yes, you basically got it correct. I would like to stay away from making to many modifications to midpoint core as I would have to keep track of those during upgrades. Going the route of creating a custom notifier sounds better,<div><br></div><div>Thanks!</div><div>JASON</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr">JASON</div></div></div>
<br><div class="gmail_quote">On Fri, Jan 22, 2016 at 6:23 AM, Pavol Mederly <span dir="ltr"><<a href="mailto:mederly@evolveum.com" target="_blank">mederly@evolveum.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div>Hello Jason,<br>
<br>
I'm not sure I understand your situation well enough. What I
understood is:<br>
1) You have a custom code for generating notifications. <br>
2) You have to include it at many places (once for each specific
handler declaration).<br>
3) You are asking how to eliminate this code duplication.<br>
<br>
One possibility would be to create a custom notifier in Java, e.g.
by subclassing SimpleUserNotifier, and overriding getSubject(..)
and getBody(..) methods to include your specific code. The only
problem is how to tell midPoint to use your notifier.<br>
<br>
There is a mechanism that selects a notifier based on the type of
configuration element used to describe it. E.g. when you use
SimpleUserNotifierType, the SimpleUserNotifier is selected. See
AggregatedEventHandler (processEvent and processNotifiers
methods), and NotificationManagerImpl.getEventHandler method. This
mechanism is based on self-registration of handlers (see e.g.
SimpleUserNotifier.init method).<br>
<br>
So, in order to register your own handler, you would need to
create a custom configuration type for it. One possibility is to
extend static schema (typically, common-3.xsd), which is not very
clean, as it changes core midPoint sources. Another is to manually
create configuration type by subclassing GeneralNotifierType class
- because you don't need to add any methods/attributes, you just
need it as a marker for the selection mechanism.<br>
<br>
To conclude: you could create your own notifier (e.g. as a
MyCustomNotifier that is a subclass of SimpleUserNotifier and
overrides init/getSubject/getBody), along with its configuration
type (e.g. MyCustomNotifierType that is a subclass
SimpleUserNotifierType). Then you would use it like this:<br>
<br>
<tt><handler></tt><tt><br>
</tt><tt> <generalNotifier xsi:type="<b>MyCustomNotifierType</b>"></tt><tt><br>
</tt><tt> </tt><tt><transport>mail</transport></tt><tt><br>
</tt><tt> </generalNotifier></tt><tt><br>
</tt><tt></handler></tt><tt><br>
</tt><br>
Although I've not tried it, it should work.<br>
<br>
Also I've created <a href="https://jira.evolveum.com/browse/MID-2772" target="_blank">MID-2772</a> to
make creating a custom notifier easier.<br>
<br>
Hope this helps,<br>
Pavol<div><div class="h5"><br>
<br>
On 12. 1. 2016 21:15, Jason Everling wrote:<br>
</div></div></div>
<blockquote type="cite"><div><div class="h5">
<div dir="ltr">I want to add this to the notifications code
directly so I don't have to reference for each notification,
currently I have to add the statement "import com.evolveum.." to
each notification that would use it.
<div><br>
</div>
<div>Within the code, where/what would be a good place to add
it?</div>
<div><br>
</div>
<div>import
com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType;</div>
<div><br>
</div>
<div>I was thinking SimpleUserNotifier.java , would that work ?</div>
<div><br>
</div>
<div>An example of our use in the subject and body:</div>
<div><br>
</div>
<div><code></div>
<div>import
com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType;<br>
</div>
<div><br>
</div>
<div>if (requestee?.getActivation()?.getAdministrativeStatus()
== ActivationStatusType.DISABLED) {<br>
</div>
<div><br>
</div>
<div>body = "some stuff here";</div>
<div>}</div>
<div>else if
(requestee?.getActivation()?.getAdministrativeStatus() ==
ActivationStatusType.ENABLED) {</div>
<div><br>
</div>
<div>body = "someother stuff";</div>
<div>}</div>
<div>else {</div>
<div>body = "something got messed up";</div>
<div>}</div>
<div><br>
</div>
<div><br clear="all">
<div>
<div>
<div dir="ltr">JASON</div>
</div>
</div>
</div>
</div>
<br>
</div></div><font size="2"><br>
<br>
CONFIDENTIALITY NOTICE:<br>
This e-mail together with any attachments is proprietary and
confidential; intended for only the recipient(s) named above and
may contain information that is privileged. You should not
retain, copy or use this e-mail or any attachments for any
purpose, or disclose all or any part of the contents to any
person. Any views or opinions expressed in this e-mail are those
of the author and do not represent those of the Baptist School
of Health Professions. If you have received this e-mail in
error, or are not the named recipient(s), you are hereby
notified that any review, dissemination, distribution or copying
of this communication is prohibited by the sender and to do so
might constitute a violation of the Electronic Communications
Privacy Act, 18 U.S.C. section 2510-2521. Please immediately
notify the sender and delete this e-mail and any attachments
from your computer. </font><br>
<br>
<fieldset></fieldset>
<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>
</div>
<br>_______________________________________________<br>
midPoint mailing list<br>
<a href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a><br>
<a href="http://lists.evolveum.com/mailman/listinfo/midpoint" rel="noreferrer" target="_blank">http://lists.evolveum.com/mailman/listinfo/midpoint</a><br>
<br></blockquote></div><br></div>
<br>
<font size="2"><br><br>CONFIDENTIALITY NOTICE:<br>This e-mail together with any attachments is proprietary and confidential; intended for only the recipient(s) named above and may contain information that is privileged. You should not retain, copy or use this e-mail or any attachments for any purpose, or disclose all or any part of the contents to any person. Any views or opinions expressed in this e-mail are those of the author and do not represent those of the Baptist School of Health Professions. If you have received this e-mail in error, or are not the named recipient(s), you are hereby notified that any review, dissemination, distribution or copying of this communication is prohibited by the sender and to do so might constitute a violation of the Electronic Communications Privacy Act, 18 U.S.C. section 2510-2521. Please immediately notify the sender and delete this e-mail and any attachments from your computer. </font><br>