diff options
author | Jorge Hernandez <jorge.hernandez-herrero@att.com> | 2019-03-20 13:44:28 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-03-20 13:44:28 +0000 |
commit | 430526c6a74773d1b681b4b4cb5ecf03af6e0c10 (patch) | |
tree | 76771d89fdff849c1785c4d9e87a2a86c8e783b7 /applications | |
parent | 8194fc9bffd890940c55c2188c56d93c7f7f4734 (diff) | |
parent | 041240baab6082916e5da69ed190051b7aa60f12 (diff) |
Merge "Fix sonar issues xacml pdp"
Diffstat (limited to 'applications')
4 files changed, 10 insertions, 8 deletions
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/ToscaDictionary.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/ToscaDictionary.java index 785ed9a8..352e51d8 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/ToscaDictionary.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/ToscaDictionary.java @@ -58,7 +58,7 @@ public final class ToscaDictionary { public static final Identifier ID_OBLIGATION_POLICY_MONITORING_DATATYPE = XACML3.ID_DATATYPE_STRING; - public static final Identifier ID_OBLIGATION_ISSUER = + public static final Identifier ID_OBLIGATION_MONITORING_ISSUER = new IdentifierImpl(URN_ONAP, "issuer:monitoring"); private ToscaDictionary() { diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtils.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtils.java index 19adaf6c..ca327b90 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtils.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlPolicyUtils.java @@ -51,6 +51,8 @@ import org.slf4j.LoggerFactory; public class XacmlPolicyUtils { private static final Logger LOGGER = LoggerFactory.getLogger(XacmlPolicyUtils.class); + private static final String DOT_FILE_SUFFIX = ".file"; + private static final String NOT_FOUND_MESSAGE = "NOT FOUND"; private XacmlPolicyUtils() { super(); @@ -165,7 +167,7 @@ public class XacmlPolicyUtils { id++; } else { referencedPolicies.add(refId); - properties.put(refId + ".file", refPolicyPath.toAbsolutePath().toString()); + properties.put(refId + DOT_FILE_SUFFIX, refPolicyPath.toAbsolutePath().toString()); break; } } @@ -193,7 +195,7 @@ public class XacmlPolicyUtils { boolean found = false; Set<String> referencedPolicies = XACMLProperties.getReferencedPolicyIDs(properties); for (String refPolicy : referencedPolicies) { - String refPolicyFile = refPolicy + ".file"; + String refPolicyFile = refPolicy + DOT_FILE_SUFFIX; // // If the key and value match, then it will return true // @@ -240,7 +242,7 @@ public class XacmlPolicyUtils { Set<String> rootPolicies = XACMLProperties.getRootPolicyIDs(properties); logger.debug("Root Policies: {}", properties.getProperty(XACMLProperties.PROP_ROOTPOLICIES)); for (String root : rootPolicies) { - logger.debug("{}", properties.getProperty(root + ".file", "NOT FOUND")); + logger.debug("{}", properties.getProperty(root + DOT_FILE_SUFFIX, NOT_FOUND_MESSAGE)); } // // Get the current set of referenced policy ids @@ -248,7 +250,7 @@ public class XacmlPolicyUtils { Set<String> referencedPolicies = XACMLProperties.getReferencedPolicyIDs(properties); logger.debug("Referenced Policies: {}", properties.getProperty(XACMLProperties.PROP_REFERENCEDPOLICIES)); for (String ref : referencedPolicies) { - logger.debug("{}", properties.getProperty(ref + ".file", "NOT FOUND")); + logger.debug("{}", properties.getProperty(ref + DOT_FILE_SUFFIX, NOT_FOUND_MESSAGE)); } } } diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/ToscaDictionaryTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/ToscaDictionaryTest.java index d427982f..b86617c5 100644 --- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/ToscaDictionaryTest.java +++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/ToscaDictionaryTest.java @@ -50,7 +50,7 @@ public class ToscaDictionaryTest { // // Probably don't need these as these ID's are used by other components // - assertNotNull(ToscaDictionary.ID_OBLIGATION_ISSUER); + assertNotNull(ToscaDictionary.ID_OBLIGATION_MONITORING_ISSUER); } } diff --git a/applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringRequest.java b/applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringRequest.java index b2e5ff9a..f3bee71b 100644 --- a/applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringRequest.java +++ b/applications/monitoring/src/main/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringRequest.java @@ -56,14 +56,14 @@ public class MonitoringRequest { Map<String, Object> resources = decisionRequest.getResource(); for (Entry<String, Object> entry : resources.entrySet()) { - if (entry.getKey().equals("policy-id")) { + if ("policy-id".contentEquals(entry.getKey())) { // // TODO handle lists of policies // request.resource = entry.getValue().toString(); continue; } - if (entry.getKey().equals("policy-type")) { + if ("policy-type".contentEquals(entry.getKey())) { // // TODO handle lists of policies // |