Merge "Fix to resolve unpushing(delete) policies issue"
authorJorge Hernandez <jorge.hernandez-herrero@att.com>
Tue, 21 May 2019 14:31:20 +0000 (14:31 +0000)
committerGerrit Code Review <gerrit@onap.org>
Tue, 21 May 2019 14:31:20 +0000 (14:31 +0000)
ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PdpApiService.java

index 8a7a8e0..7ecfb2d 100644 (file)
@@ -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;