summaryrefslogtreecommitdiffstats
path: root/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/handler/DeleteHandler.java
diff options
context:
space:
mode:
authorRavindra Bakkamanthala <rb7147@att.com>2017-05-23 14:56:12 -0400
committerRavindra Bakkamanthala <rb7147@att.com>2017-05-23 16:49:56 -0400
commit87c95be02a8a4d77e165dede90777e811b59dcae (patch)
tree4712199fc3520b530dda0c4d3b074c327df547f2 /ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/handler/DeleteHandler.java
parent7e547eaa55920dfbc9691eab33bb728395b50cf2 (diff)
Commit includes ControlLoopPolicy API and bugfixes
Change-Id: I3e18bb8b4c31a0d908bb0cff4c85e2a3fb450a63 Signed-off-by: Ravindra Bakkamanthala <rb7147@att.com>
Diffstat (limited to 'ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/handler/DeleteHandler.java')
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/handler/DeleteHandler.java33
1 files changed, 23 insertions, 10 deletions
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/handler/DeleteHandler.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/handler/DeleteHandler.java
index 15e1faa04..ff454ade9 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/handler/DeleteHandler.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/handler/DeleteHandler.java
@@ -123,7 +123,14 @@ public class DeleteHandler {
}else if(policyName.contains("Decision_")){
splitPolicyName = removeVersionExtension.replace(".Decision_", ":Decision_");
}
- split = splitPolicyName.split(":");
+ if(splitPolicyName != null){
+ split = splitPolicyName.split(":");
+ }else{
+ PolicyLogger.error(MessageCodes.ERROR_UNKNOWN + "Failed to delete the policy. Please, provide the valid policyname.");
+ response.addHeader("error", "unknown");
+ response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
+ return;
+ }
policyEntityQuery = em.createQuery("SELECT p FROM PolicyEntity p WHERE p.policyName LIKE :pName and p.scope=:pScope");
}else if(policy.getDeleteCondition().equalsIgnoreCase("Current Version")) {
if(policyName.contains("Config_")){
@@ -249,7 +256,9 @@ public class DeleteHandler {
return;
} finally {
em.close();
- con.close();
+ if(con != null){
+ con.close();
+ }
}
if (policyVersionDeleted) {
@@ -290,12 +299,16 @@ public class DeleteHandler {
PolicyEntity policyEntity = (PolicyEntity) peData;
Statement st = null;
ResultSet rs = null;
- st = con.createStatement();
- rs = st.executeQuery("Select * from PolicyGroupEntity where policyid = '"+policyEntity.getPolicyId()+"'");
- boolean gEntityList = rs.next();
- rs.close();
- if(gEntityList){
- return true;
+ try{
+ st = con.createStatement();
+ rs = st.executeQuery("Select * from PolicyGroupEntity where policyid = '"+policyEntity.getPolicyId()+"'");
+ boolean gEntityList = rs.next();
+ rs.close();
+ if(gEntityList){
+ return true;
+ }
+ }finally{
+ st.close();
}
}
return false;
@@ -392,8 +405,8 @@ public class DeleteHandler {
} catch (PAPException e1) {
PolicyLogger.error("Exception occured While Deleting Policy From PDP Group"+e1);
}
- if (group == null || ! (group instanceof StdPDPGroup) || ! (group.getId().equals(existingGroup.getId()))) {
- PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE + " Group update had bad input. id=" + existingGroup.getId() + " objectFromJSON="+group);
+ if (group == null || ! (group instanceof StdPDPGroup) || existingGroup == null || ! (group.getId().equals(existingGroup.getId()))) {
+ PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE + " Group update had bad input. id=" + existingGroup != null ? existingGroup.getId() : "null" + " objectFromJSON="+group);
loggingContext.transactionEnded();
PolicyLogger.audit("Transaction Failed - See Error.log");
response = "No Group";