diff options
author | ezhil <ezhrajam@in.ibm.com> | 2018-12-28 23:41:37 +0530 |
---|---|---|
committer | Ezhilarasi R <ezhrajam@in.ibm.com> | 2019-01-09 06:42:21 +0000 |
commit | d63f9f4458f287617e6ea7854dec8266c44be5ee (patch) | |
tree | 335c60fcc7a8df85bc49ca4da2f4a31f79d92854 /ms/neng | |
parent | 65691146cceb8ee483cd4003f5fcc6fda14c0f01 (diff) |
Fixed sonar issue in PolicyReader.java
Change-Id: I093edcd1a6e5ebfc0f3db302a006d3d3ca373c0a
Issue-ID: CCSDK-877
Signed-off-by: ezhil <ezhrajam@in.ibm.com>
Diffstat (limited to 'ms/neng')
-rw-r--r-- | ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyReader.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyReader.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyReader.java index 181bb7a3..3c4efe51 100644 --- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyReader.java +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyReader.java @@ -4,7 +4,7 @@ * ================================================================================ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ - * Modifications Copyright (C) 2018 IBM. + * Modifications Copyright (C) 2019 IBM. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,8 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.regex.Pattern; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Converts policy data to the structure expected by this micro-service. @@ -41,11 +43,12 @@ public abstract class PolicyReader implements PolicyFinder { */ private static final String NAMING_MODELS = "naming-models"; private static final String NAMING_TYPE = "naming-type"; + private static final Logger LOG = LoggerFactory.getLogger(PolicyReader.class); public static List<Map<String, ?>> namingModels(Map<String, ?> policy) { Set<String> keys = policy.keySet(); - // TODO : retrieve naming-models at any level + // retrieve naming-models at any level if (keys.contains("config")) { @SuppressWarnings("unchecked") Map<String, ?> config = (Map<String, ?>) policy.get("config"); @@ -111,7 +114,7 @@ public abstract class PolicyReader implements PolicyFinder { Object val = model.get(NAMING_TYPE); if (val != null) { String relaxedVal = relaxedNamingType(val.toString()); - if (namingType.equalsIgnoreCase(relaxedVal)) { + if (namingType != null && namingType.equalsIgnoreCase(relaxedVal)) { theModel = model; break; } @@ -231,9 +234,6 @@ public abstract class PolicyReader implements PolicyFinder { String value = null; if (map != null) { value = (String) map.get(key); - if (!(value instanceof String)) { - value = null; - } if (value != null && !Pattern.matches("\\$\\{.*\\}.*", value)) { return value; } else { @@ -335,6 +335,7 @@ public abstract class PolicyReader implements PolicyFinder { try { value = Long.valueOf(str); } catch (Exception e) { + LOG.info("String parse error", e); value = defaultValue; } return value; |