From: Simon Brandhof Date: Thu, 1 Sep 2016 06:03:16 +0000 (+0200) Subject: SONAR-7678 do not load l10n messages during ruby initialisation X-Git-Tag: 6.1-RC1~208 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a8b6d946372e3dd3f1a0bacace78b9d02867897f;p=sonarqube.git SONAR-7678 do not load l10n messages during ruby initialisation ActiveRecord models must not load l10n messages, through Java JRubyI18n component, when ruby code is parsed. * measure_filter * profile is read-only as ruby WS do not write profiles anymore --- diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb index 974a1173b87..e7d07a86d11 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/measure_filter.rb @@ -65,12 +65,19 @@ class MeasureFilter < ActiveRecord::Base belongs_to :user has_many :measure_filter_favourites, :dependent => :delete_all - validates_presence_of :name, :message => Api::Utils.message('measure_filter.missing_name') - validates_length_of :name, :maximum => 100, :message => Api::Utils.message('measure_filter.name_too_long') validates_length_of :description, :allow_nil => true, :maximum => 4000 + validate :validate_name attr_reader :pagination, :security_exclusions, :base_row, :rows, :display + def validate_name + if name.nil? || name.empty? + errors.add :name, Api::Utils.message('measure_filter.missing_name') + elsif name.size > 100 + errors.add :name, Api::Utils.message('measure_filter.name_too_long') + end + end + def sort_key criteria['sort'] end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/profile.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/profile.rb index 671dd892cd8..7b4d1d690cf 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/profile.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/profile.rb @@ -24,11 +24,8 @@ class Profile < ActiveRecord::Base has_many :active_rules_with_params, :class_name => 'ActiveRule', :foreign_key => 'profile_id', :include => ['active_rule_parameters'] has_many :changes, :class_name => 'ActiveRuleChange', :dependent => :destroy - validates_uniqueness_of :name, :scope => :language, :case_sensitive => false, :message => Api::Utils.message('quality_profiles.already_exists') - validates_presence_of :name, :message => Api::Utils.message('quality_profiles.please_type_profile_name') - MAX_NAME_LENGTH = 100 - validates_length_of :name, :maximum => MAX_NAME_LENGTH, :message => Api::Utils.message('name_too_long_x', :params => [MAX_NAME_LENGTH]) + after_initialize :readonly! # The warnings that are set on this record, equivalent to normal ActiveRecord errors but does not prevent # the record from saving. @@ -135,27 +132,6 @@ class Profile < ActiveRecord::Base end end - def before_destroy - raise 'This profile can not be deleted' unless deletable? - Property.clear_for_resources("sonar.profile.#{language}", name) - end - - def rename(new_name) - old_name=self.name - Profile.transaction do - self.name=new_name - if save - Property.with_key("sonar.profile.#{language}").each do |prop| - if prop.text_value==old_name - prop.text_value=new_name - prop.save - end - end - end - end - self - end - def projects? !projects.empty? end