class Api::ReviewsController < Api::ApiController
def index
- convert_markdown=(params[:output]=='html')
+ convert_markdown=(params[:output]=='HTML')
reviews=select_authorized(:user, Review.search(params), :project)
respond_to do |format|
def rest_to_json(rule_failures)
include_review=(params['include_review']=='true')
- convert_markdown=(params[:output]=='html')
+ convert_markdown=(params[:output]=='HTML')
JSON(rule_failures.collect{|rule_failure| rule_failure.to_json(include_review, convert_markdown)})
end
def rest_to_xml(rule_failures)
include_review=(params['include_review']=='true')
- convert_markdown=(params[:output]=='html')
+ convert_markdown=(params[:output]=='HTML')
xml = Builder::XmlMarkup.new(:indent => 0)
xml.instruct!
xml.violations do
# See http://jira.codehaus.org/browse/SONAR-2282
input.split(/\r?\n|\r/, -1)
end
+
+ def self.convert_string_to_unix_newlines(input)
+ split_newlines(input).join('\n')
+ end
end
xml.id(id.to_i)
xml.createdAt(Api::Utils.format_datetime(created_at))
xml.updatedAt(Api::Utils.format_datetime(updated_at))
- xml.user(user.login)
+ xml.author(user.login)
xml.assignee(assignee.login) if assignee
xml.title(title)
xml.type(review_type)
if convert_markdown
xml.text(comment.html_text)
else
- xml.text(comment.review_text)
+ xml.text(comment.plain_text)
end
end
end
comments << {
'author' => comment.user.login,
'updatedAt' => Api::Utils.format_datetime(comment.updated_at),
- 'text' => convert_markdown ? comment.html_text : comment.review_text
+ 'text' => convert_markdown ? comment.html_text : comment.plain_text
}
end
json['comments'] = comments
Api::Utils.markdown_to_html(review_text)
end
+ def plain_text
+ Api::Utils.convert_string_to_unix_newlines(review_text)
+ end
+
private
def comment_should_not_be_blank
end
end
end
-
+
+ def plain_message
+ @plain_message ||=
+ begin
+ Api::Utils.convert_string_to_unix_newlines(message)
+ end
+ end
+
def html_message
@html_message ||=
begin
def to_json(include_review=false, convert_markdown=false)
json = {}
- json['message'] = message
+ json['message'] = plain_message if plain_message
json['line'] = line if line && line>=1
json['priority'] = Sonar::RulePriority.to_s(failure_level).upcase
json['switchedOff']=true if switched_off?
def to_xml(xml=Builder::XmlMarkup.new(:indent => 0), include_review=false, convert_markdown=false)
xml.violation do
- xml.message(message)
+ xml.message(plain_message) if plain_message
xml.line(line) if line && line>=1
xml.priority(Sonar::RulePriority.to_s(failure_level))
xml.switchedOff(true) if switched_off?
public static final String BASE_URL = "/api/reviews";
+ public static final String OUTPUT_PLAIN = "PLAIN";
+ public static final String OUTPUT_HTML = "HTML";
+
private String reviewType;
private Long id;
private Long[] ids;
return output;
}
- /**
- * @param output the output to set
- */
public ReviewQuery setOutput(String output) {
this.output = output;
return this;