summaryrefslogtreecommitdiffstats
path: root/common/onap-common-configuration-management
diff options
context:
space:
mode:
authorPiotr Borelowski <p.borelowski@partner.samsung.com>2019-06-25 17:17:41 +0200
committerOfir Sonsino <ofir.sonsino@intl.att.com>2019-08-26 10:59:13 +0000
commit0b5efe797d39ccce1bb2feeca65197b33423d6c4 (patch)
tree2a286b816c3f2f0c50ea2234a96c2eed20ad4b43 /common/onap-common-configuration-management
parentc63f73abb5519005b3366ceb9cb9b24339f6412a (diff)
Fixed sonar issues in ConfigurationRepository
Fixing sonar issues in onap-configuration-management-core project Issue-ID: SDC-2390 Signed-off-by: Piotr Borelowski <p.borelowski@partner.samsung.com> Signed-off-by: Krystian Kedron <k.kedron@partner.samsung.com> Change-Id: I2814b189eb53f53ab94295ff6bba76d118616800
Diffstat (limited to 'common/onap-common-configuration-management')
-rwxr-xr-xcommon/onap-common-configuration-management/onap-configuration-management-core/pom.xml7
-rw-r--r--common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationRepository.java23
2 files changed, 20 insertions, 10 deletions
diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/pom.xml b/common/onap-common-configuration-management/onap-configuration-management-core/pom.xml
index 83b5ac7035..2c7fd006d5 100755
--- a/common/onap-common-configuration-management/onap-configuration-management-core/pom.xml
+++ b/common/onap-common-configuration-management/onap-configuration-management-core/pom.xml
@@ -105,7 +105,14 @@
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-logging-api</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
+
<build>
<plugins>
<plugin>
diff --git a/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationRepository.java b/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationRepository.java
index 63c3b7563f..7b2e267a14 100644
--- a/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationRepository.java
+++ b/common/onap-common-configuration-management/onap-configuration-management-core/src/main/java/org/onap/config/impl/ConfigurationRepository.java
@@ -1,5 +1,6 @@
/*
* Copyright © 2016-2018 European Support Limited
+ * Modifications Copyright (c) 2019 Samsung
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,9 +33,12 @@ import org.apache.commons.configuration2.builder.BasicConfigurationBuilder;
import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder;
import org.onap.config.ConfigurationUtils;
import org.onap.config.Constants;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
public final class ConfigurationRepository {
+ private static final Logger logger = LoggerFactory.getLogger(ConfigurationRepository.class);
private static final ConfigurationRepository REPO = new ConfigurationRepository();
private final Set<String> tenants = Collections.synchronizedSet(new HashSet<>());
@@ -49,14 +53,14 @@ public final class ConfigurationRepository {
protected boolean removeEldestEntry(Map.Entry eldest) {
try {
return size() > getConfigurationFor(Constants.DEFAULT_TENANT, Constants.DB_NAMESPACE)
- .getInt("config.size.max");
+ .getInt("config.size.max");
} catch (Exception exception) {
+ logger.info("ConfigurationException", exception);
return false;
}
}
});
-
private ConfigurationRepository() {
tenants.add(Constants.DEFAULT_TENANT);
namespaces.add(Constants.DEFAULT_NAMESPACE);
@@ -74,7 +78,6 @@ public final class ConfigurationRepository {
return namespaces;
}
-
public boolean isValidTenant(String tenant) {
return tenant != null && tenants.contains(tenant.toUpperCase());
}
@@ -86,7 +89,7 @@ public final class ConfigurationRepository {
public Configuration getConfigurationFor(String tenant, String namespace) throws Exception {
String module = tenant + Constants.KEY_ELEMENTS_DELIMITER + namespace;
ConfigurationHolder config = store.get(module);
- return config.getConfiguration(tenant + Constants.KEY_ELEMENTS_DELIMITER + namespace);
+ return config.getConfiguration();
}
public void populateConfiguration(String key, Configuration builder) {
@@ -138,7 +141,7 @@ public final class ConfigurationRepository {
}
private Configuration getEffectiveConfiguration(Configuration configuration,
- Collection<FileBasedConfigurationBuilder<FileBasedConfiguration>> list) {
+ Collection<FileBasedConfigurationBuilder<FileBasedConfiguration>> list) {
try {
CompositeConfiguration cc = new CompositeConfiguration();
for (FileBasedConfigurationBuilder<FileBasedConfiguration> b : list) {
@@ -148,19 +151,19 @@ public final class ConfigurationRepository {
composite = cc;
return composite;
} catch (Exception exception) {
+ logger.info("ConfigurationException", exception);
return null;
}
}
- public Configuration getConfiguration(String namespace) throws Exception {
-
+ public Configuration getConfiguration() throws Exception {
if (config == null) {
config = builder.getConfiguration();
lastConfigurationBuildTime = new Timestamp(System.currentTimeMillis());
} else if (lastConfigurationBuildTime != null
- && System.currentTimeMillis() - lastConfigurationBuildTime.getTime()
- > getConfigurationFor(Constants.DEFAULT_TENANT, Constants.DB_NAMESPACE)
- .getInt("config.refresh.interval")) {
+ && System.currentTimeMillis() - lastConfigurationBuildTime.getTime()
+ > getConfigurationFor(Constants.DEFAULT_TENANT, Constants.DB_NAMESPACE)
+ .getInt("config.refresh.interval")) {
lastConfigurationBuildTime = new Timestamp(System.currentTimeMillis());
}