diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-02-01 04:33:28 +0300 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-02-01 14:59:49 +0300 |
commit | 56e588b0e5be949fbd7c64b7e170d5947d7727af (patch) | |
tree | c7149f3ccb4dd943294c0e1f64007ca0a498c9d6 /sonar-server | |
parent | 936f7f5f75e4acd3a58e12f67e69d9e24290c91c (diff) | |
download | sonarqube-56e588b0e5be949fbd7c64b7e170d5947d7727af.tar.gz sonarqube-56e588b0e5be949fbd7c64b7e170d5947d7727af.zip |
Disable downloading for certain files from BatchResourcesServlet
Diffstat (limited to 'sonar-server')
-rw-r--r-- | sonar-server/src/main/java/org/sonar/server/plugins/BatchResourcesServlet.java | 19 | ||||
-rw-r--r-- | sonar-server/src/test/java/org/sonar/server/plugins/BatchResourcesServletTest.java | 16 |
2 files changed, 34 insertions, 1 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/BatchResourcesServlet.java b/sonar-server/src/main/java/org/sonar/server/plugins/BatchResourcesServlet.java index e8195a55ca4..b47258bb802 100644 --- a/sonar-server/src/main/java/org/sonar/server/plugins/BatchResourcesServlet.java +++ b/sonar-server/src/main/java/org/sonar/server/plugins/BatchResourcesServlet.java @@ -87,12 +87,29 @@ public class BatchResourcesServlet extends HttpServlet { for (Object obj : paths) { String path = (String) obj; if (StringUtils.endsWith(path, ".jar")) { - libs.add(StringUtils.removeStart(path, "/WEB-INF/lib/")); + String filename = StringUtils.removeStart(path, "/WEB-INF/lib/"); + if (!isIgnored(filename)) { + libs.add(filename); + } } } return libs; } + private static String[] IGNORE = { "derby", "jtds", "mysql", "postgresql", "jruby", "jfreechart", "eastwood", "jetty" }; + + /** + * Dirty hack to disable downloading for certain files. + */ + static boolean isIgnored(String filename) { + for (String prefix : IGNORE) { + if (StringUtils.startsWith(filename, prefix)) { + return true; + } + } + return false; + } + /** * @return part of request URL after servlet path */ diff --git a/sonar-server/src/test/java/org/sonar/server/plugins/BatchResourcesServletTest.java b/sonar-server/src/test/java/org/sonar/server/plugins/BatchResourcesServletTest.java index d5bf6699540..192854a08d5 100644 --- a/sonar-server/src/test/java/org/sonar/server/plugins/BatchResourcesServletTest.java +++ b/sonar-server/src/test/java/org/sonar/server/plugins/BatchResourcesServletTest.java @@ -75,4 +75,20 @@ public class BatchResourcesServletTest { assertThat(servlet.getLibs().size(), is(1)); assertThat(servlet.getLibs().get(0), is("sonar-core-2.6.jar")); } + + @Test + public void shouldIgnore() { + assertThat(BatchResourcesServlet.isIgnored("sonar-batch-2.6-SNAPSHOT.jar"), is(false)); + assertThat(BatchResourcesServlet.isIgnored("derby-10.6.1.0.jar"), is(true)); + assertThat(BatchResourcesServlet.isIgnored("derbyclient-10.6.1.0.jar"), is(true)); + assertThat(BatchResourcesServlet.isIgnored("derbynet-10.6.1.0.jar"), is(true)); + assertThat(BatchResourcesServlet.isIgnored("mysql-connector-java-5.1.13.jar"), is(true)); + assertThat(BatchResourcesServlet.isIgnored("postgresql-9.0-801.jdbc3.jar"), is(true)); + assertThat(BatchResourcesServlet.isIgnored("jtds-1.2.4.jar"), is(true)); + assertThat(BatchResourcesServlet.isIgnored("jfreechart-1.0.9.jar"), is(true)); + assertThat(BatchResourcesServlet.isIgnored("eastwood-1.1.0.jar"), is(true)); + assertThat(BatchResourcesServlet.isIgnored("jetty-util-6.1.24.jar"), is(true)); + assertThat(BatchResourcesServlet.isIgnored("jruby-complete-1.5.6.jar"), is(true)); + assertThat(BatchResourcesServlet.isIgnored("jruby-rack-1.0.5.jar"), is(true)); + } } |