aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2013-08-13 15:55:18 +0200
committerJulien Lancelot <julien.lancelot@gmail.com>2013-08-13 15:55:18 +0200
commit76bdc0dce4922708aaca0583b126a7f6ca3559c2 (patch)
tree4acfb95785e1f4facb8bf192a721abc515bc64c0
parentb8884a98dd15997beef796730a1424c8af395a18 (diff)
downloadsonarqube-76bdc0dce4922708aaca0583b126a7f6ca3559c2.tar.gz
sonarqube-76bdc0dce4922708aaca0583b126a7f6ca3559c2.zip
SONAR-4552 Display a nice error page when requesting a page that tries to display a non-existing project
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties1
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb19
2 files changed, 18 insertions, 2 deletions
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
index 21d6117d9e0..eb291c817c1 100644
--- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
+++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
@@ -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.
#------------------------------------------------------------------------------
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb
index 7d096f9931a..93d39dce42b 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb
@@ -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