/** Creates {@link HtmlStaplerBundlesManager} instance. */ protected HtmlStaplerBundlesManager createBundleManager( ServletContext servletContext, Strategy strategy) { String webRoot = servletContext.getRealPath(StringPool.EMPTY); String contextPath = ServletUtil.getContextPath(servletContext); return new HtmlStaplerBundlesManager(contextPath, webRoot, strategy); }
/** * Checks if request if multi-part and parse it. If request is not multi-part it copies all * parameters, to make usage the same in both cases. * * @see MultipartRequestWrapper */ public void parseRequest() throws IOException { if (ServletUtil.isMultipartRequest(request) == true) { parseRequestStream(request.getInputStream(), characterEncoding); } else { Enumeration names = request.getParameterNames(); while (names.hasMoreElements()) { String paramName = (String) names.nextElement(); String[] values = request.getParameterValues(paramName); putParameters(paramName, values); } } }
@Override protected boolean processActionPath( HttpServletRequest servletRequest, HttpServletResponse servletResponse, String actionPath) throws IOException { String bundlePath = '/' + bundlesManager.getStaplerPath() + '/'; if (actionPath.startsWith(bundlePath) == false) { return false; } String bundleId = actionPath.substring(bundlePath.length()); File file = bundlesManager.lookupBundleFile(bundleId); if (log.isDebugEnabled()) { log.debug("bundle: " + bundleId); } int ndx = bundleId.lastIndexOf('.'); String extension = bundleId.substring(ndx + 1); String contentType = MimeTypes.getMimeType(extension); servletResponse.setContentType(contentType); if (useGzip && ServletUtil.isGzipSupported(servletRequest)) { file = bundlesManager.lookupGzipBundleFile(file); servletResponse.setHeader("Content-Encoding", "gzip"); } if (file.exists() == false) { throw new IOException("bundle not found: " + bundleId); } servletResponse.setHeader("Content-Length", String.valueOf(file.length())); servletResponse.setHeader("Last-Modified", TimeUtil.formatHttpDate(file.lastModified())); if (cacheMaxAge > 0) { servletResponse.setHeader("Cache-Control", "max-age=" + cacheMaxAge); } sendBundleFile(servletResponse, file); return true; }