From 627684ae0f2ac68ff1512de7532d230e33a16c37 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Thu, 7 Jun 2012 15:20:01 +0200 Subject: [PATCH] Fix loading of project settings in review workflow --- .../app/controllers/project_reviews_controller.rb | 2 +- .../WEB-INF/app/controllers/resource_controller.rb | 2 +- .../WEB-INF/app/controllers/reviews_controller.rb | 2 +- .../main/webapp/WEB-INF/app/models/rule_failure.rb | 12 ++++++------ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_reviews_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_reviews_controller.rb index 9093108c74a..2865b521d5b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_reviews_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/project_reviews_controller.rb @@ -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 diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb index 3faaa37dec9..a9e54122f81 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/resource_controller.rb @@ -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 diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb index f0a01936a8d..fb769042aea 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb @@ -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 diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb index ed69de10094..5861abace89 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/rule_failure.rb @@ -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 -- 2.39.5