use of org.motechproject.mds.web.exception.InvalidParameterException in project motech by motech.
the class ParamParser method buildQueryParams.
public static QueryParams buildQueryParams(Map<String, String> requestParams) {
Integer page;
Integer pageSize;
String sortBy;
String orderDir;
Order order;
try {
page = getInteger(requestParams, PAGE, 1);
} catch (NumberFormatException e) {
throw new InvalidParameterException("Given page is not a number!", e);
}
try {
pageSize = getInteger(requestParams, PAGE_SIZE, 20);
} catch (NumberFormatException e) {
throw new InvalidParameterException("Given page size is not a number!", e);
}
sortBy = requestParams.get(SORT_BY);
orderDir = requestParams.get(ORDER_DIR);
order = buildOrder(sortBy, orderDir);
return new QueryParams(page, pageSize, order);
}
Aggregations