= Audit Trail

:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


The xref:security:audittrail:about.adoc[] module provides an implementation of the xref:refguide:applib:index/services/publishing/spi/EntityPropertyChangeSubscriber.adoc[EntityPropertyChangeSubscriber], as well as a number of related domain services,
It creates an audit record for each changed property of each domain entity.

WARNING: TODO: v2 - to write up...

// following material out of date:
//
//The module also provides:
//
//* `AuditingServiceMenu` service which provides actions to search for ``AuditEntry``s, underneath an 'Activity' menu on the secondary menu bar.
//
//* `AuditingServiceRepository` service to to search for persisted `AuditEntry``s.
//None of its actions are visible in the user interface (they are all `@Programmatic`).
//
//* `AuditingServiceContributions` which contributes collections to the xref:refguide:applib-classes:mixees-and-mixins.adoc[HasInteractionId] interface.
//This will therefore display all audit entries that occurred in a given request/transaction, in other words whenever a command, a published event or another audit entry is displayed.
//
//These services can be activated by updating the `pom.xml` and updating the `AppManifest#getModules()` method.
//
//If menu items or contributions are not required in the UI, these can be suppressed either using security or by implementing a xref:userguide:btb:hints-and-tips/vetoing-visibility.adoc[vetoing subscriber].
//
//== Usage
//
//The typical way to indicate that an object should be audited is to annotate it with the xref:refguide:applib:index/annotation/DomainObject.adoc#auditing[@DomainObject#auditing()] annotation.
//
//
//== Related Services
//
//The auditing service works very well with implementations of xref:refguide:applib:index/services/publishing/spi/ExecutionSubscriber.adoc[ExecutionSubscriber] that persist the ``Execution`` objects obtained from the xref:refguide:applib:index/services/iactnlayer/InteractionContext.adoc[InteractionContext] service.
//The interaction execution captures the _cause_ of an interaction (an action was invoked, a property was edited), while the `EntityPropertyChangeSubscriber` audit entries capture the _effect_ of that interaction in terms of changed state.
//
//The xref:refguide:applib:index/services/publishing/spi/CommandSubscriber.adoc[CommandSubscriber] SPI can also be combined with the audit trail service, where the xref:refguide:applib:index/services/command/Command.adoc[Command] capturesthe _intent_ of an action, not the actual action invocation itself.
//
//
