aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-01-16 15:41:01 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2012-01-16 15:41:01 +0100
commit7507d34fc8eee3f74f822697b1a955822ac3503b (patch)
tree34a93c56fc854c01ccd01d91aa83f252798de0c6
parentf6b3186f9cddcd5fcf9b87daccd962260c7588e9 (diff)
downloadsonarqube-7507d34fc8eee3f74f822697b1a955822ac3503b.tar.gz
sonarqube-7507d34fc8eee3f74f822697b1a955822ac3503b.zip
SONAR-3148 Do not log errors when the URL /charts/trends has bad parameters
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/charts_controller.rb40
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/users_controller.rb6
2 files changed, 21 insertions, 25 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/charts_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/charts_controller.rb
index db1f21ed942..4327242c00c 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/charts_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/charts_controller.rb
@@ -22,36 +22,38 @@ class ChartsController < ApplicationController
DEFAULT_TRENDS_WIDTH = 700
DEFAULT_TRENDS_HEIGHT = 250
-
+
CHART_COLORS = ["4192D9", "800000", "A7B307", "913C9F", "329F4D"]
-
+
def trends
resource=Project.by_key(params[:id])
+ bad_request("Unknown resource") unless resource
access_denied unless has_role?(:user, resource)
-
metric_keys=params[:metrics]
- metric_ids=[]
+ metrics=[]
if metric_keys
metric_keys.split(',').each do |key|
- metric_ids<<Metric.by_key(key)
+ metric=Metric.by_key(key)
+ metrics<<metric if metric
end
end
- unless metric_ids.empty?
- width=(params[:w] ? params[:w].to_i : DEFAULT_TRENDS_WIDTH)
- height=(params[:h] ? params[:h].to_i : DEFAULT_TRENDS_HEIGHT)
- display_legend = (params[:legend] ? params[:legend]=='true' : true)
-
- options={}
- if params[:from]
- options[:from]=Date::strptime(params[:from])
- end
- if params[:to]
- options[:to]=Date::strptime(params[:to])
- end
- stream = TrendsChart.png_chart(width, height, resource, metric_ids, params[:locale] || I18n.locale.to_s, display_legend, options)
- send_data stream, :type => 'image/png', :disposition => 'inline'
+ bad_request("Unknown metrics") if metrics.empty?
+
+ width=(params[:w] ? params[:w].to_i : DEFAULT_TRENDS_WIDTH)
+ height=(params[:h] ? params[:h].to_i : DEFAULT_TRENDS_HEIGHT)
+ display_legend = (params[:legend] ? params[:legend]=='true' : true)
+
+ options={}
+ if params[:from]
+ options[:from]=Date::strptime(params[:from])
end
+ if params[:to]
+ options[:to]=Date::strptime(params[:to])
+ end
+
+ stream = TrendsChart.png_chart(width, height, resource, metrics, params[:locale] || I18n.locale.to_s, display_legend, options)
+ send_data stream, :type => 'image/png', :disposition => 'inline'
end
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/users_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/users_controller.rb
index 45b04322bdc..f367c4371ab 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/users_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/users_controller.rb
@@ -133,12 +133,6 @@ class UsersController < ApplicationController
redirect_to(:action => 'index', :id => id)
end
- def toggle_edit_mode()
- current_user.toggle_edit_mode
- redirect_back_or_default(:controller => 'project')
- end
-
-
def prepare_user
user = User.new(params[:user])
default_group_name=java_facade.getSettings().getString('sonar.defaultGroup')