X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ONAP-PDP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpdp%2Frest%2Fapi%2Fservices%2FPdpApiService.java;h=7ecfb2dbeec663a5f5eefe37f32505cf257f8188;hb=refs%2Fchanges%2F11%2F87911%2F2;hp=8a7a8e0a04fd770a5719cf68de9ee7169422bf2a;hpb=b559c050557e757325743bd37b41fd49b01ba19a;p=policy%2Fengine.git 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;