diff options
author | Ravindra Bakkamanthala <rb7147@att.com> | 2017-05-15 12:53:18 -0400 |
---|---|---|
committer | Ravindra Bakkamanthala <rb7147@att.com> | 2017-05-15 13:55:23 -0400 |
commit | 7e547eaa55920dfbc9691eab33bb728395b50cf2 (patch) | |
tree | 5d0d64928b4754f65b427cb79b43718f16019582 /POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyRestController.java | |
parent | dda032f8bb161d54eb1f59de2b4a3efb774fc4d1 (diff) |
Policy TestSuite Enabled
Change-Id: I9f98c7dcdcf98713d73544956d873a84fc82adf7
Signed-off-by: Ravindra Bakkamanthala <rb7147@att.com>
Diffstat (limited to 'POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyRestController.java')
-rw-r--r-- | POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyRestController.java | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyRestController.java b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyRestController.java index c40f0da0c..75e3d0b8a 100644 --- a/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyRestController.java +++ b/POLICY-SDK-APP/src/main/java/org/openecomp/policy/admin/PolicyRestController.java @@ -28,6 +28,7 @@ import java.io.PrintWriter; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets; +import java.util.ArrayList; import java.util.Base64; import java.util.List; @@ -321,7 +322,7 @@ public class PolicyRestController extends RestrictedBaseController{ } } catch (Exception e) { - e.printStackTrace(); + LOGGER.error("Exception Occured"+e); }finally{ if(file != null){ if(file.exists()){ @@ -378,13 +379,43 @@ public class PolicyRestController extends RestrictedBaseController{ return null; } + @RequestMapping(value={"/searchDictionary"}, method={RequestMethod.POST}) + public ModelAndView searchDictionaryController(HttpServletRequest request, HttpServletResponse response) throws Exception{ + Object resultList = null; + String uri = request.getRequestURI(); + String body = callPAP(request, response, "POST", uri.replaceFirst("/", "").trim()); + if(body.contains("CouldNotConnectException")){ + List<String> data = new ArrayList<String>(); + data.add("Elastic Search Server is down"); + resultList = data; + }else{ + JSONObject json = new JSONObject(body); + resultList = json.get("policyresult"); + } + + response.setCharacterEncoding("UTF-8"); + response.setContentType("application / json"); + PrintWriter out = response.getWriter(); + JSONObject j = new JSONObject("{result: " + resultList + "}"); + out.write(j.toString()); + return null; + } + @RequestMapping(value={"/searchPolicy"}, method={RequestMethod.POST}) public ModelAndView searchPolicy(HttpServletRequest request, HttpServletResponse response) throws Exception{ + Object resultList = null; String uri = request.getRequestURI()+"?action=search"; String body = callPAP(request, response, "POST", uri.replaceFirst("/", "").trim()); + JSONObject json = new JSONObject(body); - Object resultList = json.get("policyresult"); - + try{ + resultList = json.get("policyresult"); + }catch(Exception e){ + List<String> data = new ArrayList<String>(); + data.add("Elastic Search Server is down"); + resultList = data; + } + response.setCharacterEncoding("UTF-8"); response.setContentType("application / json"); request.setCharacterEncoding("UTF-8"); |