aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2016-06-27 11:07:27 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2016-06-29 08:41:53 +0200
commit22b483458fdd132efe8a717624ea4b47ad37bba6 (patch)
tree217f9fefe750ddd6a6ced7224f481cf4231ab277 /server/sonar-web
parenta2c1cc8cd4a407aba13d733330fb5308a1f5168e (diff)
downloadsonarqube-22b483458fdd132efe8a717624ea4b47ad37bba6.tar.gz
sonarqube-22b483458fdd132efe8a717624ea4b47ad37bba6.zip
SONAR-7759 Java WS are not executed by Rails
Diffstat (limited to 'server/sonar-web')
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/java_ws_controller.rb33
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/config/routes.rb5
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/lib/java_ws_routing.rb14
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/web.xml8
4 files changed, 9 insertions, 51 deletions
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/java_ws_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/java_ws_controller.rb
index cb74a0700b3..245ed2b2a0f 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/java_ws_controller.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/java_ws_controller.rb
@@ -21,39 +21,8 @@
# since 4.2
class Api::JavaWsController < Api::ApiController
- before_filter :check_authentication, :unless => ['skip_authentication_check_for_batch']
-
- # no need to check if WS can be accessed when DB is not up-to-date, this is dealt with in
- # Platform and ServerComponents classes
- skip_before_filter :check_database_version
-
- def index
- ws_request = Java::OrgSonarServerWs::ServletRequest.new(servlet_request, params.to_java)
- ws_response = Java::OrgSonarServerWs::ServletResponse.new()
- engine = Java::OrgSonarServerPlatform::Platform.component(Java::OrgSonarServerWs::WebServiceEngine.java_class)
- engine.execute(ws_request, ws_response, params[:wspath], params[:wsaction], params[:responseFormat])
-
- ws_response.getHeaderNames().to_a.each do |name|
- response.header[name] = ws_response.getHeader(name)
- end
-
- # response is already written to HttpServletResponse
- render :text => ws_response.stream().output().toByteArray(),
- :status => ws_response.stream().httpStatus(),
- :content_type => ws_response.stream().mediaType()
- end
-
def redirect_to_ws_listing
- redirect_to :action => 'index', :wspath => 'api/webservices', :wsaction => 'list'
- end
-
-
- def skip_authentication_check_for_batch
- (params[:wspath]=='batch' && params[:wsaction]=='index') ||
- (params[:wspath]=='batch' && params[:wsaction]=='file') ||
- (params[:wspath]=='api/system' && params[:wsaction]=='db_migration_status') ||
- (params[:wspath]=='api/system' && params[:wsaction]=='migrate_db') ||
- (params[:wspath]=='api/system' && params[:wsaction]=='status')
+ redirect_to :controller => 'api/webservices', :action => 'list'
end
end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/config/routes.rb b/server/sonar-web/src/main/webapp/WEB-INF/config/routes.rb
index 77d8bcd6e14..1af5e16edac 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/config/routes.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/config/routes.rb
@@ -8,13 +8,8 @@ ActionController::Routing::Routes.draw do |map|
map.connect 'api', :controller => 'api/java_ws', :action => 'redirect_to_ws_listing'
- # deprecated, sonar-runner should use batch/index and batch/file?name=xxx
- map.connect 'batch_bootstrap/index', :controller => 'api/java_ws', :action => 'index', :wspath => 'batch', :wsaction => 'index'
- map.connect 'batch/:name', :controller => 'api/java_ws', :action => 'index', :wspath => 'batch', :wsaction => 'file', :requirements => { :name => /.*/ }
-
map.connect 'api/server/:action', :controller => 'api/server'
map.connect 'api/resoures', :controller => 'api/resources', :action => 'index'
- map.connect 'api/sources', :controller => 'api/sources', :action => 'index'
map.resources 'properties', :path_prefix => 'api', :controller => 'api/properties', :requirements => { :id => /.*/ }
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/lib/java_ws_routing.rb b/server/sonar-web/src/main/webapp/WEB-INF/lib/java_ws_routing.rb
index f0cfacd6287..96c45d64c20 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/lib/java_ws_routing.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/lib/java_ws_routing.rb
@@ -28,20 +28,6 @@ module ActionController
eval(ws.getTemplate())
prepend_route("api/plugins/#{ws.getId()}/:action/:id", {:controller => "api/#{ws.getId()}", :requirements => {:id => /.*/}})
end
-
- # Full Java web services
- ws_engine = Java::OrgSonarServerPlatform::Platform.component(Java::OrgSonarServerWs::WebServiceEngine.java_class)
- ws_engine.controllers().each do |controller|
- controller.actions.each do |action|
- if (!action.handler().java_kind_of?(Java::OrgSonarApiServerWs::RailsHandler))
- prepend_route("#{controller.path()}/#{action.key()}.:responseFormat/:id", {:controller => 'api/java_ws', :action => 'index', :wsaction => action.key(), :wspath => controller.path()})
- prepend_route("#{controller.path()}/#{action.key()}/:id", {:controller => 'api/java_ws', :action => 'index', :wsaction => action.key(), :wspath => controller.path()})
- if action.key()=='index'
- prepend_route("#{controller.path()}", {:controller => 'api/java_ws', :action => 'index', :wsaction => action.key(), :wspath => controller.path()})
- end
- end
- end
- end
end
end
end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/web.xml b/server/sonar-web/src/main/webapp/WEB-INF/web.xml
index d4402205359..bed9e8b5cec 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/web.xml
+++ b/server/sonar-web/src/main/webapp/WEB-INF/web.xml
@@ -60,6 +60,10 @@
<param-value>/images,/javascripts,/stylesheets</param-value>
</init-param>
</filter>
+ <filter>
+ <filter-name>RoutesFilter</filter-name>
+ <filter-class>org.sonar.server.platform.RoutesFilter</filter-class>
+ </filter>
<!-- order of execution is important -->
<filter-mapping>
@@ -67,6 +71,10 @@
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
+ <filter-name>RoutesFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+ <filter-mapping>
<filter-name>UserSessionFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>