cancel
Showing results for 
Search instead for 
Did you mean: 

Notification for deleted document

Alice_
Star Contributor
Star Contributor

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

1 ACCEPTED ANSWER

Clément_Lardeur
Confirmed Champ
Confirmed Champ

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.

View answer in original post

19 REPLIES 19

Alice_
Star Contributor
Star Contributor

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

Clément_Lardeur
Confirmed Champ
Confirmed Champ

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.

Alice_
Star Contributor
Star Contributor

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).

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'.

Alice_
Star Contributor
Star Contributor

Can I filter the notifications? Something like

Alice_
Star Contributor
Star Contributor

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?

Alice_
Star Contributor
Star Contributor

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>

Alice_
Star Contributor
Star Contributor

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?

You can use the method isVersion() of a DocumentModel in your listener to filter.

Florent_Guillau
World-Class Innovator
World-Class Innovator

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.