The following example of a sample method accesses changed property values and changed collection block entry information.
dumpJournals(); vars auditAccess : JadeAuditAccess; offset : Integer; journalNumber : Integer; recordType : Integer; recordObjectType : Integer; recordTimeStamp : TimeStamp; recordSerialNumber : Decimal[12,0]; recordTxnId : Decimal[12,0]; recordOid : String; recordClassNumber : Integer; recordEdition : Integer; changedPropertyNames : JadeIdentifierArray; changedProperty : String; valueBefore : String; valueAfter : String; journalsPath : String; s : String; gotJournal : Boolean; gotJournalMsg : String; log : File; jda : JadeDatabaseAdmin; addedOids : StringArray; removedOids : StringArray; oidString : String; count : Integer; collType : String; memberKeyDict : Boolean; jdo : JadeDynamicObject; jdoArray : JadeDynamicObjectArray; keyBytes : Integer; beforeKeys : Binary; afterKeys : Binary; someKeys : Binary; collOwnerClass : Integer; editionString : String; begin journalNumber:= 22;
create jda transient; journalsPath:= jda.getCurrentJournalDirectory();
create log transient; log.usePresentationFileSystem:= false; log.fileName:= 'c:\temp\jaa_dump_everything.txt'; log.allowReplace := true; log.kind := File.Kind_Unicode; log.mode := File.Mode_Output; log.open;
if not log.isAvailable then write 'unable to open output log "' & log.fileName & '"'; return; endif;
s:= "journal file path is " & journalsPath; write s; log.writeLine(s); create changedPropertyNames transient; create addedOids transient; create removedOids transient; create jdoArray transient;
create auditAccess transient; auditAccess.setAccessMode(JadeAuditAccess.Jaa_AccessMode_Long);
offset := 0; write ''; gotJournalMsg:= 'got next journal'; gotJournal:= true; on Exception do getJournalExceptionHandler(exception, gotJournal, gotJournalMsg); auditAccess.getJournal(journalsPath, journalNumber, offset); if not gotJournal then gotJournalMsg:= 'no journal file ' & journalNumber.String; write gotJournalMsg; log.writeLine(gotJournalMsg); endif; while gotJournal do s:= 'Processing journal ' & auditAccess.getJournalNumber().String; write s; log.writeLine(s); while auditAccess.getNextRecord(recordType, recordObjectType, offset, recordTimeStamp, recordSerialNumber,recordTxnId, recordOid, recordClassNumber, recordEdition) do s:= recordSerialNumber.String & ' ' & recordTxnId.String & ' recordType=' & recordType.String & ' '; if recordType = JadeAuditAccess.Jaa_Type_Create then s:= s & 'Create '; elseif recordType = JadeAuditAccess.Jaa_Type_Delete then s:= s & 'Delete '; elseif recordType = JadeAuditAccess.Jaa_Type_Update then s:= s & 'Update '; elseif recordType = JadeAuditAccess.Jaa_Type_AbortTransaction then s:= s & 'Abort transaction '; elseif recordType = JadeAuditAccess.Jaa_Type_BeginTransaction then s:= s & 'Begin transaction '; elseif recordType = JadeAuditAccess.Jaa_Type_CommitTransaction then s:= s & 'Commit transaction '; elseif recordType = JadeAuditAccess.Jaa_Type_UserSignOn then s:= s & 'Sign on '; elseif recordType = JadeAuditAccess.Jaa_Type_UserSignOff then s:= s & 'Sign off '; elseif recordType = JadeAuditAccess.Jaa_Type_ChangeUser then s:= s & 'Change user '; endif;
if recordObjectType <> JadeAuditAccess.Jaa_Object_Null then s:= s & 'recordObjectType=' & recordObjectType.String & ' '; if recordObjectType = JadeAuditAccess.Jaa_Object_Object then s:= s & 'Object '; elseif recordObjectType = JadeAuditAccess.Jaa_Object_Collection then s:= s & 'Collection '; elseif recordObjectType = JadeAuditAccess.Jaa_Object_CollectionBlock then s:= s & 'CollectionBlock of Collection '; // the oid given to us // in this case is the header oid elseif recordObjectType = JadeAuditAccess.Jaa_Object_Blob then s:= s & 'Blob/Slob '; endif; endif;
if recordEdition > 0 then editionString := ':' & recordEdition.String; else editionString := ''; endif;
log.writeLine('(' & auditAccess.getJournalNumber().String & ',' & offset.String & ') ' & s & recordOid.String & editionString);
if recordType = auditAccess.JadeAuditAccess.Jaa_Type_Update then if recordObjectType = auditAccess.JadeAuditAccess.Jaa_Object_Object then log.writeLine('update of ' & auditAccess.currentOid); if auditAccess.getChangedPropertyNames(changedPropertyNames) then foreach changedProperty in changedPropertyNames do valueBefore:= auditAccess.getBeforePropertyValue (changedProperty).String; valueAfter:= auditAccess.getAfterPropertyValue (changedProperty).String; log.writeLine(Tab & changedProperty & '[' & valueBefore & '] [' & valueAfter & ']'); endforeach; endif; endif; endif;
if recordObjectType = auditAccess.JadeAuditAccess. Jaa_Object_CollectionBlock then memberKeyDict := false; collType := ""; if auditAccess.descriptionClassIsSubclass(recordClassNumber, ObjectArray.number) then collType := "ObjectArray"; elseif auditAccess.descriptionClassIsSubclass(recordClassNumber, Set.number) then collType := "Set"; elseif auditAccess.descriptionClassIsSubclass(recordClassNumber, MemberKeyDictionary.number) then collType := "MemberKeyDictionary"; memberKeyDict := true; endif; collOwnerClass := getClassNumberForObject(getOwnerForObject (auditAccess.currentOid.asOid())); collType := collType & ' (' & auditAccess.getClassName(collOwnerClass) & '.'; collType := collType & auditAccess(getClassName auditAccess.currentClassNumber) & ')'; if recordType = auditAccess.JadeAuditAccess.Jaa_Type_Create then log.writeLine('create ' & collType & ' block=' & auditAccess.getCollectionBlockOid()); elseif recordType = auditAccess.JadeAuditAccess.Jaa_Type_Update then log.writeLine('update ' & collType & ' block=' & auditAccess.getCollectionBlockOid()); else log.writeLine('delete ' & collType & ' block=' & auditAccess.getCollectionBlockOid()); endif; if memberKeyDict then auditAccess.getCollectionBlockKeys(jdoArray); foreach jdo in jdoArray do oidString := jdo.getPropertyValue('entryOid').String; keyBytes := jdo.getPropertyValue('keyBytes').Integer; beforeKeys := jdo.getPropertyValue('beforeKeys').Binary; afterKeys := jdo.getPropertyValue('afterKeys').Binary; if beforeKeys.length() > 0 and afterKeys.length() > 0 then if keyBytes > 32 then s := Tab & 'changed ' & oidString & ' keyBytes=' & keyBytes.String & CrLf & Tab & Tab & 'old key = <' & beforeKeys.String & '>' & CrLf & Tab & Tab & ' 0x<' & beforeKeys._hex() & '>' & CrLf & Tab & Tab & 'new key = <' & afterKeys.String & '>' & CrLf & Tab & Tab & ' 0x<' & afterKeys._hex() & '>'; else s := Tab & 'changed ' & oidString & ' keyBytes=' & keyBytes.String & CrLf & Tab & Tab & ' old key = <' & beforeKeys.String & '> 0x<' & beforeKeys._hex() & '>' & CrLf & Tab & Tab & ' new key= <' & afterKeys.String & '> 0x<' & afterKeys._hex() & '>'; endif; else if afterKeys.length() = 0 then s := Tab & 'removed '; someKeys := beforeKeys; else // beforeKeys.length() = 0 s := Tab & 'added '; someKeys := afterKeys; endif; if keyBytes > 32 then s := s & oidString & ' keyBytes=' & keyBytes.String & CrLf & Tab & Tab & 'key = <' & someKeys.String & '>' & CrLf & Tab & Tab & ' 0x<' & someKeys._hex() & '>'; else s := s & oidString & ' keyBytes=' & keyBytes.String & CrLf & Tab & Tab & ' key = <' & someKeys.String & '> 0x<' & someKeys._hex() & '>'; endif; endif; log.writeLine(s); endforeach; jdoArray.purge(); else auditAccess.getCollectionBlockOids(addedOids, removedOids); count := 0; s := Tab & ' added'; foreach oidString in addedOids do count := count + 1; s := s & ' ' & oidString; if count mod 5 = 0 then log.writeLine(s); s := Tab & ' '; endif; endforeach; if s.length() > 10 then // residual log.writeLine(s); endif; count := 0; s := Tab & 'removed'; foreach oidString in removedOids do count := count + 1; s := s & ' ' & oidString; if count mod 5 = 0 then log.writeLine(s); s := Tab & ' '; endif; endforeach; if s.length() > 10 then // residual log.writeLine(s); endif; endif; endif;
endwhile; // getNextRecord
auditAccess.getNextJournal(); write ' '; write gotJournalMsg; log.writeLine(' '); log.writeLine(gotJournalMsg); endwhile; // gotJournal
log.close;
epilog delete log; delete auditAccess; delete changedPropertyNames; delete jda; delete addedOids; delete removedOids; delete jdoArray; end;