Notification for deleted document

Hi, I'm a new user of Nuxeo. I'm wondering if it is possible to have notifications when a document is deleted. I write my extension point:

<component name="org.nuxeo.sample.notify">
    <extension point="notifications" target="org.nuxeo.ecm.platform.ec.notification.service.NotificationService">
        <notification autoSubscribed="false" availableIn="all" label="Delete" channel="email" enabled="true" name="Document Removed">
        <event name="documentRemoved" />
        </notification>
    </extension>
</component>

I can subscribe an user to receive the Delete notifications, but they don't work: when I delete a document, user does not receive the notification.

What's wrong?

Thank you very much, and sorry for my bad English!

Alice

0 votes

10 answers

3800 views

ANSWER

Is it normal that you have spaces in your target?

target=&quot; org.nuxeo.ecm.platform.ec.notification.service.NotificationS ervice &quot;
02/23/2012

I think that is a problem of formattation in the previous message…in orginal code there were not those spaces!
02/23/2012



There is no simply way to do that.

A solution would be to implement your own event 'documentDeleted' and to create a listener or by overriding the concerned bean to fired this event. See http://doc.nuxeo.com/display/NXDOC/Events+and+Listeners.

0 votes



Testing the notification service for deleted files, I noticed that when a document has got more than one version, nuxeo send me a mail for each version when I delete the entire document… is there a way to filter to notifications?

0 votes



You can use the method isVersion() of a DocumentModel in your listener to filter. http://community.nuxeo.com/api/nuxeo/5.5/javadoc/org/nuxeo/ecm/core/api/DocumentModel.html#isVersion%28%29
03/27/2012

Please ask new questions as a separate Question in this site. Or add comments. But don't ask questions in the Answers of an existing question.
03/29/2012


Well, thanks in any case, but I found a cleaner solution…I write it here, so, if someone will be interested… It is possible to disable the trash service, adding the following extension:

<extension point="config" target="org.nuxeo.ecm.webapp.trashManagement.TrashManagementService">
    <trashConfig enabled="false"/>
</extension>
0 votes



Sorry, another question: if I move the “Permanently delete” button from the trash to the workspace with this piece of code:

<action confirm="if( !confirmDeleteDocumentsForever() ) return false;" help="comand.deleteDocs.help" icon="" id="CURRENT_SELECTION_DELETE" label="command.deleteDocs" link="#deleteActions.purgeSelection}">
  <category>CURRENT_SELECTION_LIST</category>
  <filter id="canPurge">
    <rule grant="true">
      <condition>#{deleteActions.canPurge}</condition>
    </rule>
  </filter>
</action>

I have the button, but it does not delete the document. Is there a way to fix it?

0 votes



Thanks, I will try to create a listener. Instead, is there an event associated to the moving of a document in the trash? I tried with “aboutToRemove”, but it does not seem to work…and “lifecycle_transition_event” catch other events too (for example: restoring).

0 votes



There is no event when a document is moved to the trash, but you should catch the event 'lifecycle_transition_event' and test if the currentLifeCycleState of the document is 'delete', then you can fired your own event 'documentDeleted'.
02/27/2012

Can I filter the notifications? Something like:

<notification name="Cancellazione" channel="email" availableIn="all" autoSubscribed="false" label="Cancellazione" template="remove" enabled="true"> <event name="lifecycle_transition_event"/> <filter id="del"> <rule grant="false">

  &lt;condition&gt;
     #{document.getCurrentLifeCycleState().equals(&quot;deleted&quot;)}
  &lt;/condition&gt;

</rule> </filter> </notification>

02/28/2012


Ok, thanks, now all has got sense! Could I bind the “documentRemoved” event to the “Delete” button?

0 votes



This is my new piece of code: this works with every event, except for documentRemoved and documentMoved…can anyone tell me why?

<extension target="org.nuxeo.ecm.platform.ec.notification.service.NotificationService" point="templates">
        <template name="remove" src="templates/documentRemoved.ftl" />
    </extension>
    <extension target="org.nuxeo.ecm.platform.ec.notification.service.NotificationService" point="notifications">

        <notification name="Cancellazione" channel="email" availableIn="all" autoSubscribed="false"
          label="Cancellazione" template="remove">
          <event name="documentRemoved"/>
        </notification>
0 votes



The event 'documentRemoved' is throwed when a document is permanently removed form the trash. What is your test case ?
02/27/2012

Where is the trash? I would like to send a notification when I selected a document from a folder and press the button "Delete"…in this way, isn't a document removed?
02/27/2012

The trash is a sub-tab of the administration tab. When you press the button 'Delete' the 'documentRemoved' event is not fired, this is why the notification is not sended.
02/27/2012


The curious thing is that the code works with every other defined event (for example: documentModified or documentLocked or versionRemoved)… it doesn't work only with documentRemoved and I really don't understand why… (I try to add my own template…it works with other event too)

0 votes



Can you (by convention) use a name without space (this is the technical name, so my advice would be to use the Camel Case.

Have you defined your component into the Manifest ?

How did you generate your bundle. My piece of advice would be to use the Nuxeo IDE.

Or more easily you can use studio and copy you contribution (from <extension... to </extension>) into Advanced setting > XML Extension.

Regards.

0 votes



You need to precise a template for your notification :

<notification template="documentRemoved" autoSubscribed="false" availableIn="all" label="Delete" channel="email" enabled="true" name="Document Removed">
    <event name="documentRemoved" />
</notification>

Moreover the template must be defined in an other contribution point :

  <extension target="org.nuxeo.ecm.platform.ec.notification.service.NotificationService"
    point="templates">
    <template name="documentRemoved" src="templates/documentRemoved.ftl" />
  </extension>

You can see the template 'modif.ftl' to create your own template 'documentRemoved.ftl'.

I think it should work better!

0 votes