diff options
author | Fabrice Bellingard <bellingard@gmail.com> | 2012-04-10 10:24:29 +0200 |
---|---|---|
committer | Fabrice Bellingard <bellingard@gmail.com> | 2012-04-10 10:24:29 +0200 |
commit | 7effa4cf5ef1c02f5cecfdeccd8ba3c20e77fd0b (patch) | |
tree | 9c817a20c2ac45e93b5b495b2c16e53af358aa16 | |
parent | a8614fdb0f491e6dfa955395399b6670b3e5bbfe (diff) | |
download | sonarqube-7effa4cf5ef1c02f5cecfdeccd8ba3c20e77fd0b.tar.gz sonarqube-7effa4cf5ef1c02f5cecfdeccd8ba3c20e77fd0b.zip |
SONAR-3278 Revert back the review search by 'id' on WS
- As previous versions of the Java WS Client used this parameter (and
in turn Sonar Eclipse too)
- But keep it undocumented as it is deprecated
- And update the Java WS Client to not use 'id' anymore but 'ids'
4 files changed, 10 insertions, 11 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_reviews_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_reviews_controller.rb index bb973147d3e..38e4837bf24 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_reviews_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_reviews_controller.rb @@ -36,7 +36,8 @@ class ProjectReviewsController < ApplicationController if @project access_denied unless has_role?(:user, @project) - found_reviews = Review.search(params) + # 'id' is the id of the project, so it should be removed from the search params + found_reviews = Review.search(params.reject {|k,v| k=='id'}) @reviews = select_authorized(:user, found_reviews, :project) if found_reviews.size != @reviews.size @security_exclusions = true 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 2ca3c693b7e..cac8b35f2af 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,15 +260,13 @@ class Review < ActiveRecord::Base conditions=[] values={} - if options['ids'].present? + if options['id'].present? + conditions << 'id=:id' + values[:id]=options['id'].to_i + elsif options['ids'].present? ids=options['ids'].split(',') - if ids.size > 1 - conditions << 'id in (:ids)' - values[:ids]=ids.map { |id| id.to_i } - else - conditions << 'id=:id' - values[:id]=ids[0].to_i - end + conditions << 'id in (:ids)' + values[:ids]=ids.map { |id| id.to_i } else # --- 'review_type' is deprecated since 2.9 --- diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewQuery.java index 81d3cc850b0..da420c118a9 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewQuery.java @@ -267,7 +267,7 @@ public class ReviewQuery extends Query<Review> { StringBuilder url = new StringBuilder(BASE_URL); url.append('?'); if (id != null) { - appendUrlParameter(url, "id", id); + appendUrlParameter(url, "ids", id); } else if (ids != null) { appendUrlParameter(url, "ids", ids); } diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewQueryTest.java index 5632b29c79a..0186f0ec468 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewQueryTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ReviewQueryTest.java @@ -39,7 +39,7 @@ public class ReviewQueryTest extends QueryTestCase { @Test public void queryById() { - assertThat(new ReviewQuery().setId(13L).getUrl(), is("/api/reviews?id=13&")); + assertThat(new ReviewQuery().setId(13L).getUrl(), is("/api/reviews?ids=13&")); assertThat(new ReviewQuery().setIds(10L, 11L).getUrl(), is("/api/reviews?ids=10,11&")); } |