use of org.cerberus.crud.service.ICountryEnvironmentService in project cerberus-source by cerberustesting.
the class GetEnvironmentAvailable method doGet.
@Override
protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {
PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);
String testName = policy.sanitize(httpServletRequest.getParameter("test"));
String testCaseName = policy.sanitize(httpServletRequest.getParameter("testCase"));
String country = policy.sanitize(httpServletRequest.getParameter("country"));
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
ICountryEnvironmentService countryEnvironmentService = appContext.getBean(CountryEnvironmentService.class);
JSONArray array = new JSONArray();
JSONObject jsonObject = new JSONObject();
try {
for (String[] strings : countryEnvironmentService.getEnvironmentAvailable(testName, testCaseName, country)) {
JSONObject env = new JSONObject();
env.put("environment", strings[0]);
env.put("description", strings[0].concat(" With Build: ").concat(strings[1]).concat(" And Revision: ").concat(strings[2]));
array.put(env);
}
jsonObject.put("envList", array);
httpServletResponse.setContentType("application/json");
httpServletResponse.getWriter().print(jsonObject.toString());
} catch (JSONException exception) {
LOG.warn(exception.toString());
}
}
Aggregations