From: jsimomaa Date: Thu, 15 Feb 2018 08:53:18 +0000 (+0200) Subject: Remove fixed "testlog" as client id and read from system property X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=ee1faf8f38b6ad98dd805f66a7294f3aedbafb5e;p=simantics%2Fplatform.git Remove fixed "testlog" as client id and read from system property refs #7768 Change-Id: I673f29eccc06c8375811fe5da557d506737209c2 (cherry picked from commit 59fb587c2dae32a2e865c9198aa20ffcad7f3c7f) --- 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); }