From 15671ddfedd4e91eab98946bb75297e4f4d9e893 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Fri, 17 Nov 2017 14:58:32 +0100 Subject: Fix remaining SOnar Resolve remaining sonar issues reported in Critical and Blocker Change-Id: Id80bf15c78e93a454f2446cb563f5c29a186b3d4 Issue-ID: CLAMP-74 Signed-off-by: Determe, Sebastien (sd378r) --- .../clamp/clds/client/req/policy/PolicyClient.java | 28 +++++++++--------- src/main/java/org/onap/clamp/clds/dao/CldsDao.java | 34 ++++++++++++---------- .../java/org/onap/clamp/clds/service/CldsUser.java | 6 ++-- 3 files changed, 35 insertions(+), 33 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java b/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java index e01a68fa4..957153560 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java +++ b/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java @@ -62,21 +62,21 @@ import org.springframework.context.ApplicationContext; * Policy utility methods - specifically, send the policy. */ public class PolicyClient { - protected static final String POLICY_PREFIX_BASE = "Config_"; - protected static final String POLICY_PREFIX_BRMS_PARAM = "Config_BRMS_Param_"; - protected static final String POLICY_PREFIX_MICROSERVICE = "Config_MS_"; - protected static final String LOG_POLICY_PREFIX = "Response is "; - protected static final EELFLogger logger = EELFManager.getInstance() - .getLogger(PolicyClient.class); - protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - protected static final String POLICY_MSTYPE_PROPERTY_NAME = "policy.ms.type"; - protected static final String POLICY_ONAPNAME_PROPERTY_NAME = "policy.onap.name"; + + protected static final String POLICY_PREFIX_BASE = "Config_"; + protected static final String POLICY_PREFIX_BRMS_PARAM = "Config_BRMS_Param_"; + protected static final String POLICY_PREFIX_MICROSERVICE = "Config_MS_"; + protected static final String LOG_POLICY_PREFIX = "Response is "; + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyClient.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + protected static final String POLICY_MSTYPE_PROPERTY_NAME = "policy.ms.type"; + protected static final String POLICY_ONAPNAME_PROPERTY_NAME = "policy.onap.name"; @Value("${org.onap.clamp.config.files.cldsPolicyConfig:'classpath:/clds/clds-policy-config.properties'}") - protected String cldsPolicyConfigFile; + protected String cldsPolicyConfigFile; @Autowired - protected ApplicationContext appContext; + protected ApplicationContext appContext; @Autowired - protected RefProp refProp; + protected RefProp refProp; /** * Perform BRMS policy type. @@ -88,7 +88,6 @@ public class PolicyClient { * @param policyRequestUuid * PolicyRequest UUID * @return The response message of policy - * */ public String sendBrmsPolicy(Map> attributes, ModelProperties prop, String policyRequestUuid) { @@ -331,7 +330,7 @@ public class PolicyClient { logger.info("Policy versions.size()=" + versions.size()); } catch (PolicyConfigException e) { // just print warning - if no policy version found - logger.warn("warning: policy not found...policy name - " + policyName, e.getMessage()); + logger.warn("policy not found...policy name - " + policyName, e); } return versions; } @@ -393,7 +392,6 @@ public class PolicyClient { * * @param prop * The ModelProperties - * * @return The response message from policy */ protected String deletePolicy(ModelProperties prop, String policyType) { diff --git a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java index 2c052c1a7..625aea586 100644 --- a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java +++ b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java @@ -54,20 +54,21 @@ import org.springframework.stereotype.Repository; */ @Repository("cldsDao") public class CldsDao { - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsDao.class); + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsDao.class); protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - private JdbcTemplate jdbcTemplateObject; - private SimpleJdbcCall procGetModel; - private SimpleJdbcCall procGetModelTemplate; - private SimpleJdbcCall procSetModel; - private SimpleJdbcCall procInsEvent; - private SimpleJdbcCall procUpdEvent; - private SimpleJdbcCall procSetTemplate; - private SimpleJdbcCall procGetTemplate; - private SimpleJdbcCall procDelAllModelInstances; - private SimpleJdbcCall procInsModelInstance; - private SimpleJdbcCall procDelModelInstance; - private static final String HEALTHCHECK = "Select 1"; + private JdbcTemplate jdbcTemplateObject; + private SimpleJdbcCall procGetModel; + private SimpleJdbcCall procGetModelTemplate; + private SimpleJdbcCall procSetModel; + private SimpleJdbcCall procInsEvent; + private SimpleJdbcCall procUpdEvent; + private SimpleJdbcCall procSetTemplate; + private SimpleJdbcCall procGetTemplate; + private SimpleJdbcCall procDelAllModelInstances; + private SimpleJdbcCall procInsModelInstance; + private SimpleJdbcCall procDelModelInstance; + private static final String HEALTHCHECK = "Select 1"; /** * Log message when instantiating @@ -421,11 +422,12 @@ public class CldsDao { List cldsServiceDataList = new ArrayList<>(); try { String getCldsServiceSQL = "SELECT * , TIMESTAMPDIFF(SECOND, timestamp, CURRENT_TIMESTAMP()) FROM clds_service_cache where invariant_service_id = ? "; - cldsServiceData = jdbcTemplateObject.queryForObject(getCldsServiceSQL, new Object[] { invariantUUID }, - new CldsServiceDataMapper()); + cldsServiceData = jdbcTemplateObject.queryForObject(getCldsServiceSQL, new Object[] { + invariantUUID + }, new CldsServiceDataMapper()); logger.info("value of cldsServiceDataList: {}", cldsServiceDataList); } catch (EmptyResultDataAccessException e) { - logger.info("cache row not found for invariantUUID: {}", invariantUUID); + logger.warn("cache row not found for invariantUUID: " + invariantUUID, e); } return cldsServiceData; } diff --git a/src/main/java/org/onap/clamp/clds/service/CldsUser.java b/src/main/java/org/onap/clamp/clds/service/CldsUser.java index db8a24f31..af39991e9 100644 --- a/src/main/java/org/onap/clamp/clds/service/CldsUser.java +++ b/src/main/java/org/onap/clamp/clds/service/CldsUser.java @@ -26,8 +26,9 @@ package org.onap.clamp.clds.service; import java.util.Arrays; public class CldsUser { - private String user; - private String password; + + private String user; + private String password; private SecureServicePermission[] permissions; /** @@ -68,6 +69,7 @@ public class CldsUser { } public String[] getPermissionsString() { + // NOSONAR return Arrays.stream(getPermissions()).map(SecureServicePermission::getKey).toArray(String[]::new); } -- cgit 1.2.3-korg