Fix JS resource loading for JsPlugin type (was returning 404)

Because of the change Ie8d9a9ac1 WrappedRequest
getPathInfo() does not include anymore the plugin
name. This broke the JsPlugin support as any attempt
to serve the actual .js file was not able to locate
the plugin name in the path info.

We need now to get the entire request-uri and assert
the format /plugins/<plugin>/static/<plugins.js>

Change-Id: I5d6d434453824d2539a364a2d6c69b687edbbee0
This commit is contained in:
Luca Milanesio 2014-07-09 00:08:56 +01:00 committed by David Pursehouse
parent 7953f040da
commit 0a3b513050

View File

@ -584,7 +584,7 @@ class HttpPluginServlet extends HttpServlet
private void sendJsPlugin(Plugin plugin, ResourceKey key, private void sendJsPlugin(Plugin plugin, ResourceKey key,
HttpServletRequest req, HttpServletResponse res) throws IOException { HttpServletRequest req, HttpServletResponse res) throws IOException {
File pluginFile = plugin.getSrcFile(); File pluginFile = plugin.getSrcFile();
if (req.getPathInfo().equals(getJsPluginPath(plugin)) && pluginFile.exists()) { if (req.getRequestURI().equals(getJsPluginPath(plugin)) && pluginFile.exists()) {
res.setHeader("Content-Length", Long.toString(pluginFile.length())); res.setHeader("Content-Length", Long.toString(pluginFile.length()));
res.setContentType("application/javascript"); res.setContentType("application/javascript");
writeToResponse(res, new FileInputStream(pluginFile)); writeToResponse(res, new FileInputStream(pluginFile));
@ -595,7 +595,7 @@ class HttpPluginServlet extends HttpServlet
} }
private static String getJsPluginPath(Plugin plugin) { private static String getJsPluginPath(Plugin plugin) {
return String.format("%s/static/%s", plugin.getName(), plugin.getSrcFile() return String.format("/plugins/%s/static/%s", plugin.getName(), plugin.getSrcFile()
.getName()); .getName());
} }