public class AuditModelRevisionListener implements RevisionListener
{
@Override
public void newRevision(Object revisionEntity)
{ AuditRevistionData auditModel = (AuditRevistionData) revisionEntity;
auditModel.editor = Security.getConnectedSystemAccount().user;
auditModel.description = ????;
}
}
Note that the passed revisionEntity is NOT the entity on which the action is performed upon. Retrieving the user reference is easy using the Security class.
I would like to derive the description of the CRUD operation from the method that was called.
So my main question is: is there a way in Play to retrieve the method reference that is currently being called by the user?
This would be very useful as I can use the name to store a descriptive revision message. Also I could extend this in the future by adding a custom annotation to the method which allows for a more descriptive revision message.
Thanks in advance!
Richard
Request request = Http.Request.current.get();
Method invokedMethod = request.invokedMethod;
And voila, you've got the method. This also allows me to add custom annotations to the method for better audting.
Should you have any queries, don't hesitate to send me a note. I'll be happy to assist. Hope to make a nice blogpost of this soon.
I'll reply to this topic if i got it ready..
/Richard