use of io.lumeer.engine.api.event.UpdateResourceComment in project engine by Lumeer.
the class MongoResourceCommentDao method updateComment.
@Override
public ResourceComment updateComment(final ResourceComment comment) {
FindOneAndUpdateOptions options = new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER);
try {
Bson update = new org.bson.Document("$set", comment);
ResourceComment updatedComment = databaseCollection().findOneAndUpdate(idFilter(comment.getId()), update, options);
if (updatedComment == null) {
throw new StorageException("Comment '" + comment.getId() + "' has not been updated.");
}
if (updateResourceCommentEvent != null) {
updateResourceCommentEvent.fire(new UpdateResourceComment(comment));
}
return updatedComment;
} catch (MongoException ex) {
throw new StorageException("Cannot update comment: " + comment, ex);
}
}
Aggregations