1 25 package org.snipsnap.net; 26 27 import org.snipsnap.app.Application; 28 import org.snipsnap.config.Configuration; 29 import org.snipsnap.container.Components; 30 import org.snipsnap.snip.Snip; 31 import org.snipsnap.snip.SnipSpace; 32 33 import javax.servlet.RequestDispatcher ; 34 import javax.servlet.ServletException ; 35 import javax.servlet.http.HttpServlet ; 36 import javax.servlet.http.HttpServletRequest ; 37 import javax.servlet.http.HttpServletResponse ; 38 import java.io.IOException ; 39 40 45 public class ThemeImageServlet extends HttpServlet { 46 47 public void doGet(HttpServletRequest request, HttpServletResponse response) 48 throws ServletException , IOException { 49 50 String fileName = request.getPathInfo(); 51 52 if (fileName != null && fileName.length() > 1) { 53 Configuration config = Application.get().getConfiguration(); 54 SnipSpace space = (SnipSpace)Components.getComponent(SnipSpace.class); 55 Snip themeSnip = space.load("SnipSnap/themes/"+config.getTheme()); 56 57 if(themeSnip != null) { 58 request.setAttribute(FileDownloadServlet.FILENAME, fileName.substring(1)); 59 request.setAttribute(FileDownloadServlet.SNIP, themeSnip); 60 RequestDispatcher dispatcher = 61 getServletContext().getNamedDispatcher("org.snipsnap.net.FileDownloadServlet"); 62 dispatcher.forward(request, response); 63 return; 64 } 65 } 66 response.sendError(HttpServletResponse.SC_NOT_FOUND); 67 } 68 } 69 | Popular Tags |