diff options
author | Jorge Hernandez <jorge.hernandez-herrero@att.com> | 2019-05-21 14:31:20 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-05-21 14:31:20 +0000 |
commit | 7157ce69dd1f1a5a2d3cfaaa1c1754a8740e1cfa (patch) | |
tree | efce7ffc0618a9e2a515790c88caab586525e891 | |
parent | d46992c843eb05a02606fac4ef21c0d05c312a21 (diff) | |
parent | 202be3bf6f8b95ed1012b0127f8b859410ce6be5 (diff) |
Merge "Fix to resolve unpushing(delete) policies issue"
-rw-r--r-- | ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PdpApiService.java | 12 |
1 files changed, 9 insertions, 3 deletions
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<String> policyNames, List<String> policyTypes, List<PolicyNameType> 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; |