[midPoint] Where to add class for my future builds?

Jason Everling jeverling at bshp.edu
Fri Jan 22 15:44:54 CET 2016


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,

Thanks!
JASON

JASON

On Fri, Jan 22, 2016 at 6:23 AM, Pavol Mederly <mederly at evolveum.com> wrote:

> Hello Jason,
>
> I'm not sure I understand your situation well enough. What I understood is:
> 1) You have a custom code for generating notifications.
> 2) You have to include it at many places (once for each specific handler
> declaration).
> 3) You are asking how to eliminate this code duplication.
>
> 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.
>
> 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).
>
> 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.
>
> 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:
>
> <handler>
>   <generalNotifier xsi:type="*MyCustomNotifierType*">
>     <transport>mail</transport>
>   </generalNotifier>
> </handler>
>
> Although I've not tried it, it should work.
>
> Also I've created MID-2772 <https://jira.evolveum.com/browse/MID-2772> to
> make creating a custom notifier easier.
>
> Hope this helps,
> Pavol
>
>
> On 12. 1. 2016 21:15, Jason Everling wrote:
>
> 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.
>
> Within the code, where/what would be a good place to add it?
>
> import
> com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType;
>
> I was thinking SimpleUserNotifier.java , would that work ?
>
> An example of our use in the subject and body:
>
> <code>
> import
> com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType;
>
> if (requestee?.getActivation()?.getAdministrativeStatus() ==
> ActivationStatusType.DISABLED) {
>
> body = "some stuff here";
> }
> else if (requestee?.getActivation()?.getAdministrativeStatus() ==
> ActivationStatusType.ENABLED) {
>
> body = "someother stuff";
> }
> else {
> body = "something got messed up";
> }
>
>
> JASON
>
>
>
> CONFIDENTIALITY NOTICE:
> 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.
>
>
> _______________________________________________
> midPoint mailing listmidPoint at lists.evolveum.comhttp://lists.evolveum.com/mailman/listinfo/midpoint
>
>
>
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> http://lists.evolveum.com/mailman/listinfo/midpoint
>
>

-- 


CONFIDENTIALITY NOTICE:
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. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20160122/0e18196b/attachment.htm>


More information about the midPoint mailing list