response.contentType("application/json; charset=UTF-8").print( jsonMessages.toString() );
}
}
private Collection<Message> listMessages(Direction direction, String recipientKey, Value recipientValue, Value status, Value numRecords) {
MessageCriteria criteria = new MessageCriteria()
.direction(direction)
.orderBy("id")
.orderType(OrderType.DOWNWARDS)
.numRecords( numRecords == null ? 2000 : numRecords.asInteger() );
if (recipientValue != null) {
criteria.addProperty(recipientKey, recipientValue.asString());
}
if (status != null) {
List<Value> statusList = status.asList();
for (Value s : statusList) {
criteria.addStatus(s.asInteger().byteValue());
}
}
return routingEngine.getMessageStore().list(criteria);
}