Configure custom notification email

Hi,

I am trying to configure Nuxeo to use a custom template when sending “Modification alert” email notification. Here is what i done so far..

From a working installation (meaning that i subscribed on Modification alert and if i modify a folder i correctly get a modification notification email)

STEP 1: Removing the default modification notification

In the nuxeo-platform-notification-core-5.4.2

i modified notification-contribution.xml to disable the Modification notification by setting enabled=“false”

The result was that the Modification option disapeared from the Alert interface as expected, and i stoped receiving notification email on modification of the folder. So far so good…

STEP 2: Adding a custom modification notification

1-i added in my own custom .jar (which i use to expose custom services) a copy of

OSGI-INF/notification-contribution.xml (with Modification  enable="true")

2-i added a custom src/templates/modif.ftl

3-i added in the MANIFEST.FM a Nuxeo-Component: OSGI-INF/notification-contrib.xml

4-Restart…..

The result is that i now have the Modification option back in the interface, and if i modify the folder i get a notification email, except that i am not getting the custom modif.ftl template but still the default one.

Can someone indicates to me what is missing so i can get a custom email notification ?

Thanks Michel

0 votes

2 answers

6098 views

ANSWER



ARrrrrglll !!! Did you modify the file into the nuxeo-platform-notification-core-5.4.2 ? Bad, really bad :D

In fact Nuxeo is extensible and you can override easily with your own bundle (Nuxeo jar) the Nuxeo ones. This is the philosophy of the platform. We provide a Framework and some Modules (DM, DAM, Social-Collaboration, …) that can be a starting point for you. And you can override each part of the module.

So for your point you are near:

  1. DON'T TOUCH INTO THE NUXEO JAR ! I insist
  2. Do your step 2 but in your notification.xml file you must check that
  3. the name of the component at the beginning of your XML file is different of the nuxeo ones. For instance <component name="com.yourcomapny.yourprojectname.ecm.platform.notification.service.NotificationContrib">
  4. you must add this <require>org.nuxeo.ecm.platform.notification.service.NotificationContrib</require> (this is the name of the component that contains the contribution you want to override.
  5. you must disable the default contribution as https://jira.nuxeo.com/browse/NXP-8105

With the require you ask to the runtime to deploy your contribution AFTER the Nuxeo one. As you give the same name of the notification, the service will override with yours.

So your contribution must be something like:

<?xml version="1.0" encoding="UTF-8"?>
<component name="com.caristix.nuxeo.ecm.platform.notification.service.NotificationContrib">
  <require>org.nuxeo.ecm.platform.notification.service.NotificationContrib</require>
  <extension target="org.nuxeo.ecm.platform.ec.notification.service.NotificationService" point="notifications">
    <notification name="Modification" enabled="false"></notification>
    <notification name="Modification" channel="email" availablein="Workspace" autosubscribed="true"
      template="yourtemplate" subject="Document modified" 
      label="label.nuxeo.notifications.modif"> 
      <event name="documentModified"/>
    </notification>

Last point, you can use the new Nuxeo version, Nuxeo 5.5 that brings really cool features..

Hope this will be the solution :D

0 votes



Hi bjalon , tx for your quick answer

>>ARrrrrglll !!! Did you modify the file into the nuxeo-platform-notification-core-5.4.2 ? Bad, really bad :D

Ya i fell bad about it ;) . But i am in exploring mode on a test server and i started with the info from http://community.nuxeo.com/5.1/books/nuxeo-book/html/notification-service.html which says;

"Default defined notification may be disabled by setting enabled="false"."

But anyway i put back the original .jar, tben i renamed the component name and now i have a double copy of all the alerts in the interface , so the overriding part didn't work.

Is the <require> part to be placed in the Notification-Contrib.xml file like this?

&lt; ?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;

&lt;component
  name=&quot;com.caristix.nuxeo.ecm.platform.notification.service.NotificationContrib&quot;&gt;

&lt;require&gt;org.nuxeo.ecm.platform.notification.service.NotificationContrib&lt;/require&gt;

&lt;extension
  target=&quot;org.nuxeo.ecm.platform.ec.notification.service.NotificationService&quot;
  point=&quot;notifications&quot;&gt; etc,.....

tx Michel

ps: is it normal that i cannot add a comment on an answer pps: and i cannot add < at the beginning of a line

12/08/2011

I finally got it working

Since i only wanted to point to a custom mail template file , the only thing i had to contribute was the templates extensions.

And the problem i had with the last test is that i had a bad path; my templates folder being part of my src package i needed src="src/templates/caristixModif.ftl" and not src="templates/caristixModif.ftl"

&lt;?xml version=&quot;1.0&quot;?&gt;

&lt;component
  name=&quot;com.caristix.ecm.platform.notification.service.NotificationContrib&quot;&gt;

&lt;require&gt;org.nuxeo.ecm.platform.notification.service.NotificationContrib&lt;/require&gt;

  &lt;extension
    target=&quot;org.nuxeo.ecm.platform.ec.notification.service.NotificationService&quot;
    point=&quot;templates&quot;&gt;

   &lt;template name=&quot;modif&quot; src=&quot;src/templates/caristixModif.ftl&quot; /&gt;

  &lt;/extension&gt;

&lt;/component&gt;
12/12/2011


First:

If i put , it disable also the one i want to add.

Here is what i just tried; 1- I disable the <notification name=“Modification” 2- I created a new <notification name=“Modification2” with a different name but using the same event.

The only problem remaining is to use the custom .ftl file i put in my own src/templates folder in my .jar. I am still receiving the default modification email template.

So i guess i need something in the NotificationService extension so that points to the src/templates folder in my .jar and not in the default templates folder

Any hint on this ?

<extension

target="org.nuxeo.ecm.platform.ec.notification.service.NotificationService"
point="notifications">

<notification name="Subscriptions updated" channel="email" enabled="true" availableIn="Workspace"
  autoSubscribed="true" template="subscriptionsUpdated" subject="New subscription" label="label.nuxeo.notifications.subscriptions.updated">
  <event name="subscriptionAssigned"/>
</notification>

<notification name="Modification" channel="email" enabled="false" availableIn="Workspace"
  autoSubscribed="false" template="modif" subject="Document modified" label="label.nuxeo.notifications.modif">
  <event name="documentModified"/>
</notification>

<notification name="Modification2" channel="email" enabled="true" availableIn="Workspace"
  autoSubscribed="false" template="modif" subject="Document modified" label="label.nuxeo.notifications.modif">
  <event name="documentModified"/>
</notification>

<extension

target="org.nuxeo.ecm.platform.ec.notification.service.NotificationService"
point="templates">

<template name="subscriptionsUpdated" src="templates/subscriptionsUpdated.ftl" />
<template name="modif" src="templates/modif.ftl" />


<template name="defaultNotifTemplate" src="templates/defaultNotifTemplate.ftl" />

0 votes



If your are using maven, you need to put your templates in src/main/resources/templates

I made it work (not sure if necessary) with a contribution like:

    &lt;notification name=&quot;Modification&quot; enabled=&quot;false&quot;&gt;
        &lt;event name=&quot;documentModified&quot; /&gt;
    &lt;/notification&gt;
    &lt;notification name=&quot;Modification&quot; channel=&quot;email&quot; enabled=&quot;true&quot; availableIn=&quot;Workspace&quot; autoSubscribed=&quot;false&quot;
        template=&quot;modif&quot; subject=&quot; Document modified&quot; label=&quot;label.nuxeo.notifications.modif&quot;&gt;
        &lt;event name=&quot;documentModified&quot; /&gt;
    &lt;/notification&gt;

To make sure the previous Modification is unregistered. And the event are necessary with enabled="false" to make sure the event to notification relationship is removed.

03/06/2012