]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4552 Display a nice error page when requesting a page that tries to display...
authorJulien Lancelot <julien.lancelot@gmail.com>
Tue, 13 Aug 2013 13:55:18 +0000 (15:55 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Tue, 13 Aug 2013 13:55:18 +0000 (15:55 +0200)
plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb

index 21d6117d9e0aac329652198d83b0fea9a45ad3c5..eb291c817c1ae0c406441a9c04be65960017473d 100644 (file)
@@ -689,6 +689,7 @@ dashboard.shared_dashboards.description=These dashboards can be added to default
 dashboard.username.default=[SonarQube]
 dashboard.delete_confirm_title=Delete dashboard
 dashboard.delete_dashboard=Delete dashboard
+dashboard.project_not_found=The requested project does not exist. Either it has never been analyzed successfully or it has been deleted.
 
 
 #------------------------------------------------------------------------------
index 7d096f9931ae5419907ff63a6a03f241edbd1a0e..93d39dce42b1b7c9937fa1ab271cd86c08dbb12a 100644 (file)
@@ -181,8 +181,23 @@ class DashboardController < ApplicationController
   end
 
   def load_resource
-    init_resource_for_user_role unless !params[:id]
-    @project=@resource # for backward compatibility with old widgets
+    if params[:id]
+      @resource=Project.by_key(params[:id])
+      return project_not_found unless @resource
+      @resource=@resource.permanent_resource
+
+      @snapshot=@resource.last_snapshot
+      return project_not_found unless @snapshot
+
+      access_denied unless has_role?(:user, @resource)
+
+      @project=@resource # for backward compatibility with old widgets
+    end
+  end
+
+  def project_not_found
+    flash[:error] = message('dashboard.project_not_found')
+    redirect_to :action => :index
   end
 
   def load_authorized_widget_definitions