From 82e81ac60d97b93847a26accc071e7043d831ab0 Mon Sep 17 00:00:00 2001 From: Michael Mokry Date: Mon, 11 Dec 2017 10:07:43 -0600 Subject: Adding SONAR fixes for - pushPolicy defect fixes for POLICY-486 - Common Policy Validation feature for POLIYC-449 Change-Id: I8d54aa5a9b819c6eb4427dfa47c4ce963a21c2e0 Issue-ID: POLICY-449,POLICY-486 Signed-off-by: Michael Mokry --- .../api/services/CreateUpdatePolicyServiceImpl.java | 18 +++++++----------- .../onap/policy/pdp/rest/api/utils/PolicyApiUtils.java | 7 +++---- 2 files changed, 10 insertions(+), 15 deletions(-) (limited to 'ONAP-PDP-REST/src/main/java/org') diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/CreateUpdatePolicyServiceImpl.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/CreateUpdatePolicyServiceImpl.java index 483e13c23..9939de966 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/CreateUpdatePolicyServiceImpl.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/CreateUpdatePolicyServiceImpl.java @@ -244,17 +244,13 @@ public class CreateUpdatePolicyServiceImpl implements CreateUpdatePolicyService return false; } - if(policyParameters.getPolicyClass() != null){ - if ("Config".equals(policyParameters.getPolicyClass().toString())){ - String policyConfigType = policyParameters.getPolicyConfigType().toString(); - if(!"BRMS_Param".equalsIgnoreCase(policyConfigType)){ - if(Strings.isNullOrEmpty(policyParameters.getConfigBody())){ - message = XACMLErrorConstants.ERROR_DATA_ISSUE + "ConfigBody: No Config Body given"; - LOGGER.error("Common validation did not return success: " + message); - return false; - } - } - } + if(policyParameters.getPolicyClass() != null && "Config".equals(policyParameters.getPolicyClass().toString())){ + String policyConfigType = policyParameters.getPolicyConfigType().toString(); + if(!"BRMS_Param".equalsIgnoreCase(policyConfigType) && Strings.isNullOrEmpty(policyParameters.getConfigBody())){ + message = XACMLErrorConstants.ERROR_DATA_ISSUE + "ConfigBody: No Config Body given"; + LOGGER.error("Common validation did not return success: " + message); + return false; + } } try { diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/utils/PolicyApiUtils.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/utils/PolicyApiUtils.java index 472d3aa95..197db26c1 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/utils/PolicyApiUtils.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/utils/PolicyApiUtils.java @@ -62,8 +62,7 @@ public class PolicyApiUtils { public static String formatResponse(StringBuilder responseString){ LOGGER.info("Formatting response message from Policy Validator"); - String response = null; - response = responseString.toString().replace("
", " | "); + String response = responseString.toString().replace("
", " | "); response = response.replaceAll("(|<\\/b>|
||<\\/i>|@#)", ""); return response; @@ -126,8 +125,8 @@ public class PolicyApiUtils { || "PUT".equals(json.getString("method").trim()) || "POST".equals(json.getString("method").trim())){ - message = SUCCESS; - + //Successful Validation + }else{ message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Method value."; return message; -- cgit 1.2.3-korg