private DownloadStrategy findStrategy(String url) { for (final DownloadStrategy downloadStrategy : getDownloadStrategies()) { if (downloadStrategy.matches(url)) { return downloadStrategy; } } return null; } }
/** * @return content type for given path. */ public String getContentType(String path) { return contentTypeResolver.getContentType(path); }
/** * Sets caching headers with private cache control. Applications should call this method from urlrewrite.xml to * decorate urls like <code>/sp/{build num}/.../_/resourceurl</code>. * * @see <a href="http://tuckey.org/urlrewrite/manual/2.6/">http://tuckey.org/urlrewrite/manual/2.6/</a> */ public static void addPrivateCachingHeaders(final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse) { addCachingHeaders(httpServletRequest, httpServletResponse, "private"); } }
public void serveFile(final HttpServletRequest request, final HttpServletResponse response) throws DownloadException { for (final DownloadStrategy strategy : strategies.values()) { if (strategy.matches(request.getRequestURI().toLowerCase())) { strategy.serveFile(request, response); return; } } throw new DownloadException( "Found plugin download strategy during matching but not when trying to serve. Enable debug logging for more information."); }
public String getContentType() { return originalResource.getContentType(); } }
public boolean isResourceModified(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { return originalResource.isResourceModified(httpServletRequest, httpServletResponse); }
public void streamResource(final OutputStream out) throws DownloadException { final InputStream resourceStream = getResourceAsStreamViaMinificationStrategy(); if (resourceStream == null) { log.warn("Resource not found: {}", this); return; } streamResource(resourceStream, out); }
@Override public SourceMap writeTo(OutputStream out, boolean isSourceMapEnabled) { try { downloadableResource.streamResource(out); } catch (DownloadException e) { Support.LOGGER.debug("Error while serving file: DownloadException"); } return sourceMap; } };
@Override public String toString() { final String pluginKey = plugin != null ? plugin.getKey() : ""; return "Resource: " + pluginKey + " " + getLocation() + " (" + getContentType() + ")"; }
@Override public void addServlet(Plugin plugin, String servletName, HttpServlet servlet, ServletContext servletContext) { delegateModuleManager.addServlet(plugin, servletName, servlet, servletContext); }
@Override public HttpServlet getServlet(String path, ServletConfig servletConfig) throws ServletException { return delegateModuleManager.getServlet(path, servletConfig); }
@Override public void removeServletModule(ServletModuleDescriptor descriptor) { delegateModuleManager.removeServletModule(descriptor); }
@Override public void addServletModule(ServletModuleDescriptor descriptor) { delegateModuleManager.addServletModule(descriptor); }
@Override protected InputStream getResourceAsStream(final String resourceLocation) { String fixedResourceLocation = fixResourceLocation(resourceLocation); return servletContext.getResourceAsStream(fixedResourceLocation); }
@Override public Iterable<Filter> getFilters(FilterLocation location, String pathInfo, FilterConfig filterConfig, DispatcherType dispatcherType) { return delegateModuleManager.getFilters(location, StringUtils.removeStart(pathInfo, path), filterConfig, dispatcherType); }
public String getContentType() { return originalResource.getContentType(); }
public boolean isResourceModified(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { return originalResource.isResourceModified(httpServletRequest, httpServletResponse); }
/** * Sets caching headers with public cache control. Applications should call this method from urlrewrite.xml to * decorate urls like <code>/s/{build num}/.../_/resourceurl</code>. * * @see <a href="http://tuckey.org/urlrewrite/manual/2.6/">http://tuckey.org/urlrewrite/manual/2.6/</a> */ public static void addPublicCachingHeaders(final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse) { addCachingHeaders(httpServletRequest, httpServletResponse, "public"); }
@Override public void addServlet(Plugin plugin, String servletName, String className) { delegateModuleManager.addServlet(plugin, servletName, className); }
/** * Adapter, turns DownloadableResource into Content. */ public static Content asContent(final DownloadableResource downloadableResource, final SourceMap sourceMap, boolean isTransformed) { return new ContentImpl(downloadableResource.getContentType(), isTransformed) { @Override public SourceMap writeTo(OutputStream out, boolean isSourceMapEnabled) { try { downloadableResource.streamResource(out); } catch (DownloadException e) { Support.LOGGER.debug("Error while serving file: DownloadException"); } return sourceMap; } }; }