From f1c0e17d509b7a6ba17ec055b2e81681c7ac02e9 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Fri, 7 Mar 2014 15:14:37 +0100 Subject: [PATCH] Verify profile is existing on some actions --- .../main/java/org/sonar/server/qualityprofile/QProfiles.java | 3 +++ .../webapp/WEB-INF/app/controllers/profiles_controller.rb | 2 ++ .../WEB-INF/app/controllers/rules_configuration_controller.rb | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfiles.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfiles.java index 4442553a8c3..5c4c7f18dd4 100644 --- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfiles.java +++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfiles.java @@ -166,14 +166,17 @@ public class QProfiles implements ServerComponent { // PROFILE RULES + @CheckForNull public QProfileRule findByRule(int ruleId) { return rules.findByRuleId(ruleId); } + @CheckForNull public QProfileRule findByActiveRuleId(int activeRuleId) { return rules.findByActiveRuleId(activeRuleId); } + @CheckForNull public QProfileRule findByProfileAndRule(int profileId, int ruleId) { return rules.findByProfileIdAndRuleId(profileId, ruleId); } diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb index 82bf4bf0e63..4e6da1a42f8 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb @@ -176,6 +176,7 @@ class ProfilesController < ApplicationController call_backend do @profile = Internal.quality_profiles.profile(params[:id].to_i) + not_found('Profile not found') unless @profile @parent = Internal.quality_profiles.parent(@profile) if @profile.parent @ancestors = Internal.quality_profiles.ancestors(@profile).to_a @children = Internal.quality_profiles.children(@profile).to_a @@ -319,6 +320,7 @@ class ProfilesController < ApplicationController require_parameters 'id' call_backend do @profile = Internal.quality_profiles.profile(params[:id].to_i) + not_found('Profile not found') unless @profile end render :partial => 'profiles/rename_form' end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb index 6ee2726be2d..23583cdf205 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb @@ -35,6 +35,7 @@ class RulesConfigurationController < ApplicationController call_backend do @profile = Internal.quality_profiles.profile(params[:id].to_i) + not_found('Profile not found') unless @profile @parent_profile = Internal.quality_profiles.parent(@profile) if @profile.parent() add_breadcrumbs ProfilesController::root_breadcrumb, Api::Utils.language_name(@profile.language), @@ -145,6 +146,7 @@ class RulesConfigurationController < ApplicationController # form to duplicate a rule require_parameters :id, :rule_id @profile = Internal.quality_profiles.profile(params[:id].to_i) + not_found('Profile not found') unless @profile add_breadcrumbs ProfilesController::root_breadcrumb, Api::Utils.language_name(@profile.language), {:name => @profile.name, :url => {:controller => 'rules_configuration', :action => 'index', :id => @profile.id}} @@ -192,6 +194,7 @@ class RulesConfigurationController < ApplicationController call_backend do @profile = Internal.quality_profiles.profile(params[:id].to_i) + not_found('Profile not found') unless @profile @rule = Internal.quality_profiles.findByRule(params[:rule_id].to_i) if @rule.templateId().nil? redirect_to :action => 'index', :id => params[:id] @@ -259,6 +262,7 @@ class RulesConfigurationController < ApplicationController stop_watch = Internal.profiling.start("rules", "BASIC") @profile = Internal.quality_profiles.profile(params[:id].to_i) + not_found('Profile not found') unless @profile init_params criteria = init_criteria query = Java::OrgSonarServerQualityprofile::ProfileRuleQuery::parse(criteria.to_java) -- 2.39.5