From d63f9f4458f287617e6ea7854dec8266c44be5ee Mon Sep 17 00:00:00 2001 From: ezhil Date: Fri, 28 Dec 2018 23:41:37 +0530 Subject: Fixed sonar issue in PolicyReader.java Change-Id: I093edcd1a6e5ebfc0f3db302a006d3d3ca373c0a Issue-ID: CCSDK-877 Signed-off-by: ezhil --- .../onap/ccsdk/apps/ms/neng/core/policy/PolicyReader.java | 13 +++++++------ 1 file 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> namingModels(Map policy) { Set keys = policy.keySet(); - // TODO : retrieve naming-models at any level + // retrieve naming-models at any level if (keys.contains("config")) { @SuppressWarnings("unchecked") Map config = (Map) 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; -- cgit 1.2.3-korg