1 package org.roller.presentation.velocity; 2 import java.io.IOException ; 3 import java.util.Date ; 4 5 import javax.servlet.ServletException ; 6 import javax.servlet.http.HttpServletRequest ; 7 import javax.servlet.http.HttpServletResponse ; 8 9 import org.apache.commons.logging.Log; 10 import org.apache.commons.logging.LogFactory; 11 import org.apache.velocity.Template; 12 import org.apache.velocity.context.Context; 13 import org.apache.velocity.servlet.VelocityServlet; 14 import org.roller.RollerException; 15 import org.roller.model.PlanetManager; 16 import org.roller.presentation.RollerRequest; 17 import org.roller.util.Utilities; 18 19 26 public class PlanetFeedServlet extends VelocityServlet 27 { 28 private static Log mLogger = 29 LogFactory.getFactory().getInstance(RollerRequest.class); 30 31 public Template handleRequest(HttpServletRequest request, 32 HttpServletResponse response, Context context) 33 { 34 RollerRequest rreq = null; 35 try 36 { 37 rreq = RollerRequest.getRollerRequest(request, getServletContext()); 38 } 39 catch (RollerException e) 40 { 41 if (mLogger.isDebugEnabled()) 43 { 44 mLogger.debug("RollerRequest threw Exception", e); 45 } 46 try 47 { 48 response.sendError(HttpServletResponse.SC_NOT_FOUND); 49 } 50 catch (IOException e1) 51 { 52 if (mLogger.isDebugEnabled()) 53 { 54 mLogger.debug("IOException sending error", e); 55 } 56 } 57 return null; 58 } 59 try 60 { 61 response.setContentType("application/rss+xml;charset=utf-8"); 62 PlanetManager planet = 63 rreq.getRoller().getPlanetManager(); 64 if (request.getParameter("group") != null) 65 { 66 context.put("group", 67 planet.getGroup(request.getParameter("group"))); 68 } 69 context.put("planet", planet); 70 context.put("date", new Date ()); 71 context.put("utilities", new Utilities()); 72 return getTemplate("planetrss.vm"); 73 } 74 catch (Exception e) 75 { 76 mLogger.error("ERROR in PlanetFeedServlet", e); 77 } 78 return null; 79 } 80 81 85 protected void error( HttpServletRequest req, HttpServletResponse res, 86 Exception e) throws ServletException , IOException 87 { 88 mLogger.warn("ERROR in PlanetFeedServlet",e); 89 } 90 } 91 92 | Popular Tags |