I have a requirement to provide audit trail information (who changed
what data, when and which records) whenever any data in my application
is added, updated or deleted. I have done this using code of the form:
public Callbacks<HistoricArtefacts> getCallbacks() {
return(new AbstractCallbacks<HistoricArtefacts>() {
public boolean afterUpdate(HistoricArtefacts bean, boolean
success) {
if (success) {
new
AuditTrailUpdater().recordUpdate("historicartefacts",
bean.getSite_survey_id(), "update");
}
return(true);
}
});
}
in each of the beans representing my different data types. I have
written a class (AuditTrailUpdater) which writes the data to the
appropriate audit trail table. I need to have user login name, table
name, record id, operation type (insert/update/delete) and date/time.
All of these are easy, apart from I am having trouble providing the
login name of the currently authenticated user (I am using database
authentication BTW). The way I am accustomed to doing this is from
within an Element context using:
identity =
(RoleUserIdentity)getRequestAttribute(Identified.IDENTITY_ATTRIBUTE_NAME);
However, none of this is available to me outside of the Element context
i.e. in my updating class. I can't make this latter class an Element as
I am instantiating it within a bean as above. How would I get hold of
the user name other than by the above? I can see that I could have the
class which does the bean save (a RIFE Element) could set an extra
"username" property in the bean, but this seems very clumsy. Is there a
better way?
Thanks for any insights,
David Herbert
British Antarctic Survey.
--
This message (and any attachments) is for the recipient only. NERC is subject
to the Freedom of Information Act 2000 and the contents of this email and any
reply you make may be disclosed by NERC unless it is exempt from release under
the Act. Any material supplied to NERC may be stored in an electronic
records management system.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"rife-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rife-users?hl=en
-~----------~----~----~----~------~----~------~--~---