This may be overkill for you...but I'm involved in a web project where we are using backing beans, lots of RESTful urls to get data from our beans. We have to audit absolutely everything (requirement), button presses, every single field change (originally it was just about every keystroke!!!), logins, logouts...as you can imagine, the volume of audit data is huge. We push it via a web service to a SQL data store, we send in real time, and use a batch process to catch any transfers that fail.
If we not had not had a stack of legacy code in Lotus Script, we would have gone this way: http://www.mindoo.de/web/blog.nsf/dx/22.07.2009175255KLELM7.htm?opendocument&comments
...but we already had an audit process in place. Ours is in Lotus Script, all back end, but the following method would work for java as well, if you are auditing the Notesdocument as opposed to a representation of the NotesDocument as a java object as above (which is what we do when getting our NotesDocument data...we then convert it to JSON).
Get the NotesDocument you need to change, create a temporary NotesDoc, copy all fields to the temp document...we store this in a list object and give it a ListTag of START, then start doing something to your document which changes field values, then, whenever you want to take another "snapshot" create another temp notesdocument and copy all the fields to this temp document, put in list with new ListTag, e.g. PROCESS_ONE. 99% of the time we just have START and FINISH. Then you loop across all fields on first START and see if the corresponding field exists on FINISH, compare fields, if any differences, you can move this to an "audit" document. Now cycle across all fields in the FINISH as you may have added new fields which didn't exist before. Add those to the audit document. Now you have an audit doc with all diffs. The reason we use temp docs is that we were getting into issues with DateTime and Number fields, if your audit doc has notes fields on it, then you can do whatever with DateTime --> ISO string conversions when you decide to display\ move to your audit datastore.
This functionality is built into a "base" class we have, our "working" class, say a WebOrder, "extends" our base class, so we just do:
Dim wc as webClass()
'// get your back end doc..
set wc = new WebClass(doc) '// the BaseClass.new() method automatically creates a "START" snapshot, even if a new doc, with no fields on it, in which case on submit, audits every new field.
'// do some stuff to your doc
call wc.createLineItems()
'// or...
doc.replaceItemValu("SomeField", 999)
'// ...we have amethod that allows us to take a snapshot of the doc, if you wanted...
wc.takeSnapshot()
'// but on submit(), it automatically takes a snapshot and creates an audit log
call wc.submit()
Hopefully this might give you some ideas,
Regards,
Nick