aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-11-03 14:29:26 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-11-03 14:29:26 +0000
commitce0caddad67119edc47fd5509720e78fcd5e3da7 (patch)
tree0a581f4a027001bfdf226bc86cda73fa1a646d73
parent55c0003570731e64d7eeba8816bbf17fe04ee134 (diff)
downloadsonarqube-ce0caddad67119edc47fd5509720e78fcd5e3da7.tar.gz
sonarqube-ce0caddad67119edc47fd5509720e78fcd5e3da7.zip
SONAR-1910 Add a web service to upgrade database version
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/api/server_controller.rb27
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/setup_controller.rb7
2 files changed, 29 insertions, 5 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/server_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/server_controller.rb
index b033007963c..1982ac48d88 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/server_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/server_controller.rb
@@ -21,8 +21,14 @@ class Api::ServerController < Api::ApiController
skip_before_filter :check_authentication, :except => 'system'
before_filter :admin_required, :only => 'system'
+
+ # prevent HTTP proxies from caching server status
before_filter :set_cache_buster, :only => 'index'
-
+
+ # execute database setup
+ verify :method => :post, :only => [ :setup ]
+ skip_before_filter :check_database_version, :setup
+
def key
render :text => Java::OrgSonarServerPlatform::Platform.getServer().getId()
end
@@ -58,6 +64,25 @@ class Api::ServerController < Api::ApiController
format.text { render :text => text_not_supported}
end
end
+
+ def setup
+ begin
+ DatabaseVersion.setup unless DatabaseVersion.uptodate?
+ hash={:status => 'ok'}
+ respond_to do |format|
+ format.json{ render :json => jsonp(hash) }
+ format.xml { render :xml => hash.to_xml(:skip_types => true, :root => 'setup') }
+ format.text { render :text => hash[:status] }
+ end
+ rescue => e
+ hash={:status => 'ko', :msg => e.message}
+ respond_to do |format|
+ format.json{ render :json => jsonp(hash) }
+ format.xml { render :xml => hash.to_xml(:skip_types => true, :root => 'setup') }
+ format.text { render :text => hash[:status] }
+ end
+ end
+ end
private
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/setup_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/setup_controller.rb
index 58b1a0d71ea..b452dd7ab57 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/setup_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/setup_controller.rb
@@ -19,7 +19,7 @@
#
class SetupController < ApplicationController
skip_before_filter :check_database_version, :check_authentication
-
+
SECTION=Navigation::SECTION_CONFIGURATION
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
@@ -40,9 +40,8 @@ class SetupController < ApplicationController
end
def setup_database
- unless DatabaseVersion.uptodate?
- DatabaseVersion.setup
- end
+ # do not forget that this code is also in /api/server/setup (see api/server_controller.rb)
+ DatabaseVersion.setup unless DatabaseVersion.uptodate?
redirect_to home_path
end
end