From d8ed7a991d54bd6e53a7c1fedee808ab78dfdf19 Mon Sep 17 00:00:00 2001 From: isaac Date: Wed, 2 Feb 2022 17:26:05 -0600 Subject: Fixing sonar issues in xacml-pdp Issue-ID: POLICY-3900 Signed-off-by: isaac Change-Id: I29d22d1c6b690204270d87fff6ce42d9d00cef6a --- .../org/onap/policy/pdp/xacml/application/common/OnapObligation.java | 5 +++-- .../application/common/std/StdCombinedPolicyResultsTranslator.java | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'applications/common/src/main/java/org') diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/OnapObligation.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/OnapObligation.java index 4febd212..d6c744cb 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/OnapObligation.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/OnapObligation.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import com.att.research.xacml.api.Identifier; import com.att.research.xacml.api.Obligation; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import java.util.Collections; import java.util.Map; import lombok.AccessLevel; import lombok.Getter; @@ -103,7 +104,7 @@ public class OnapObligation { @SuppressWarnings("unchecked") public Map getPolicyContentAsMap() { if (this.policyContent == null) { - return null; + return Collections.emptyMap(); } return gson.fromJson(this.policyContent, Map.class); } diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslator.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslator.java index 5bf9151e..2a4574eb 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslator.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdCombinedPolicyResultsTranslator.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2022 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -186,7 +186,7 @@ public class StdCombinedPolicyResultsTranslator extends StdBaseTranslator { // Sanity check that we got the attributes we care about. NOTE: This translator // ensures that these are set when convertPolicy is called. // - if (! Strings.isNullOrEmpty(policyId) && policyContent != null) { + if (! Strings.isNullOrEmpty(policyId) && !policyContent.isEmpty()) { decisionResponse.getPolicies().put(policyId, policyContent); } else { LOGGER.error("Missing obligation policyId {} or policyContent {}", policyId, -- cgit 1.2.3-korg