From: Julien Lancelot Date: Tue, 24 Jan 2017 07:58:17 +0000 (+0100) Subject: SONAR-8684 Remove RailsHandler X-Git-Tag: 6.3-RC1~413 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8f754a77bdd6555c46a4a8b4a524ad194c734ab5;p=sonarqube.git SONAR-8684 Remove RailsHandler --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/ws/WebServiceFilter.java b/server/sonar-server/src/main/java/org/sonar/server/ws/WebServiceFilter.java index 7d1f78da028..e0a9aeb9ebc 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/ws/WebServiceFilter.java +++ b/server/sonar-server/src/main/java/org/sonar/server/ws/WebServiceFilter.java @@ -28,7 +28,6 @@ import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.sonar.api.server.ws.RailsHandler; import org.sonar.api.server.ws.WebService; import org.sonar.api.web.ServletFilter; @@ -51,8 +50,8 @@ public class WebServiceFilter extends ServletFilter { webServiceEngine.controllers() .forEach(controller -> controller.actions() .forEach(action -> { - // Rails, Rest and servlet filter WS should not be executed by the web service engine - if (isJavaWs(controller, action)) { + // Rest and servlet filter WS should not be executed by the web service engine + if (shouldBeExecutedByWebServiceEngine(controller, action)) { includeUrls.add("/" + controller.path() + "/*"); } else { excludeUrls.add("/" + action.path() + "*"); @@ -87,9 +86,8 @@ public class WebServiceFilter extends ServletFilter { // Nothing to do } - private static boolean isJavaWs(WebService.Controller controller, WebService.Action action) { - return !(action.handler() instanceof RailsHandler) - && !(action.handler() instanceof ServletFilterHandler) + private static boolean shouldBeExecutedByWebServiceEngine(WebService.Controller controller, WebService.Action action) { + return !(action.handler() instanceof ServletFilterHandler) && !controller.path().equals(CONTROLLER_PROPERTIES); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/ws/WebServiceFilterTest.java b/server/sonar-server/src/test/java/org/sonar/server/ws/WebServiceFilterTest.java index 0871dad3cbc..de0eaeafa1f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/ws/WebServiceFilterTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/ws/WebServiceFilterTest.java @@ -30,7 +30,6 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.sonar.api.server.ws.RailsHandler; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.RequestHandler; import org.sonar.api.server.ws.Response; @@ -68,9 +67,7 @@ public class WebServiceFilterTest { initWebServiceEngine( newWsUrl("api/issues", "search"), newWsUrl("batch", "index"), - newWsUrl("api/authentication", "login").setHandler(ServletFilterHandler.INSTANCE), - newWsUrl("api/resources", "index").setHandler(RailsHandler.INSTANCE), - newWsUrl("api/issues", "deprecatedSearch").setHandler(RailsHandler.INSTANCE)); + newWsUrl("api/authentication", "login").setHandler(ServletFilterHandler.INSTANCE)); assertThat(underTest.doGetPattern().matches("/api/issues/search")).isTrue(); assertThat(underTest.doGetPattern().matches("/api/issues/search.protobuf")).isTrue(); @@ -78,7 +75,6 @@ public class WebServiceFilterTest { assertThat(underTest.doGetPattern().matches("/api/resources/index")).isFalse(); assertThat(underTest.doGetPattern().matches("/api/authentication/login")).isFalse(); - assertThat(underTest.doGetPattern().matches("/api/issues/deprecatedSearch")).isFalse(); assertThat(underTest.doGetPattern().matches("/api/properties")).isFalse(); assertThat(underTest.doGetPattern().matches("/foo")).isFalse(); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/RailsHandler.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/RailsHandler.java deleted file mode 100644 index 63ce01080fb..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/RailsHandler.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.api.server.ws; - -/** - * Used to declare web services that are still implemented in Ruby on Rails. - * - * @since 4.4 - */ -public class RailsHandler implements RequestHandler { - - public static final RequestHandler INSTANCE = new RailsHandler(); - - private RailsHandler() { - // Nothing - } - - @Override - public void handle(Request request, Response response) { - throw new UnsupportedOperationException("This web service is implemented in rails"); - } - -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/RailsHandlerTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/RailsHandlerTest.java deleted file mode 100644 index 6c6a44a169a..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/server/ws/RailsHandlerTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.api.server.ws; - -import org.junit.Test; - -public class RailsHandlerTest { - - @Test(expected = UnsupportedOperationException.class) - public void throw_unsupported_operation_exception() throws Exception { - RailsHandler.INSTANCE.handle(null, null); - } -}