use of org.obiba.mica.core.event.CommentUpdatedEvent in project mica2 by obiba.
the class CommentsService method save.
public Comment save(Comment comment, MailNotification<Comment> mailNotification) {
if (comment.getMessage().isEmpty())
throw new IllegalArgumentException("Comment message cannot be empty");
Comment saved = comment;
if (!comment.isNew()) {
saved = commentsRepository.findOne(comment.getId());
if (saved == null) {
saved = comment;
} else {
BeanUtils.copyProperties(comment, saved, "id", "classId", "createdDate");
}
saved.setLastModifiedDate(DateTime.now());
}
if (mailNotification != null)
mailNotification.send(saved);
commentsRepository.save(saved);
eventBus.post(new CommentUpdatedEvent(comment));
return saved;
}
Aggregations