Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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
languagejava
firstline1
titleAccessing the IAuditEngine in a service
linenumberstrue
@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
languagejava
firstline1
titleAccessing the IAuditEngine in a container
linenumberstrue
@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.

...

Code Block
languagejava
firstline1
titleLogging an audit message
linenumberstrue
@AquimaService("EXAMPLE_SERVICE")
public class ExampleService implements IService {
  @Override
  public IServiceResult handle(IServiceContext serviceContext) 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 nameDescription
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.
caseIdWhen the audit message was created in context of a certain case this field can be used to store the id of said case.
taskNameWhen the audit message was created in context of a certain task this field can be used to store the name of said task.
taskIdWhen the audit message was created in context of a certain task this field can be used to store the id of said task.
sourceTypeThis 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.
sourceIdThis 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.
contextAn string on string key/value map. Can be used to store any context specific information.

Dynamic case management auditing

When your application uses dynamic case management you might want to know how to access certain information such as process, case and task information.

...