summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Mokry <michael.mokry@att.com>2019-05-16 12:46:03 -0500
committerMichael Mokry <michael.mokry@att.com>2019-05-20 11:04:09 -0500
commit202be3bf6f8b95ed1012b0127f8b859410ce6be5 (patch)
treeb30658eb01c25f4ae0c419e0faf02e305a79839e
parentb559c050557e757325743bd37b41fd49b01ba19a (diff)
Fix to resolve unpushing(delete) policies issue
Added code the ONAP-PDP-REST to fix an issue causing the policyName to be null and fail validation Updated Changes per Review: 1. re-added the else for "No Policy Scope given" 2. localized the policyName and policyScope declarations to reset to null each time through the loop 3. Changed to polName check to endsWith per Jim's review Change-Id: I912511ef362cc79e89adc1c9da93d387e273c32a Issue-ID: POLICY-1754 Signed-off-by: Michael Mokry <michael.mokry@att.com>
-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;