Versions Compared

Key

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

https://github.com/UnionVMS/UVMS-AuditModule-APP

...

Code Block
languagexml
themeConfluence
titleMaven
<!-- Integration dependency -->
<dependency>
  <groupId>eu.europa.ec.fisheries.uvms.audit</groupId>
  <artifactId>audit-model</artifactId>
  <version>LATEST</version>
</dependency>


Github App: https://github.com/UnionVMS/UVMS-AuditModule-APP
QA Summary App: https://sonarcloud.io/dashboard?id=eu.europa.ec.fisheries.uvms.audit%3Aaudit
CI location App: https://jenkins.focus.fish/view/UVMS%20App/job/UVMS-Audit-APP/
Project Site reports App: https://jenkins.focus.fish/view/Site-Reports/job/UVMS-Audit-APP-Site-reports/site/

Module dependencies


Name

Description

Documentation

User

Authentication operations and access management

User

...

If you are Using Wildfly as your applicationserver the settings should look like below.

JMS Queues

<admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:/jms/queue/UVMSAuditModel" use-java-context="true" pool-name="UVMSAuditModel">
    <config-property name="PhysicalName">
        UVMSAuditModel
    </config-property>
</admin-object>
<admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:/jms/queue/UVMSAudit" use-java-context="true" pool-name="UVMSAudit">
    <config-property name="PhysicalName">
        UVMSAudit
    </config-property>
</admin-object>

Datasource

<datasource jta="true" jndi-name="java:jboss/datasources/uvms_audit"  pool-name="uvms_audit" enabled="true" use-ccm="true">
    <connection-url>jdbc:postgresql://127.0.0.1:5432/db71u</connection-url>
    <driver-class>org.postgresql.Driver</driver-class>
    <driver>postgresql</driver>
    <security>
        <user-name>audit</user-name>
        <password>audit</password>
    </security>
</datasource>

Maven Dependency

Source code for the model is available in https://github.com/UnionVMS/UVMS-AuditModule-MODEL

<dependency>
    <groupId>eu.europa.ec.fisheries.uvms.audit</groupId>
    <artifactId>audit-model</artifactId>
    <version>2.1.2version>
    <type>jar</type>
</dependency>

How it works

Now that the prerequisites are met we can start with the actual integration. But first it is important to understand what happens when we are integrating the module. The following code shows an example on how to integrate with the Audit module.

try {
    String auditData = AuditLogMapper.mapToAuditLog(“Asset”, “Create”, “{abc}”);
    messageProducer.sendModuleMessage(auditData, ModuleQueue.AUDIT);
} catch (AuditModelMarshallException e) {
    LOG.error("Failed to send audit log message!);
}

The above example is a code snippet that shows how simple it is to integrate with the Audit module. Essentially what it does is to create a String that is an xml that will be sent over the JMS queue via a JMS message producer. If you are not using the standard Message producer provided by the Module archetype it is important that you use the object javax.jms.TextMessage when sending your message or the message cannot be parsed by the Audit module.

...

In the asset module the mapping to the Audit module is made by an internal “Asset mapper” so that each individual methods for the objects is more easily accessed. See code below.

public class AuditModuleRequestMapper {

    final static Logger LOG = LoggerFactory.getLogger(AuditModuleRequestMapper.class);

    public static String mapAuditLogVesselCreated(String guid) throws AuditModelMarshallException {
        return mapToAuditLog(AuditObjectTypeEnum.ASSET.getValue(), AuditOperationEnum.CREATE.getValue(), guid);
    }

    public static String mapAuditLogVesselUpdated(String guid) throws AuditModelMarshallException {
        return mapToAuditLog(AuditObjectTypeEnum.ASSET.getValue(), AuditOperationEnum.UPDATE.getValue(), guid);
    }

    public static String mapAuditLogVesselGroupCreated(String guid) throws AuditModelMarshallException {
        return mapToAuditLog(AuditObjectTypeEnum.ASSET_GROUP.getValue(), AuditOperationEnum.CREATE.getValue(), guid);
    }

    public static String mapAuditLogVesselGroupUpdated(String guid) throws AuditModelMarshallException {
        return mapToAuditLog(AuditObjectTypeEnum.ASSET_GROUP.getValue(), AuditOperationEnum.UPDATE.getValue(), guid);
    }

    public static String mapAuditLogVesselGroupDeleted(String guid) throws AuditModelMarshallException {
        return mapToAuditLog(AuditObjectTypeEnum.ASSET_GROUP.getValue(), AuditOperationEnum.ARCHIVE.getValue(), guid);
    }

    private static String mapToAuditLog(String objectType, String operation, String affectedObject) throws AuditModelMarshallException {
        return AuditLogMapper.mapToAuditLog(objectType, operation, affectedObject);
    }

}

Model:

Image Added

Domain:

Image Added

Service:

Image Added

Message:

Image Added

Rest:

Image Added