use of org.cerberus.crud.service.ITestCaseExecutionwwwDetService in project cerberus-source by cerberustesting.
the class TCEwwwDetail method doGet.
@Override
protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {
String echo = httpServletRequest.getParameter("sEcho");
String sStart = httpServletRequest.getParameter("iDisplayStart");
String sAmount = httpServletRequest.getParameter("iDisplayLength");
String sCol = httpServletRequest.getParameter("iSortCol_0");
String sdir = httpServletRequest.getParameter("sSortDir_0");
String dir = "asc";
// String[] cols = {"id","execID","start","url",
// "end","ext","statusCode","method","bytes","timeInMillis","reqHeader_Host","resHeader_ContentType"};
int start = 0;
int amount = 0;
int col = 0;
if (sStart != null) {
start = Integer.parseInt(sStart);
if (start < 0)
start = 0;
}
if (sAmount != null) {
amount = Integer.parseInt(sAmount);
if (amount < 10 || amount > 100)
amount = 10;
}
if (sCol != null) {
col = Integer.parseInt(sCol);
if (col < 0 || col > 5)
col = 0;
}
if (sdir != null) {
if (!sdir.equals("asc"))
dir = "desc";
}
// String colName = cols[col];
// data that will be shown in the table
JSONArray data = new JSONArray();
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
ITestCaseExecutionwwwDetService tCEwwwDetService = appContext.getBean(ITestCaseExecutionwwwDetService.class);
PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);
String id = policy.sanitize(httpServletRequest.getParameter("id"));
List<TestCaseExecutionwwwDet> detailList = tCEwwwDetService.getListOfDetail(Integer.valueOf(id));
try {
JSONObject jsonResponse = new JSONObject();
for (TestCaseExecutionwwwDet detail : detailList) {
JSONArray row = new JSONArray();
row.put(detail.getId()).put(detail.getExecID()).put(detail.getStart()).put(detail.getUrl()).put(detail.getEnd()).put(detail.getExt()).put(detail.getStatusCode()).put(detail.getMethod()).put(detail.getBytes()).put(detail.getTimeInMillis()).put(detail.getReqHeader_Host()).put(detail.getResHeader_ContentType());
data.put(row);
}
jsonResponse.put("aaData", data);
jsonResponse.put("sEcho", echo);
httpServletResponse.setContentType("application/json");
httpServletResponse.getWriter().print(jsonResponse.toString());
} catch (JSONException e) {
httpServletResponse.setContentType("text/html");
httpServletResponse.getWriter().print(e.getMessage());
}
}
Aggregations