Page History
How to access the audit functionality in a service
In order to access auditing functionality one can retrieve an instance of an IAuditEngine from the IServiceContext passed to the handle method of a service implementation.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
@AquimaService("EXAMPLE_SERVICE")
public class ExampleService implements IService {
@Override
public IServiceResult handle(IServiceContext serviceContext) throws ServiceException, Exception {
final IAuditEngine auditEngine = serviceContext.getAuditEngine();
return new ServiceResult("Success");
}
} |
How to access the audit functionality in a container
In order to access auditing functionality one can retrieve an instance of an IAuditEngine from the IContainerContext passed to the expand method of a container implementation.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
@AquimaExpander("EXAMPLE_CONTAINER") public class ExampleContainer implements IContainerExpander { @Override public Container expand(Container container, ContainerDefinition containerDefinition, IContainerContext containerContext) throws Exception { final IAuditEngine auditEngine = containerContext.getAuditEngine(); return container; } } |
Logging an audit message
You can simply call the audit method on the IAuditEngine with an implementation of IAuditMessage.
The message object must be wrapped inside a Supplier object. The easiest way to do this is by instantiating your IAuditMessage instance inside a lamba.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
@AquimaService("EXAMPLE_SERVICE") public class ExampleService implements IService { @Override public IServiceResult handle(IServiceContext contextserviceContext) throws ServiceException, Exception { final var auditEngine = serviceContext.getAuditEngine(); // This ExampleAuditMessage could for example set all required fields by itself from the profile. auditEngine.audit(() -> new ExampleAuditMessage(serviceContext.getProfile())); return new ServiceResult("Success"); } } |
Structure of an audit message
With the audit engine you can log audit messages.
...
Field name | Description |
---|---|
eventType | The type of the audit message. This field is meant to provide information about the context of the event. Was it for example a create, update, delete event? |
processName | When the audit message was created in context of a certain process this field can be used to store the name of said process. |
caseId | When the audit message was created in context of a certain case this field can be used to store the id of said case. |
taskName | When the audit message was created in context of a certain task this field can be used to store the name of said task. |
taskId | When the audit message was created in context of a certain task this field can be used to store the id of said task. |
sourceType | This field can be used to store information about the source of the audit message. Such as the type of the service that this audit message was logged in. |
sourceId | This field can be used to store information about the source of the audit message. Can be used to specifically identify a certain service where the audit message was created. |
context | An string on string key/value map. Can be used to store any context specific information. |
Dynamic case management auditing
When you your application uses dynamic case management you might want to know how to access certain information such as process, case and task information.
...