* Parses required search values from the query string
* @param query The HTTP query to work with
* @return A parsed SearchQuery object
*/
private final SearchQuery parseQueryString(HttpQuery query) {
final SearchQuery search_query = new SearchQuery();
search_query.setQuery(query.getRequiredQueryStringParam("query"));
if (query.hasQueryStringParam("limit")) {
final String limit = query.getQueryStringParam("limit");
try {
search_query.setLimit(Integer.parseInt(limit));
} catch (NumberFormatException e) {
throw new BadRequestException(
"Unable to convert 'limit' to a valid number");
}
}
if (query.hasQueryStringParam("start_index")) {
final String idx = query.getQueryStringParam("start_index");
try {
search_query.setStartIndex(Integer.parseInt(idx));
} catch (NumberFormatException e) {
throw new BadRequestException(
"Unable to convert 'start_index' to a valid number");
}
}