diff options
author | Fabrice Bellingard <bellingard@gmail.com> | 2011-05-30 14:58:02 +0200 |
---|---|---|
committer | Fabrice Bellingard <bellingard@gmail.com> | 2011-05-30 19:19:11 +0200 |
commit | 3cd3a7dcc73cb3924d8c61f532423226bb38b38b (patch) | |
tree | 1616351a6516ed3cc0b7748ddde670162789ef98 /sonar-server/src | |
parent | 9d66cd90629de1ccfc144636f66a96efbdfd53d8 (diff) | |
download | sonarqube-3cd3a7dcc73cb3924d8c61f532423226bb38b38b.tar.gz sonarqube-3cd3a7dcc73cb3924d8c61f532423226bb38b38b.zip |
SONAR-2404 Extend the Review web service API to create & update
- Java client WS: create, update and delete queries
- Added the ID of each comment on a review (JSON and XML) to be able
to cleanly delete the last comment of a review
Diffstat (limited to 'sonar-server/src')
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/controllers/api/reviews_controller.rb | 8 | ||||
-rw-r--r-- | sonar-server/src/main/webapp/WEB-INF/app/models/review.rb | 2 |
2 files changed, 6 insertions, 4 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/reviews_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/reviews_controller.rb index 4d485008464..50341983fd3 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/reviews_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/reviews_controller.rb @@ -173,18 +173,17 @@ class Api::ReviewsController < Api::ApiController # DELETE /api/reviews # Required parameters: # - 'id' : the review id - # - 'comment_id' : for the moment, only 'last_comment' value is accepted + # - 'comment_id' : the id of the comment to delete (for the moment, only the last comment can be deleted) # # Example : - # - DELETE "/api/reviews/update?id=1&comment=last_comment + # - DELETE "/api/reviews/update?id=1&comment=5 # def delete begin # 1- Get some parameters convert_markdown=(params[:output]=='HTML') comment_id = params[:comment_id] - raise "'comment' parameter is missing." unless comment_id - raise "Currently, only 'last_comment' is accepted for the 'comment' parameter." unless comment_id == 'last_comment' + raise "'comment_id' parameter is missing." unless comment_id # 2- Get the review or create one raise "No 'id' parameter has been provided." unless params[:id] @@ -197,6 +196,7 @@ class Api::ReviewsController < Api::ApiController # 3- Delete the last comment if possible raise "Cannot delete the only existing comment of this review." if review.comments.size == 1 last_comment = review.comments.last + raise "Only the last comment of a review can be deleted" unless last_comment.id == comment_id raise "You do not have the rights to edit this comment as it is not yours." unless last_comment.user == current_user review.delete_comment(last_comment.id) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb index fe2d2073f4d..d28b1de6a73 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb @@ -260,6 +260,7 @@ class Review < ActiveRecord::Base xml.comments do review_comments.each do |comment| xml.comment do + xml.id(comment.id) xml.author(comment.user.login) xml.updatedAt(Api::Utils.format_datetime(comment.updated_at)) if convert_markdown @@ -293,6 +294,7 @@ class Review < ActiveRecord::Base comments = [] review_comments.each do |comment| comments << { + 'id' => comment.id, 'author' => comment.user.login, 'updatedAt' => Api::Utils.format_datetime(comment.updated_at), 'text' => convert_markdown ? comment.html_text : comment.plain_text |