aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2013-02-08 09:06:21 +0100
committerJulien Lancelot <julien.lancelot@gmail.com>2013-02-08 09:06:21 +0100
commit51fbc048418de8d69342d8278b75c9251e320a23 (patch)
treedaf35f84cc27a207f9122a57adbe89ee5553bc40 /sonar-server
parent856243d53548ef170facc3b68988c05de1f072af (diff)
downloadsonarqube-51fbc048418de8d69342d8278b75c9251e320a23.tar.gz
sonarqube-51fbc048418de8d69342d8278b75c9251e320a23.zip
SONAR-3820 Error when calling /api/violations webservice API
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/api/violations_controller.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/review.rb17
2 files changed, 10 insertions, 9 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/violations_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/violations_controller.rb
index 57c1c13ee3f..25d557a9b48 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/violations_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/violations_controller.rb
@@ -83,7 +83,7 @@ class Api::ViolationsController < Api::ResourceRestController
end
limit = (params[:limit] ? [params[:limit].to_i,5000].min : 5000)
- violations = RuleFailure.find(:all,
+ violations = RuleFailure.all(
:conditions => [ conditions.join(' AND '), values],
:include => [:snapshot, {:snapshot => :project}, :rule, :review],
:order => 'rule_failures.failure_level DESC',
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 26df00de9f6..4f6a284ce83 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
@@ -420,7 +420,7 @@ class Review < ActiveRecord::Base
xml.id(id.to_i)
xml.createdAt(Api::Utils.format_datetime(created_at))
xml.updatedAt(Api::Utils.format_datetime(updated_at))
- xml.author(user.login)
+ xml.author(user.login) if user
xml.assignee(assignee.login) if assignee
xml.title(title)
xml.status(status)
@@ -433,7 +433,7 @@ class Review < ActiveRecord::Base
review_comments.each do |comment|
xml.comment do
xml.id(comment.id.to_i)
- xml.author(comment.user.login)
+ xml.author(comment.user.login) if comment.user
xml.updatedAt(Api::Utils.format_datetime(comment.updated_at))
if convert_markdown
xml.text(comment.html_text)
@@ -455,7 +455,7 @@ class Review < ActiveRecord::Base
json['id'] = id.to_i
json['createdAt'] = Api::Utils.format_datetime(created_at)
json['updatedAt'] = Api::Utils.format_datetime(updated_at)
- json['author'] = user.login
+ json['author'] = user.login if user
json['assignee'] = assignee.login if assignee
json['title'] = title if title
json['status'] = status
@@ -466,12 +466,13 @@ class Review < ActiveRecord::Base
json['violationId'] = rule_failure_permanent_id if rule_failure_permanent_id
comments = []
review_comments.each do |comment|
- comments << {
- 'id' => comment.id.to_i,
- 'author' => comment.user.login,
- 'updatedAt' => Api::Utils.format_datetime(comment.updated_at),
- 'text' => convert_markdown ? comment.html_text : comment.plain_text
+ comment_map = {
+ 'id' => comment.id.to_i,
+ 'updatedAt' => Api::Utils.format_datetime(comment.updated_at),
+ 'text' => convert_markdown ? comment.html_text : comment.plain_text
}
+ comment_map['author'] = comment.user.login if comment.user
+ comments << comment_map
end
json['comments'] = comments
json