roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r574952 - /roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/PlanetFeedServlet.java
Date Wed, 12 Sep 2007 13:23:39 GMT
Author: snoopdave
Date: Wed Sep 12 06:23:39 2007
New Revision: 574952

URL: http://svn.apache.org/viewvc?rev=574952&view=rev
Log:
Code formatting and import cleanup only

Modified:
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/PlanetFeedServlet.java

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/PlanetFeedServlet.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/PlanetFeedServlet.java?rev=574952&r1=574951&r2=574952&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/PlanetFeedServlet.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/PlanetFeedServlet.java
Wed Sep 12 06:23:39 2007
@@ -28,12 +28,10 @@
 import javax.servlet.http.HttpServletResponse;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
 import org.apache.roller.planet.business.PlanetFactory;
 import org.apache.roller.planet.business.PlanetManager;
 import org.apache.roller.planet.pojos.Planet;
-import org.apache.roller.planet.pojos.PlanetGroup;
 import org.apache.roller.weblogger.pojos.StaticTemplate;
 import org.apache.roller.weblogger.pojos.Template;
 import org.apache.roller.weblogger.ui.rendering.Renderer;
@@ -52,35 +50,31 @@
  * @web.servlet-mapping url-pattern="/planetrss/*"
  */
 public class PlanetFeedServlet extends HttpServlet {
-    
+
     private static Log log = LogFactory.getLog(PlanetFeedServlet.class);
-    
     private PlanetCache planetCache = null;
-    
-    
+
     /**
      * Init method for this servlet
      */
     public void init(ServletConfig servletConfig) throws ServletException {
-        
+
         super.init(servletConfig);
-        
+
         log.info("Initializing PlanetRssServlet");
-        
+
         this.planetCache = PlanetCache.getInstance();
     }
-    
-    
+
     /**
      * Handle GET requests for weblog pages.
      */
-    public void doGet(HttpServletRequest request, HttpServletResponse response) 
-            throws ServletException, IOException {
-        
+    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
+
         log.debug("Entering");
-        
+
         PlanetManager planet = PlanetFactory.getPlanet().getPlanetManager();
-        
+
         PlanetRequest planetRequest = null;
         try {
             planetRequest = new PlanetRequest(request);
@@ -90,22 +84,21 @@
             response.sendError(HttpServletResponse.SC_NOT_FOUND);
             return;
         }
-        
+
         // figure planet last modified date
         Date lastModified = planetCache.getLastModified();
-        
+
         // Respond with 304 Not Modified if it is not modified.
-        if (ModDateHeaderUtil.respondIfNotModified(request,response,lastModified.getTime()))
{
+        if (ModDateHeaderUtil.respondIfNotModified(request, response, lastModified.getTime()))
{
             return;
         }
 
         // set content type
         String accepts = request.getHeader("Accept");
         String userAgent = request.getHeader("User-Agent");
-        if (accepts != null && userAgent != null 
-            && accepts.indexOf("*/*") != -1 && userAgent.startsWith("Mozilla"))
{
-            // client is a browser and now that we offer styled feeds we want 
-            // browsers to load the page rather than popping up the download 
+        if (accepts != null && userAgent != null && accepts.indexOf("*/*")
!= -1 && userAgent.startsWith("Mozilla")) {
+            // client is a browser and now that we offer styled feeds we want
+            // browsers to load the page rather than popping up the download
             // dialog, so we provide a content-type that browsers will display
             response.setContentType("text/xml");
         } else {
@@ -113,19 +106,18 @@
         }
 
         // set last-modified date
-        ModDateHeaderUtil.setLastModifiedHeader(response,lastModified.getTime());
+        ModDateHeaderUtil.setLastModifiedHeader(response, lastModified.getTime());
 
         // cached content checking
-        String cacheKey = PlanetCache.CACHE_ID+":"+this.generateKey(planetRequest);
+        String cacheKey = PlanetCache.CACHE_ID + ":" + this.generateKey(planetRequest);
         CachedContent entry = (CachedContent) planetCache.get(cacheKey);
-        if(entry != null) {
+        if (entry != null) {
             response.setContentLength(entry.getContent().length);
             response.getOutputStream().write(entry.getContent());
             return;
-            
         }
-        
-        
+
+
         // looks like we need to render content
         HashMap model = new HashMap();
         try {
@@ -140,78 +132,84 @@
             model.put("absoluteSite", WebloggerRuntimeConfig.getAbsoluteContextURL());
             model.put("feedStyle", new Boolean(WebloggerRuntimeConfig.getBooleanProperty("site.newsfeeds.styledFeeds")));
 
-            int numEntries =
-                    WebloggerRuntimeConfig.getIntProperty("site.newsfeeds.defaultEntries");
+            int numEntries = WebloggerRuntimeConfig.getIntProperty("site.newsfeeds.defaultEntries");
             int entryCount = numEntries;
             String sCount = request.getParameter("count");
-            if (sCount!=null) {
+            if (sCount != null) {
                 try {
                     entryCount = Integer.parseInt(sCount);
                 } catch (NumberFormatException e) {
                     log.warn("Improperly formatted count parameter");
                 }
-                if ( entryCount > numEntries ) entryCount = numEntries;
-                if ( entryCount < 0 ) entryCount = 0;
+                if (entryCount > numEntries) {
+                    entryCount = numEntries;
+                }
+                if (entryCount < 0) {
+                    entryCount = 0;
+                }
             }
             model.put("entryCount", new Integer(entryCount));
-            
         } catch (Exception ex) {
             log.error("Error loading model objects for page", ex);
-            
-            if(!response.isCommitted()) response.reset();
+
+            if (!response.isCommitted()) {
+                response.reset();
+            }
             response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
             return;
         }
-        
-        
+
+
         // lookup Renderer we are going to use
         Renderer renderer = null;
         try {
             log.debug("Looking up renderer");
             Template template = new StaticTemplate("templates/planet/planetrss.vm", "velocity");
             renderer = RendererManager.getRenderer(template);
-        } catch(Exception e) {
+        } catch (Exception e) {
             // nobody wants to render my content :(
             log.error("Couldn't find renderer for planet rss", e);
-            
-            if(!response.isCommitted()) response.reset();
+
+            if (!response.isCommitted()) {
+                response.reset();
+            }
             response.sendError(HttpServletResponse.SC_NOT_FOUND);
             return;
         }
-        
+
         // render content.  use default size of about 24K for a standard page
         CachedContent rendererOutput = new CachedContent(24567);
         try {
             log.debug("Doing rendering");
             renderer.render(model, rendererOutput.getCachedWriter());
-            
+
             // flush rendered output and close
             rendererOutput.flush();
             rendererOutput.close();
-        } catch(Exception e) {
+        } catch (Exception e) {
             // bummer, error during rendering
             log.error("Error during rendering for planet rss", e);
-            
-            if(!response.isCommitted()) response.reset();
+
+            if (!response.isCommitted()) {
+                response.reset();
+            }
             response.sendError(HttpServletResponse.SC_NOT_FOUND);
             return;
         }
-        
-        
+
+
         // post rendering process
-        
         // flush rendered content to response
         log.debug("Flushing response output");
         response.setContentLength(rendererOutput.getContent().length);
         response.getOutputStream().write(rendererOutput.getContent());
-        
+
         // cache rendered content.
         this.planetCache.put(cacheKey, rendererOutput);
-        
+
         log.debug("Exiting");
     }
 
-    
     /**
      * Generate a cache key from a parsed planet request.
      * This generates a key of the form ...
@@ -228,32 +226,31 @@
      *
      */
     private String generateKey(PlanetRequest planetRequest) {
-        
+
         StringBuffer key = new StringBuffer();
         key.append(planetRequest.getContext());
         key.append("/");
         key.append(planetRequest.getType());
-        
-        if(planetRequest.getFlavor() != null) {
+
+        if (planetRequest.getFlavor() != null) {
             key.append("/").append(planetRequest.getFlavor());
         }
-        
+
         // add language
         key.append("/").append(planetRequest.getLanguage());
-        
-        if(planetRequest.getFlavor() != null) {
+
+        if (planetRequest.getFlavor() != null) {
             // add excerpts
-            if(planetRequest.isExcerpts()) {
+            if (planetRequest.isExcerpts()) {
                 key.append("/excerpts");
             }
         } else {
             // add login state
-            if(planetRequest.getAuthenticUser() != null) {
+            if (planetRequest.getAuthenticUser() != null) {
                 key.append("/user=").append(planetRequest.getAuthenticUser());
             }
         }
-        
+
         return key.toString();
     }
-    
-}
+}
\ No newline at end of file



Mime
View raw message