use of org.xel.Poll in project elastic-core-maven by OrdinaryDude.
the class SearchPolls method processRequest.
@Override
protected JSONStreamAware processRequest(HttpServletRequest req) throws ParameterException {
String query = Convert.nullToEmpty(req.getParameter("query"));
if (query.isEmpty()) {
return JSONResponses.missing("query");
}
int firstIndex = ParameterParser.getFirstIndex(req);
int lastIndex = ParameterParser.getLastIndex(req);
boolean includeFinished = "true".equalsIgnoreCase(req.getParameter("includeFinished"));
JSONObject response = new JSONObject();
JSONArray jsonArray = new JSONArray();
try (DbIterator<Poll> polls = Poll.searchPolls(query, includeFinished, firstIndex, lastIndex)) {
while (polls.hasNext()) {
jsonArray.add(JSONData.poll(polls.next()));
}
}
response.put("polls", jsonArray);
return response;
}
Aggregations