aboutsummaryrefslogtreecommitdiffstats
path: root/ONAP-PDP-REST/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'ONAP-PDP-REST/src/main')
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PdpApiService.java12
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;