From: Jorge Hernandez Date: Tue, 21 May 2019 14:31:20 +0000 (+0000) Subject: Merge "Fix to resolve unpushing(delete) policies issue" X-Git-Tag: 1.4.1~1 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=policy%2Fengine.git;a=commitdiff_plain;h=7157ce69dd1f1a5a2d3cfaaa1c1754a8740e1cfa;hp=d46992c843eb05a02606fac4ef21c0d05c312a21 Merge "Fix to resolve unpushing(delete) policies issue" --- diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PdpApiService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PdpApiService.java index 8a7a8e0a0..7ecfb2dbe 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PdpApiService.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PdpApiService.java @@ -103,8 +103,7 @@ public abstract class PdpApiService { protected boolean validatePolicyNameAndScope(List policyNames, List policyTypes, List policyList) { - String policyName = null; - String policyScope = null; + String polType = null; if (policyTypes.size() == 1) { @@ -117,13 +116,20 @@ public abstract class PdpApiService { if (policyTypes.size() > 1) { polType = policyTypes.get(i).trim(); } - if (polName.contains(".")) { + + String policyName = null; + String policyScope = null; + if (polName.endsWith("xml")) { + policyName = polName; + policyScope = policyName.substring(0, StringUtils.lastOrdinalIndexOf(policyName, ".", 3)); + } else if (polName.contains(".")) { policyName = polName.substring(polName.lastIndexOf('.') + 1); policyScope = polName.substring(0, polName.lastIndexOf('.')); } else { message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Scope given."; return false; } + if (StringUtils.isBlank(policyName) || StringUtils.isBlank(policyScope)) { message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Invalid Policy Name."; return false;