From 11d685ff718945a0ba2b172106ba34a83a44c5a5 Mon Sep 17 00:00:00 2001 From: "k.kedron" Date: Wed, 17 Apr 2019 14:20:01 +0200 Subject: Fixed Sonar issues in the onap.clamp.clds.client packages Fixed Sonar issues: - change the HasMap to more optimized(in this case) EnumMap in GuardPolicyAttributesConstructor - remove no necessary casting in the TcaRequestFormatter - remove not used value in the DcaeDispatcherServices Additionally correct javadoc in PolicyClient. Change-Id: I6435fe093248073fee9749366e98d5720a8fe375 Issue-ID: CLAMP-346 Signed-off-by: Krystian Kedron --- .../org/onap/clamp/clds/client/DcaeDispatcherServices.java | 3 ++- .../req/policy/GuardPolicyAttributesConstructor.java | 5 ++++- .../onap/clamp/clds/client/req/policy/PolicyClient.java | 9 ++++++--- .../clamp/clds/client/req/tca/TcaRequestFormatter.java | 14 ++++++++------ 4 files changed, 20 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java index f74af49f8..024785e2e 100644 --- a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java +++ b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java @@ -5,6 +5,8 @@ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights * reserved. * ================================================================================ + * 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. * You may obtain a copy of the License at @@ -54,7 +56,6 @@ public class DcaeDispatcherServices { private static final String STATUS_URL_LOG = "Status URL extracted: "; private static final String DCAE_URL_PREFIX = "/dcae-deployments/"; private static final String DCAE_URL_PROPERTY_NAME = "dcae.dispatcher.url"; - public static final String DCAE_REQUESTID_PROPERTY_NAME = "dcae.header.requestId"; private static final String DCAE_LINK_FIELD = "links"; private static final String DCAE_STATUS_FIELD = "status"; diff --git a/src/main/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructor.java b/src/main/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructor.java index bc82cb3da..e996ae822 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructor.java +++ b/src/main/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructor.java @@ -5,6 +5,8 @@ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights * reserved. * ================================================================================ + * 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. * You may obtain a copy of the License at @@ -30,6 +32,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.EnumMap; import org.onap.clamp.clds.model.properties.ModelProperties; import org.onap.clamp.clds.model.properties.PolicyChain; @@ -99,7 +102,7 @@ public class GuardPolicyAttributesConstructor { } private static Map> createAttributesMap(Map matchingAttributes) { - Map> attributes = new HashMap<>(); + Map> attributes = new EnumMap<>(AttributeType.class); attributes.put(AttributeType.MATCHING, matchingAttributes); return attributes; } 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 c88489190..43209b299 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 @@ -5,6 +5,8 @@ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights * reserved. * ================================================================================ + * 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. * You may obtain a copy of the License at @@ -84,7 +86,6 @@ public class PolicyClient { public static final String POLICY_OP_NAME_PREFIX_PROPERTY_NAME = "policy.op.policyNamePrefix"; public static final String POLICY_MS_NAME_PREFIX_PROPERTY_NAME = "policy.ms.policyNamePrefix"; public static final String POLICY_OP_TYPE_PROPERTY_NAME = "policy.op.type"; - public static final String POLICY_GUARD_SUFFIX = "_Guard"; public static final String TOSCA_FILE_TEMP_PATH = "tosca.filePath"; @Autowired @@ -382,10 +383,12 @@ public class PolicyClient { * Use list Policy API to retrieve the policy. Return true if policy exists * otherwise return false. * - * @param policyNamePrefix - * The Policy Name Prefix * @param prop * The ModelProperties + * @param policyPrefix + * The Policy Name Prefix + * @param policyNameWithPrefix + * The Policy Full Name * @return The response message from policy * @throws PolicyConfigException * In case of issues with policy engine diff --git a/src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java b/src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java index 6b8f04397..ae0de074a 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java +++ b/src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java @@ -5,6 +5,8 @@ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights * reserved. * ================================================================================ + * 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. * You may obtain a copy of the License at @@ -173,7 +175,7 @@ public class TcaRequestFormatter { /** * This method updates the blueprint that is received in the UI with the TCA * Json. - * + * * @param refProp * * The refProp generally created by Spring, it's an access on * the clds-references.properties file @@ -188,11 +190,11 @@ public class TcaRequestFormatter { String jsonPolicy = JsonUtils.GSON.toJson(createPolicyContent(refProp, modelProperties, null, null, null)); logger.info("Yaml that will be updated:" + yamlValue); Yaml yaml = new Yaml(); - Map loadedYaml = (Map) yaml.load(yamlValue); - Map nodeTemplates = (Map) loadedYaml.get("node_templates"); - Map tcaObject = (Map) nodeTemplates.get("tca_tca"); - Map propsObject = (Map) tcaObject.get("properties"); - Map appPreferences = (Map) propsObject.get("app_preferences"); + Map loadedYaml = yaml.load(yamlValue); + Map nodeTemplates = loadedYaml.get("node_templates"); + Map tcaObject = nodeTemplates.get("tca_tca"); + Map propsObject = tcaObject.get("properties"); + Map appPreferences = propsObject.get("app_preferences"); appPreferences.put("tca_policy", jsonPolicy); String blueprint = yaml.dump(loadedYaml); logger.info("Yaml updated:" + blueprint); -- cgit 1.2.3-korg