.getJSONObject(msgCollId).getJSONArray("messages");
// TODO: special case @all
if (messages == null) {
throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "message collection"
+ msgCollId + " not found");
}
// TODO: filter and sort outbox.
for (int i = 0; i < messages.length(); i++) {
JSONObject msg = messages.getJSONObject(i);
result.add(filterFields(msg, fields, Message.class));
}
return ImmediateFuture.newInstance(new RestfulCollection<Message>(result));
} catch (JSONException je) {
throw new ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, je.getMessage(),
je);
}
}