]> source.dussan.org Git - sonarqube.git/commitdiff
Fix loading of project settings in review workflow
authorSimon Brandhof <simon.brandhof@gmail.com>
Thu, 7 Jun 2012 13:20:01 +0000 (15:20 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Thu, 7 Jun 2012 13:20:15 +0000 (15:20 +0200)
sonar-server/src/main/webapp/WEB-INF/app/controllers/project_reviews_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb

index 9093108c74ad9af3bedaa8a1b252da644b3d85fe..2865b521d5b7ac2faf1b3124ecdc7f76199f61c9 100644 (file)
@@ -269,7 +269,7 @@ class ProjectReviewsController < ApplicationController
 
     error_message = nil
     begin
-      RuleFailure.execute_command(params[:command], review.violation, review.resource.project, current_user, params)
+      RuleFailure.execute_command(params[:command], review.violation, current_user, params)
     rescue Exception => e
       error_message=Api::Utils.exception_message(e, :backtrace => false)
     end
index 3faaa37dec92648fe4b9568b27e160d7546ad831..a9e54122f813f508987360284a26dc28462a844a 100644 (file)
@@ -379,7 +379,7 @@ class ResourceController < ApplicationController
 
     @review_screens_by_vid=nil
     if current_user && has_role?(:user, @resource)
-      @review_screens_by_vid = RuleFailure.available_java_screens_for_violations(violations, @resource.project, current_user)
+      @review_screens_by_vid = RuleFailure.available_java_screens_for_violations(violations, @resource, current_user)
     end
     render :action => 'index', :layout => !request.xhr?
   end
index f0a01936a8d16aec2b9bfefc67c4d414fa7b2fa6..fb769042aea98d1986141f4362087e3f3ea12072 100644 (file)
@@ -71,7 +71,7 @@ class ReviewsController < ApplicationController
     # TODO remove parameters 'id' and 'command' from params
     error_message = nil
     begin
-      RuleFailure.execute_command(params[:command], violation, violation.snapshot.root_snapshot.project, current_user, params)
+      RuleFailure.execute_command(params[:command], violation, current_user, params)
     rescue Exception => e
       error_message=Api::Utils.exception_message(e, :backtrace => false)
     end
index ed69de10094003cd87a647316d54209adc40b76a..5861abace89229a9039562f67abe70793b4fff6e 100644 (file)
@@ -252,9 +252,9 @@ class RuleFailure < ActiveRecord::Base
   #
   # Constraint : all the violations are in the same project
   #
-  def self.available_java_screens_for_violations(violations, project, user)
+  def self.available_java_screens_for_violations(violations, resource, user)
     reviews = violations.map { |violation| to_java_workflow_review(violation) }
-    context = to_java_workflow_context(project, user)
+    context = to_java_workflow_context(resource, user)
     Java::OrgSonarServerUi::JRubyFacade.getInstance().listAvailableReviewsScreens(reviews, context)
   end
 
@@ -268,9 +268,9 @@ class RuleFailure < ActiveRecord::Base
     end
   end
 
-  def self.execute_command(command_key, violation, project, user, parameters)
+  def self.execute_command(command_key, violation, user, parameters)
     review = to_java_workflow_review(violation)
-    context = to_java_workflow_context(project, user)
+    context = to_java_workflow_context(violation.resource, user)
     Java::OrgSonarServerUi::JRubyFacade.getInstance().executeReviewCommand(command_key, review, context, parameters)
   end
 
@@ -298,14 +298,14 @@ class RuleFailure < ActiveRecord::Base
     java_review
   end
 
-  def self.to_java_workflow_context(project, user)
+  def self.to_java_workflow_context(resource, user)
     java_context = Java::OrgSonarApiWorkflowInternal::DefaultWorkflowContext.new
     java_context.setUserId(user.id)
     java_context.setUserLogin(user.login)
     java_context.setUserName(user.name)
     java_context.setUserEmail(user.email)
     java_context.setIsAdmin(user.has_role?(:admin))
-    java_context.setProjectId(project.id)
+    java_context.setProjectId(resource.root_project.id)
     java_context
   end