Foros de discusión

Using Velocity to Write to Logs on Web Content Publish?

Ed O'Connell, modificado hace 10 años.

Using Velocity to Write to Logs on Web Content Publish?

New Member Mensajes: 8 Fecha de incorporación: 18/01/13 Mensajes recientes
I am working with Liferay 6.1 and I have a question regarding the capability of Velocity WCM templates to listen for the 'publish' event, both a general question and a specific one.

Both of these questions stem from a requirement my team was given to allow for end users to subscribe to be notified via email when particular web content was updated. We could not meet our requirements with any out of the box liferay functionality, so we built a service that did what we wanted and called that service through velocity in a WCM template.

At first, it seemed as if we were going to need to find some what to listen for the publish event and then use that listener to call the service, but as it turned out our requirements were better served by having a checkbox available that would allow content administrators to flag whether or not a particular publishing event should trigger an email. That made listening for an event easier, because all we had to do was check to see what value the checkbox had. [there were some complications having to do with how to update the content in the database and deal with the checking and unchecking the checkbox, but we worked those out]

Now the thing is, there is one business scenario we are trying to guard against, and it brings up the idea of listening for the publish event all over again.

Essentially, what we are trying to find out is whether or not there is a way to have velocity listen for the publish event, and on publish write a log (ideally write to the existing liferay logs) of which checkboxes were checked at the time of that event. This would allow us to audit the events in the case that an administrator claimed the send email checkbox was checked but the service did not send out notifications.

Can this be done?

The two things I am wondering are:

1) Can velocity listen for the publish event and use that event as a trigger for some action?

and

2) Can velocity write to the logs (I believe I have seen examples of this, but am not totally certain how it is done) and if so, how?