diff options
author | 2020-02-19 11:48:59 +0100 | |
---|---|---|
committer | 2020-02-24 10:56:18 +0100 | |
commit | 2edef3c2aaafba49439e20aa13eb647c67c781d5 (patch) | |
tree | bf1dd67aab8a2ed19260fb270321ccb746841f20 /certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfig.java | |
parent | 1e81a4ebe5141878b054e72d000ac0e7f6bc3d71 (diff) |
Added validation of configuration
Fields are being validated right after reading servers details from JSON (when application starts).
Created own annotation to validate server URL with proper requirements.
When invalid details are given application closes.
Signed-off-by: Michal Banka <michal.banka@nokia.com>
Change-Id: I3e476266056ec0fb637f01f9d4d4c63b1f0d1c6a
Issue-ID: AAF-997
Diffstat (limited to 'certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfig.java')
-rw-r--r-- | certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfig.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfig.java b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfig.java index 20e8934e..93721e88 100644 --- a/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfig.java +++ b/certService/src/main/java/org/onap/aaf/certservice/certification/configuration/CmpServersConfig.java @@ -23,6 +23,8 @@ package org.onap.aaf.certservice.certification.configuration; import org.onap.aaf.certservice.certification.configuration.model.Cmpv2Server; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.cloud.context.config.annotation.RefreshScope; @@ -39,20 +41,19 @@ import org.springframework.context.event.EventListener; @Configuration public class CmpServersConfig { - private static final String CMP_SERVERS_CONFIG_FILENAME = "cmpServers.json"; - private static final Logger LOGGER = LoggerFactory.getLogger(CmpServersConfig.class); + private static final String CMP_SERVERS_CONFIG_FILENAME = "cmpServers.json"; private static final String REFRESHING_CONFIGURATION = "Refreshing configuration"; - @Value("${app.config.path}") private String configPath; - - private CmpServersConfigLoader cmpServersConfigLoader; private List<Cmpv2Server> cmpServers; + private final CmpServersConfigLoader cmpServersConfigLoader; @Autowired - public CmpServersConfig(CmpServersConfigLoader cmpServersConfigLoader) { + public CmpServersConfig(@Value("${app.config.path}") String configPath, + CmpServersConfigLoader cmpServersConfigLoader) { this.cmpServersConfigLoader = cmpServersConfigLoader; + this.configPath = configPath; } @PostConstruct |