JadeAuditAccess Class Method Example

The method in the following example uses the functionality of the JadeAuditAccess class framework to read a journal. (For further examples, see the Audit Access White Paper.)

dumpJournal();
vars
    file: File;
    lyne: String;
    jDir: String;
    jaa: JadeAuditAccess;
    journalNum: Integer;
    offset: Integer;
    time: Time;
    date: Date;
    type: Integer;
    objType: Integer;
    ts: TimeStamp;
    serial: Decimal[20, 0];
    tranId: Decimal[20, 0];
    strOid: String;
    classNum: Integer;
    editn: Integer;
    userSlot: Integer;
    userName: String;
    byUserSlot: Integer;
    byUserName: String;
begin
    jDir:= 'c:\jadexxdev\system\journals\current\';
    journalNum:= 535;
    create file transient;
    file.fileName:= jDir & 'dump_of_journal_' & journalNum.String & '.txt';
    file.allowReplace:= true;
    file.kind:= File.Kind_ANSI;
    file.mode:= File.Mode_Output;
    file.open;
    if file.isAvailable then
        create jaa transient;
        jaa.getJournal(jDir, journalNum, offset);
        while jaa.getNextRecord(type, objType, offset, ts, serial, tranId,
                                strOid, classNum, editn) do
            lyne:= ts.Time.String & ' ' & serial.String & ' (' &
                   journalNum.String & ', ' & offset.String & ') ';
            if type = jaa.Jaa_Type_BeginTransaction then
                lyne:= lyne & 'beginTransaction';
            elseif type = jaa.Jaa_Type_CommitTransaction then
                lyne:= lyne & 'commitTransaction';
            elseif type = jaa.Jaa_Type_AbortTransaction then
                lyne:= lyne & 'abortTransaction';
            elseif type = jaa.Jaa_Type_UserSignOn then
                lyne:= lyne & 'signOn';
                jaa.getUserData(userName, userSlot);
                lyne:= lyne & ' index=' & userSlot.String &
                              ', name=' & userName;
            elseif type = jaa.Jaa_Type_UserSignOff then
                lyne:= lyne & 'signOff';
                jaa.getUserData(userName, userSlot);
                lyne:= lyne & ' index=' & userSlot.String &
                              ', name=' & userName;
            elseif type = jaa.Jaa_Type_ChangeUser then
                lyne:= lyne & 'changeUser';
                jaa.getChangeUserData(userName, userSlot, byUserName,
                                      byUserSlot);
                lyne:= lyne & ' index=' & userSlot.String &
                              ', name=' & userName &
                              ', by index=' & byUserSlot.String &
                              ', name=' & byUserName;
            elseif type = jaa.Jaa_Type_DatabaseOpen then
                lyne:= lyne & 'dbOpen';
            elseif type = jaa.Jaa_Type_DatabaseClose then
                lyne:= lyne & 'dbClose';
            elseif type = jaa.Jaa_Type_NoAuditDiscontinuity then
                lyne:= lyne & 'disc-noAudit';
            elseif type = jaa.Jaa_Type_ReorgDiscontinuity then
                lyne:= lyne & 'disc-reorg';
            elseif type = jaa.Jaa_Type_AuditSwitch then
                lyne:= lyne & 'disc-switch';
            elseif type = jaa.Jaa_Type_Create then
                lyne:= lyne & 'create';
                if objType = jaa.Jaa_Object_Object then
                    lyne:= lyne & 'object';
                elseif objType = jaa.Jaa_Object_Blob then
                    lyne:= lyne & 'blob';
                elseif objType = jaa.Jaa_Object_Collection then
                    lyne:= lyne & 'collection';
                endif;
            elseif type = jaa.Jaa_Type_Delete then
                lyne:= lyne & 'delete';
                if objType = jaa.Jaa_Object_Object then
                    lyne:= lyne & ' object';
                elseif objType = jaa.Jaa_Object_Blob then
                    lyne:= lyne & ' blob';
                elseif objType = jaa.Jaa_Object_Collection then
                    lyne:= lyne & ' collection';
                endif;
            elseif type = jaa.Jaa_Type_Update then
                lyne:= lyne & 'update';
                if objType = jaa.Jaa_Object_Object then
                    lyne:= lyne & ' object';
                elseif objType = jaa.Jaa_Object_Blob then
                    lyne:= lyne & ' blob';
                elseif objType = jaa.Jaa_Object_Collection then
                    lyne:= lyne & ' collection';
                endif;
            endif;
            file.writeLine(lyne);
        endwhile;
    endif;
epilog
    delete file;
    delete jaa;
end;