public void updateChangeLog ( final Principal user , final Verb verb , final String object ) { if ( ( Settings . ChangelogEnabled . getValue ( ) || Settings . UserChangelogEnabled . getValue ( ) ) ) { final JsonObject obj = new JsonObject ( ) ; obj . add ( "time" , toElement ( System . currentTimeMillis ( ) ) ) ; if ( user != null ) { obj . add ( "userId" , toElement ( user . getUuid ( ) ) ) ; obj . add ( "userName" , toElement ( user . getName ( ) ) ) ; } else { obj . add ( "userId" , JsonNull . INSTANCE ) ; obj . add ( "userName" , JsonNull . INSTANCE ) ; } obj . add ( "verb" , toElement ( verb ) ) ; obj . add ( "target" , toElement ( object ) ) ; if ( Settings . ChangelogEnabled . getValue ( ) ) { if ( changeLog . length ( ) > 0 && verb . equals ( Verb . create ) ) { // ensure that node creation appears first in the log changeLog . insert ( 0 , "\n" ) ; changeLog . insert ( 0 , obj . toString ( ) ) ; } else { changeLog . append ( obj . toString ( ) ) ; changeLog . append ( "\n" ) ; } } if ( Settings . UserChangelogEnabled . getValue ( ) && user != null ) { // remove user for user-centric logging to reduce redundancy obj . remove ( "userId" ) ; obj . remove ( "userName" ) ; appendUserChangelog ( user . getUuid ( ) , obj . toString ( ) ) ; } } }
Update changelog for Verb . create and Verb . delete