From 22b483458fdd132efe8a717624ea4b47ad37bba6 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Mon, 27 Jun 2016 11:07:27 +0200 Subject: [PATCH] SONAR-7759 Java WS are not executed by Rails --- .../java/it/component/ProjectSearchTest.java | 8 +- .../sonar/server/app/TomcatConnectors.java | 8 +- .../org/sonar/server/app/TomcatContexts.java | 7 +- .../sonar/server/platform/RoutesFilter.java | 68 +++++++ .../platformlevel/PlatformLevel4.java | 2 + .../platformlevel/PlatformLevelSafeMode.java | 4 +- .../org/sonar/server/ws/ServletRequest.java | 32 ++- .../org/sonar/server/ws/WebServiceFilter.java | 144 ++++++++++++++ .../server/app/TomcatConnectorsTest.java | 29 ++- .../server/platform/RoutesFilterTest.java | 87 ++++++++ .../sonar/server/ws/ServletRequestTest.java | 72 ++++--- .../sonar/server/ws/WebServiceFilterTest.java | 186 ++++++++++++++++++ .../app/controllers/api/java_ws_controller.rb | 33 +--- .../src/main/webapp/WEB-INF/config/routes.rb | 5 - .../webapp/WEB-INF/lib/java_ws_routing.rb | 14 -- .../sonar-web/src/main/webapp/WEB-INF/web.xml | 8 + 16 files changed, 586 insertions(+), 121 deletions(-) create mode 100644 server/sonar-server/src/main/java/org/sonar/server/platform/RoutesFilter.java create mode 100644 server/sonar-server/src/main/java/org/sonar/server/ws/WebServiceFilter.java create mode 100644 server/sonar-server/src/test/java/org/sonar/server/platform/RoutesFilterTest.java create mode 100644 server/sonar-server/src/test/java/org/sonar/server/ws/WebServiceFilterTest.java diff --git a/it/it-tests/src/test/java/it/component/ProjectSearchTest.java b/it/it-tests/src/test/java/it/component/ProjectSearchTest.java index 0bd21727022..01827629ba1 100644 --- a/it/it-tests/src/test/java/it/component/ProjectSearchTest.java +++ b/it/it-tests/src/test/java/it/component/ProjectSearchTest.java @@ -19,6 +19,9 @@ */ package it.component; +import static org.assertj.core.api.Assertions.assertThat; +import static util.ItUtils.projectDir; + import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarRunner; import it.Category4Suite; @@ -35,9 +38,6 @@ import org.junit.Test; import org.junit.experimental.categories.Category; import util.QaOnly; -import static org.assertj.core.api.Assertions.assertThat; -import static util.ItUtils.projectDir; - @Category(QaOnly.class) public class ProjectSearchTest { @@ -58,7 +58,7 @@ public class ProjectSearchTest { SonarRunner build = SonarRunner.create(projectDir("shared/xoo-sample")); orchestrator.executeBuild(build); - String url = orchestrator.getServer().getUrl() + "/api/projects?key=sample&versions=true"; + String url = orchestrator.getServer().getUrl() + "/api/projects/index?key=sample&versions=true"; HttpClient httpclient = new DefaultHttpClient(); try { HttpGet get = new HttpGet(url); diff --git a/server/sonar-server/src/main/java/org/sonar/server/app/TomcatConnectors.java b/server/sonar-server/src/main/java/org/sonar/server/app/TomcatConnectors.java index bcf14fed9ec..986f2a8a4f2 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/app/TomcatConnectors.java +++ b/server/sonar-server/src/main/java/org/sonar/server/app/TomcatConnectors.java @@ -19,6 +19,9 @@ */ package org.sonar.server.app; +import static com.google.common.collect.FluentIterable.from; +import static java.util.Arrays.asList; + import com.google.common.base.Predicates; import java.util.HashSet; import java.util.List; @@ -29,9 +32,6 @@ import org.apache.catalina.connector.Connector; import org.apache.catalina.startup.Tomcat; import org.sonar.process.Props; -import static com.google.common.collect.FluentIterable.from; -import static java.util.Arrays.asList; - /** * Configuration of Tomcat connectors */ @@ -41,6 +41,7 @@ class TomcatConnectors { public static final String HTTP_PROTOCOL = "HTTP/1.1"; public static final String AJP_PROTOCOL = "AJP/1.3"; public static final int MAX_HTTP_HEADER_SIZE_BYTES = 48 * 1024; + private static final int MAX_POST_SIZE = -1; private TomcatConnectors() { // only static stuff @@ -82,6 +83,7 @@ class TomcatConnectors { connector = newConnector(props, HTTP_PROTOCOL, "http"); configureMaxHttpHeaderSize(connector); connector.setPort(port); + connector.setMaxPostSize(MAX_POST_SIZE); } return connector; } diff --git a/server/sonar-server/src/main/java/org/sonar/server/app/TomcatContexts.java b/server/sonar-server/src/main/java/org/sonar/server/app/TomcatContexts.java index abd0dd2df4e..56dcf66f5ff 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/app/TomcatContexts.java +++ b/server/sonar-server/src/main/java/org/sonar/server/app/TomcatContexts.java @@ -19,6 +19,9 @@ */ package org.sonar.server.app; +import static java.lang.String.format; +import static org.apache.commons.lang.StringUtils.isEmpty; + import com.google.common.annotations.VisibleForTesting; import java.io.File; import java.io.IOException; @@ -33,9 +36,6 @@ import org.sonar.api.utils.log.Loggers; import org.sonar.process.ProcessProperties; import org.sonar.process.Props; -import static java.lang.String.format; -import static org.apache.commons.lang.StringUtils.isEmpty; - /** * Configures Tomcat contexts: *