result.add(personObj);
}
if (GroupId.Type.self == groupId.getType() && result.isEmpty()) {
throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "People '" + idSet + "' not found");
}
// We can pretend that by default the people are in top friends order
if (options.getSortBy().equals(Person.Field.NAME.toString())) {
Collections.sort(result, NAME_COMPARATOR);
if (options.getSortOrder() == SortOrder.descending) {
Collections.reverse(result);
}
}
// TODO: The samplecontainer doesn't really have the concept of HAS_APP so
// we can't support any filters yet. We should fix this.
int totalSize = result.size();
int last = options.getFirst() + options.getMax();
result = result.subList(options.getFirst(), Math.min(last, totalSize));
return ImmediateFuture.newInstance(new RestfulCollection<Person>(result, options.getFirst(), totalSize, options.getMax()));
} catch (JSONException je) {
throw new ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, je.getMessage(),
je);
}
}