@GET
@Path("{messageId}/comment")
public Response getCommentsForMessage(@PathParam("messageId") ObjectId messageId) {
User user = applicationManager.getSecurityService().getCurrentUser();
SobaMessage sobaMessage;
try {
sobaMessage = applicationManager.getMessageService().getMessage(user.getAccount(), messageId);
} catch (MessageNotFoundException e) {
return error(e.getMessage(), Response.status(Response.Status.NOT_FOUND));
}
MessageCommentsResponseDTO dto = new MessageCommentsResponseDTO();
List<MessageCommentResponseDTO> allComments = new ArrayList<>();
for (MessageComment comment : sobaMessage.getComments()) {
allComments.add(comment.toDTO());
}
dto.setComments(allComments);