You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ag...@apache.org on 2005/12/06 01:03:20 UTC

svn commit: r354234 - /incubator/roller/trunk/src/org/roller/presentation/velocity/FlavorServlet.java

Author: agilliland
Date: Mon Dec  5 16:03:17 2005
New Revision: 354234

URL: http://svn.apache.org/viewcvs?rev=354234&view=rev
Log:
updated code formating.


Modified:
    incubator/roller/trunk/src/org/roller/presentation/velocity/FlavorServlet.java

Modified: incubator/roller/trunk/src/org/roller/presentation/velocity/FlavorServlet.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/velocity/FlavorServlet.java?rev=354234&r1=354233&r2=354234&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/velocity/FlavorServlet.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/velocity/FlavorServlet.java Mon Dec  5 16:03:17 2005
@@ -22,78 +22,69 @@
 
 /////////////////////////////////////////////////////////////////////////////
 /**
-  * <p>Responsible for rendering RSS feeds and other "flavors" of output for a
-  * weblog.</p>
-  *
-  * <p>If Servlet is mapped to <code>/rss</code> and user has defined
-  * an RSS override page (i.e. a page named "_rss"), then that Velocity
-  * template will be used for rendering.</p>
-  *
-  * <p>If there is a request parameter named "flavor", then the Velocity
-  * template specified by that parameter will be used for rendering. For
-  * example if the flavor is "rss092" then the template at classpath
-  * "/flavors/rss092.vm" will be used for rendering.</p>
-  *
-  * <p>Otherwise, the template /flavors/rss.vm" will be used for rendering.</p>
-  *
-  * <p>Assumes that If-Modified-Since has already been handled.</p>
-  *
-  * @author David M Johnson
-  *
-  * @web.servlet name="RssServlet"
-  * @web.servlet-mapping url-pattern="/rss/*"
-  * @web.servlet-mapping url-pattern="/atom/*"
-  * @web.servlet-mapping url-pattern="/flavor/*"
-  */
-public class FlavorServlet extends VelocityServlet
-{
+ * <p>Responsible for rendering RSS feeds and other "flavors" of output for a
+ * weblog.</p>
+ *
+ * <p>If Servlet is mapped to <code>/rss</code> and user has defined
+ * an RSS override page (i.e. a page named "_rss"), then that Velocity
+ * template will be used for rendering.</p>
+ *
+ * <p>If there is a request parameter named "flavor", then the Velocity
+ * template specified by that parameter will be used for rendering. For
+ * example if the flavor is "rss092" then the template at classpath
+ * "/flavors/rss092.vm" will be used for rendering.</p>
+ *
+ * <p>Otherwise, the template /flavors/rss.vm" will be used for rendering.</p>
+ *
+ * <p>Assumes that If-Modified-Since has already been handled.</p>
+ *
+ * @author David M Johnson
+ *
+ * @web.servlet name="RssServlet"
+ * @web.servlet-mapping url-pattern="/rss/*"
+ * @web.servlet-mapping url-pattern="/atom/*"
+ * @web.servlet-mapping url-pattern="/flavor/*"
+ */
+public class FlavorServlet extends VelocityServlet {
     static final long serialVersionUID = -2720532269434186051L;
     
     private static Log mLogger = LogFactory.getLog(FlavorServlet.class);
     
     public Template handleRequest(HttpServletRequest request,
-                                  HttpServletResponse response, Context ctx)
-    {
+            HttpServletResponse response, Context ctx) {
+        
         RollerRequest rreq = null;
-        try
-        {
+        
+        try {
             rreq = RollerRequest.getRollerRequest(request,getServletContext());
             
-            // This is an ugly hack to fix the following bug: 
+            // This is an ugly hack to fix the following bug:
             // ROL-547: "Site wide RSS feed is your own if you are logged in"
-            String[] pathInfo = StringUtils.split(rreq.getPathInfo(),"/"); 
-            if (pathInfo.length < 1) 
-            {
+            String[] pathInfo = StringUtils.split(rreq.getPathInfo(),"/");
+            if (pathInfo.length < 1) {
                 // If website not specified in URL, set it to null
                 rreq.setWebsite(null);
             }
-        }
-        catch (RollerException e)
-        {
+        } catch (RollerException e) {
             // An error initializing the request is considered to be a 404
-            if (mLogger.isDebugEnabled())
-            {
+            if (mLogger.isDebugEnabled()) {
                 mLogger.debug("RollerRequest threw Exception", e);
             }
-            try
-            {
+            try {
                 response.sendError(HttpServletResponse.SC_NOT_FOUND);
-            }
-            catch (IOException e1)
-            {
-                if (mLogger.isDebugEnabled())
-                {
+            } catch (IOException e1) {
+                if (mLogger.isDebugEnabled()) {
                     mLogger.debug("IOException sending error", e);
                 }
             }
             return null;
         }
-        try
-        {
+        
+        try {
             // Needed to init request attributes, etc.
             PageContext pageContext =
-                JspFactory.getDefaultFactory().getPageContext(
-                this, request,  response, "", true, 8192, true);
+                    JspFactory.getDefaultFactory().getPageContext(
+                    this, request,  response, "", true, 8192, true);
             rreq.setPageContext(pageContext);
             
             // get update time before loading context
@@ -113,54 +104,46 @@
             }
             
             ContextLoader.setupContext(ctx, rreq, response);
-
+            
             final String useTemplate;
             PageModel pageModel = (PageModel)ctx.get("pageModel");
-            if (request.getServletPath().endsWith("rss"))
-            {
-                if (pageModel.getPageByName("_rss") != null) 
+            if (request.getServletPath().endsWith("rss")) {
+                if (pageModel.getPageByName("_rss") != null)
                     // If the request specified the "/rss" mapping and the
                     // user has defined an RSS override page, we will use that.
                     useTemplate = pageModel.getPageByName("_rss").getId();
                 else
                     useTemplate = "/flavors/rss.vm";
-            }
-            else if (request.getServletPath().endsWith("atom"))
-            {
-                if (pageModel.getPageByName("_atom") != null) 
+            } else if (request.getServletPath().endsWith("atom")) {
+                if (pageModel.getPageByName("_atom") != null)
                     // If the request specified the "/atom" mapping and the
                     // user has defined an Atom override page, we will use that.
                     useTemplate = pageModel.getPageByName("_atom").getId();
                 else
                     useTemplate = "/flavors/atom.vm";
-            }
-            else if (request.getParameter("flavor") != null)
-            {
+            } else if (request.getParameter("flavor") != null) {
                 // If request specifies a "flavor" then use that.
                 String flavor = request.getParameter("flavor");
                 useTemplate = "/flavors/" + flavor + ".vm";
-            }
-            else
-            {
+            } else {
                 // Fall through to default RSS page template.
                 useTemplate = "/flavors/rss.vm";
             }
+            
             return getTemplate(useTemplate);
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             mLogger.error("ERROR in RssServlet", e);
         }
+        
         return null;
     }
-
+    
     //------------------------------------------------------------------------
     /**
      * Handle error in Velocity processing.
      */
     protected void error( HttpServletRequest req, HttpServletResponse res,
-        Exception e) throws ServletException, IOException
-    {
+            Exception e) throws ServletException, IOException {
         mLogger.warn("ERROR in FlavorServlet",e);
     }
 }