Audit Trail

The Audit Trail module provides an implementation of the EntityPropertyChangeSubscriber, which provides a fine-grained persistent audit trail: each and every change to a entity property is persisted as an individual AuditTrailEntry instance. This entity has a interaction id which makes it easy to identify all the changes made within a single interaction. If the Command Log extension is enabled, then it also means that the audit entries can be correlated back to the command (action invocation or property edit) that gave rise to them.

The AuditTrailMenu provides a set of actions that can be used to query the resultant audit trail. See menu bar layout below for the configuration of these.

Setup

Dependency Management

In your application’s top level pom.xml, add a dependency for this module’s own bill of materials (BOM):

pom.xml
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.apache.causeway.extensions</groupId>
            <artifactId>causeway-extensions-audittrail</artifactId>
             <scope>import</scope>
            <type>pom</type>
           <version>2.0.0</version>
        </dependency>
    </dependencies>
</dependencyManagement>

Dependencies / Imports

Your application may or may not need to interact with the audit trail directly. If it does, then add a dependency/import to the applib module wherever required:

  • add this dependency:

    pom.xml
    <dependencies>
        <dependency>
            <groupId>org.apache.causeway.extensions</groupId>
            <artifactId>causeway-extensions-audittrail-applib</artifactId>
        </dependency>
    </dependencies>
  • and @Import this module:

    MyModule.java
    @Configuration
    @Import({
        CausewayModuleExtAuditTrailApplib.class,
        // ...
    })
    public class MyModule { ... }

In your application’s App Manifest, import the implementation modules of this extension. The exact modules to use will depend upon the persistence mechanism in use:

  • add this dependency to your webapp’s pom.xml:

    pom.xml
    <dependencies>
        <dependency>
            <groupId>org.apache.causeway.extensions</groupId>
            <artifactId>causeway-extensions-audittrail-persistence-xxx</artifactId> (1)
        </dependency>
    </dependencies>
    1 either:
  • and @Import this module to your app manifest:

    MyAppManifest.java
    @Configuration
    @Import({
        CausewayModuleExtAuditTrailPersistenceXxx.class,    (1)
        // ...
    })
    public class MyAppManifest { ... }
    1 either

Once configured, the extension provides a number of menu actions. You can use menubars.layout.xml to arrange these as you see fit. To get you started, the following fragment adds all of the actions to an "Activity" secondary menu:

menubars.layout.xml
<mb:secondary>
    ...
    <mb:menu>
        <mb:named>Activity</mb:named>
        ...
        <mb:section>
            <mb:named>Audit Trail</mb:named>
            <mb:serviceAction id="findMostRecent" objectType="causeway.ext.auditTrail.AuditTrailMenu"/>
            <mb:serviceAction id="findAuditEntries" objectType="causeway.ext.auditTrail.AuditTrailMenu"/>
            <mb:serviceAction id="findAll" objectType="causeway.ext.auditTrail.AuditTrailMenu"/>
        </mb:section>
        ...
    </mb:menu>
</mb:secondary>