From 59fb587c2dae32a2e865c9198aa20ffcad7f3c7f Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Thu, 15 Feb 2018 10:53:18 +0200 Subject: [PATCH] Remove fixed "testlog" as client id and read from system property refs #7768 Change-Id: I673f29eccc06c8375811fe5da557d506737209c2 --- .../simantics/audit/client/AuditLoggingClient.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bundles/org.simantics.auditlogging/src/org/simantics/audit/client/AuditLoggingClient.java b/bundles/org.simantics.auditlogging/src/org/simantics/audit/client/AuditLoggingClient.java index e9043187d..769ebb086 100644 --- a/bundles/org.simantics.auditlogging/src/org/simantics/audit/client/AuditLoggingClient.java +++ b/bundles/org.simantics.auditlogging/src/org/simantics/audit/client/AuditLoggingClient.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.UUID; import org.simantics.audit.AuditLogging; import org.simantics.audit.AuditLogging.Level; @@ -14,6 +15,7 @@ import org.slf4j.LoggerFactory; public class AuditLoggingClient { private static final String AUDIT_SERVER_ADDRESS = "org.simantics.audit.serverAddress"; + private static final String AUDIT_CLIENT_ID = "org.simantics.audit.clientId"; private static final Logger LOGGER = LoggerFactory.getLogger(AuditLoggingClient.class); @@ -21,9 +23,8 @@ public class AuditLoggingClient { private AuditLoggingAPIClient apiClient; - private AuditLoggingClient(String serverAddress) throws AuditLoggingException { - // Read config from sysargs - apiClient = new AuditLoggingAPIClient("testlog", serverAddress); + private AuditLoggingClient(String clientId, String serverAddress) throws AuditLoggingException { + apiClient = new AuditLoggingAPIClient(clientId, serverAddress); } private static AuditLoggingClient fromEnv() throws AuditLoggingException { @@ -36,8 +37,11 @@ public class AuditLoggingClient { synchronized (AuditLoggingClient.class) { if (INSTANCE == null) { String serverAddress = (String) properties.get(AUDIT_SERVER_ADDRESS); + String clientId = (String) properties.get(AUDIT_CLIENT_ID); + if (clientId == null || clientId.isEmpty()) + clientId = UUID.randomUUID().toString(); if (serverAddress != null && !serverAddress.isEmpty()) { - INSTANCE = new AuditLoggingClient(serverAddress); + INSTANCE = new AuditLoggingClient(clientId, serverAddress); } else { LOGGER.warn("No {} system property defined so client not configured", AUDIT_SERVER_ADDRESS); } -- 2.47.1