From 7e547eaa55920dfbc9691eab33bb728395b50cf2 Mon Sep 17 00:00:00 2001 From: Ravindra Bakkamanthala Date: Mon, 15 May 2017 12:53:18 -0400 Subject: Policy TestSuite Enabled Change-Id: I9f98c7dcdcf98713d73544956d873a84fc82adf7 Signed-off-by: Ravindra Bakkamanthala --- .../policy/admin/PolicyManagerServlet.java | 36 +++++++++++++--------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyManagerServlet.java') diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyManagerServlet.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyManagerServlet.java index 6c60c58c2..aa8a227d3 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyManagerServlet.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyManagerServlet.java @@ -143,7 +143,7 @@ public class PolicyManagerServlet extends HttpServlet { try { inputStream = new FileInputStream(location); } catch (FileNotFoundException e) { - e.printStackTrace(); + LOGGER.error("Exception Occured while initializing the JSONConfig file"+e); } if (location.endsWith("json")) { JsonReader jsonReader = null; @@ -295,7 +295,7 @@ public class PolicyManagerServlet extends HttpServlet { private JSONObject searchPolicyList(JSONObject params, HttpServletRequest request) { Set scopes = null; List roles = null; - policyData = null; + policyData = new ArrayList(); JSONArray policyList = null; if(params.has("policyList")){ policyList = (JSONArray) params.get("policyList"); @@ -492,7 +492,7 @@ public class PolicyManagerServlet extends HttpServlet { bw.close(); object = HumanPolicyComponent.DescribePolicy(temp); } catch (IOException e) { - e.printStackTrace(); + LOGGER.error("Exception Occured while Describing the Policy"+e); }finally{ temp.delete(); } @@ -679,6 +679,9 @@ public class PolicyManagerServlet extends HttpServlet { private String getUserName(String loginId){ PolicyController controller = new PolicyController(); UserInfo userInfo = (UserInfo) controller.getEntityItem(UserInfo.class, "userLoginId", loginId); + if(userInfo == null){ + return "super-admin"; + } return userInfo.getUserName(); } @@ -798,13 +801,15 @@ public class PolicyManagerServlet extends HttpServlet { } }else{ //Query the Policy Entity with oldPolicy Name - String oldpolicyEntityquery = "FROM PolicyEntity where policyName = '"+oldPolicySplit[1]+"' and scope ='"+oldPolicySplit[0]+"'"; - System.out.println(oldpolicyEntityquery); + String policyEntityCheck = oldPolicySplit[1].substring(0, oldPolicySplit[1].indexOf(".")); + String oldpolicyEntityquery = "FROM PolicyEntity where policyName like '"+policyEntityCheck+"%' and scope ='"+oldPolicySplit[0]+"'"; List oldEntityData = controller.getDataByQuery(oldpolicyEntityquery); if(!oldEntityData.isEmpty()){ - entity = (PolicyEntity) oldEntityData.get(0); + for(int i=0; i0"; controller.executeQuery(policyScopeQuery); } + }else{ + String policyScopeQuery = "delete PolicyEditorScopes where SCOPENAME like '"+path.replace("\\", "\\\\")+"%' and id >0"; + controller.executeQuery(policyScopeQuery); } } return success(); @@ -1379,4 +1385,4 @@ public class PolicyManagerServlet extends HttpServlet { throw new ServletException(e); } } -} +} \ No newline at end of file -- cgit 1.2.3-korg