]> source.dussan.org Git - sonarqube.git/commitdiff
Revert "SONAR-11883 Remove redirection that was kept for old scanners"
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 3 Apr 2019 13:18:44 +0000 (15:18 +0200)
committerSonarTech <sonartech@sonarsource.com>
Wed, 3 Apr 2019 18:21:06 +0000 (20:21 +0200)
This reverts commit 91e2ea646539462d22d5064adf47af8b3fbd5705.

server/sonar-docs/src/pages/setup/upgrade-notes.md
server/sonar-server/src/main/java/org/sonar/server/platform/web/RedirectFilter.java
server/sonar-server/src/test/java/org/sonar/server/platform/web/RedirectFilterTest.java

index 92f75ff514fad7b971088a83adae699f62b2a10f..1f3e1c62ad4f5d95eae9a17faa54451fc8230221 100644 (file)
@@ -3,13 +3,6 @@ title: Release Upgrade Notes
 url: /setup/upgrade-notes/
 ---
 
-## Release 7.8 Upgrade Notes
-**Scanner version compatibility**
-Only the following scanner versions are compatible with SonarQube 7.8:
-* SonarQube Scanner CLI 2.9+
-* SonarQube Scanner Maven 3.3.0.603+
-* SonarQube Scanner Gradle 2.3+
-
 ## Release 7.7 Upgrade Notes  
 **Deprecated parameters dropped**  
 `sonar.language`, and  `sonar.profile`, both deprecated since 4.5, are dropped in this version as is `sonar.analysis.mode`, which as been deprecated since 6.6. These now-unrecognized parameters will simply be ignored, rather than failing analysis.
index 64a174666411433e0f154771ef71e1f1f432890e..1567b242a8977ad757e1118bfc61a09247da1863 100644 (file)
@@ -41,7 +41,10 @@ public class RedirectFilter implements Filter {
   private static final String EMPTY = "";
 
   private static final List<Redirect> REDIRECTS = ImmutableList.of(
-    newSimpleRedirect("/api", "/api/webservices/list"));
+    newSimpleRedirect("/api", "/api/webservices/list"),
+    new BatchRedirect(),
+    new BatchBootstrapRedirect(),
+    new ProfilesExportRedirect());
 
   @Override
   public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException {
@@ -97,6 +100,60 @@ public class RedirectFilter implements Filter {
     String apply(HttpServletRequest request);
   }
 
+  /**
+   * Old scanners were using /batch/file.jar url (see SCANNERAPI-167)
+   */
+  private static class BatchRedirect implements Redirect {
+
+    private static final String BATCH_WS = "/batch";
+
+    @Override
+    public boolean test(String path) {
+      return path.startsWith(BATCH_WS + "/") && path.endsWith(".jar");
+    }
+
+    @Override
+    public String apply(HttpServletRequest request) {
+      String path = extractPath(request);
+      return format("%s%s/file?name=%s", request.getContextPath(), BATCH_WS, path.replace(BATCH_WS + "/", EMPTY));
+    }
+  }
+
+  /**
+   * Old scanners were using /batch_bootstrap url (see SCANNERAPI-167)
+   */
+  private static class BatchBootstrapRedirect implements Redirect {
+
+    @Override
+    public boolean test(String path) {
+      return "/batch_bootstrap/index".equals(path);
+    }
+
+    @Override
+    public String apply(HttpServletRequest request) {
+      return format("%s%s/index", request.getContextPath(), "/batch");
+    }
+  }
+
+  /**
+   * Old scanners were using /profiles/export url (see SVS-130)
+   */
+  private static class ProfilesExportRedirect implements Redirect {
+
+    private static final String PROFILES_EXPORT = "/profiles/export";
+    private static final String API_QUALITY_PROFILE_EXPORT = "/api/qualityprofiles/export";
+
+    @Override
+    public boolean test(String path) {
+      return PROFILES_EXPORT.equals(path);
+    }
+
+    @Override
+    public String apply(HttpServletRequest request) {
+      return format("%s%s?%s", request.getContextPath(), API_QUALITY_PROFILE_EXPORT, request.getQueryString());
+    }
+  }
+
   private static String extractPath(HttpServletRequest request) {
     return sanitizePath(request.getRequestURI().replaceFirst(request.getContextPath(), EMPTY));
   }
index 255e97509ccf9cfb88d188e39ef5c614b3145768..4396df7dad3447b305147f36efa038d17858ede0 100644 (file)
@@ -37,11 +37,11 @@ import static org.mockito.Mockito.when;
 
 public class RedirectFilterTest {
 
-  private HttpServletRequest request = mock(HttpServletRequest.class);
-  private HttpServletResponse response = mock(HttpServletResponse.class);
-  private FilterChain chain = mock(FilterChain.class);
+  HttpServletRequest request = mock(HttpServletRequest.class);
+  HttpServletResponse response = mock(HttpServletResponse.class);
+  FilterChain chain = mock(FilterChain.class);
 
-  private RedirectFilter underTest = new RedirectFilter();
+  RedirectFilter underTest = new RedirectFilter();
 
   @Before
   public void setUp() throws Exception {
@@ -54,6 +54,23 @@ public class RedirectFilterTest {
     verifyRedirection("/api/", null, "/sonarqube/api/webservices/list");
   }
 
+  @Test
+  public void send_redirect_when_url_contains_batch_with_jar() throws Exception {
+    verifyRedirection("/batch/file.jar", null, "/sonarqube/batch/file?name=file.jar");
+  }
+
+  @Test
+  public void send_redirect_when_url_contains_batch_bootstrap() throws Exception {
+    verifyRedirection("/batch_bootstrap/index", null, "/sonarqube/batch/index");
+    verifyRedirection("/batch_bootstrap/index/", null, "/sonarqube/batch/index");
+  }
+
+  @Test
+  public void send_redirect_when_url_contains_profiles_export() throws Exception {
+    verifyRedirection("/profiles/export", "format=pmd", "/sonarqube/api/qualityprofiles/export?format=pmd");
+    verifyRedirection("/profiles/export/", "format=pmd", "/sonarqube/api/qualityprofiles/export?format=pmd");
+  }
+
   @Test
   public void does_not_redirect_and_execute_remaining_filter_on_unknown_path() throws Exception {
     verifyNoRedirection("/api/issues/search", null);