<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">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
      <meta http-equiv="content-type" content="text/html; charset=utf-8">
      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>
      <meta http-equiv="content-type" content="text/html; charset=utf-8">
      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>
      <meta http-equiv="content-type" content="text/html; charset=utf-8">
      <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">MID-2772</a> to
      make creating a custom notifier easier.<br>
      <br>
      Hope this helps,<br>
      Pavol<br>
      <br>
      On 12. 1. 2016 21:15, Jason Everling wrote:<br>
    </div>
    <blockquote
cite="mid:CAFkZXY6ALWF3Fp-vgt-VCS=u_e+7vu8iWLHfpJhcvA85YU+wSw@mail.gmail.com"
      type="cite">
      <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>
      <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 class="mimeAttachmentHeader"></fieldset>
      <br>
      <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>
    <br>
  </body>
</html>