private void setSortOptions(HistoricActivityStatisticsQuery query, String sortOrder, String sortBy) {
boolean sortOptionsValid = (sortBy != null && sortOrder != null) || (sortBy == null && sortOrder == null);
if (!sortOptionsValid) {
throw new InvalidRequestException(Status.BAD_REQUEST, "Only a single sorting parameter specified. sortBy and sortOrder required");
}
if (sortBy != null) {
if (sortBy.equals("activityId")) {
query.orderByActivityId();
} else {
throw new InvalidRequestException(Status.BAD_REQUEST, "sortBy parameter has invalid value: " + sortBy);
}
}
if (sortOrder != null) {
if (sortOrder.equals("asc")) {
query.asc();
} else
if (sortOrder.equals("desc")) {
query.desc();
} else {
throw new InvalidRequestException(Status.BAD_REQUEST, "sortOrder parameter has invalid value: " + sortOrder);
}
}
}