]> source.dussan.org Git - sonarqube.git/commitdiff
Verify profile is existing on some actions
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 7 Mar 2014 14:14:37 +0000 (15:14 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 7 Mar 2014 14:14:37 +0000 (15:14 +0100)
sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfiles.java
sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/controllers/rules_configuration_controller.rb

index 3de9aa427ab0bae9f218cbf61646efa90874da4a..119e892cc2cec29acd89694823bf551e8503968e 100644 (file)
 
 package org.sonar.server.qualityprofile;
 
-import org.sonar.server.paging.Paging;
-
 import com.google.common.base.Strings;
 import org.sonar.api.ServerComponent;
 import org.sonar.api.component.Component;
 import org.sonar.server.exceptions.BadRequestException;
+import org.sonar.server.paging.Paging;
 import org.sonar.server.user.UserSession;
 import org.sonar.server.util.Validation;
 
@@ -168,14 +167,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);
   }
index 82bf4bf0e63d5f117d89f602e52809a06d3913e8..4e6da1a42f8dd3b2ff6176ee54259352941343c8 100644 (file)
@@ -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
index 4dcaa2aa657f4d94c5730491e698ca193807d09e..ab16f7cecaf4a8f3479cd2eb4543d7e1ec26e84a 100644 (file)
@@ -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)