roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r415761 - in /incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering: model/ModelLoader.java model/WeblogPageModel.java servlets/FeedServlet.java servlets/PageServlet.java servlets/PreviewServlet.java
Date Tue, 20 Jun 2006 18:48:20 GMT
Author: snoopdave
Date: Tue Jun 20 11:48:19 2006
New Revision: 415761

URL: http://svn.apache.org/viewvc?rev=415761&view=rev
Log:
Moving model selection logic out of ModelLoader

Modified:
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ModelLoader.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/WeblogPageModel.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/FeedServlet.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/PageServlet.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/PreviewServlet.java

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ModelLoader.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ModelLoader.java?rev=415761&r1=415760&r2=415761&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ModelLoader.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ModelLoader.java
Tue Jun 20 11:48:19 2006
@@ -40,32 +40,32 @@
     private static Log log = LogFactory.getLog(ModelLoader.class);   
     
     /** 
-     * Load page models needed for rendering a weblog page.
+     * Load page models needed by PageServlet and PreviewServlet.
      */
-    public static void loadPageModels(
+    public static void loadWeblogPageModels(
         WebsiteData weblog,
         PageContext pageContext,
         Map         map) throws RollerException { 
         
         HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
         HttpServletResponse response = (HttpServletResponse)pageContext.getRequest();
-
-        // Only load old model if it's specified
-        String useOldModel = 
-            RollerConfig.getProperty("velocity.pagemodel.classname");        
-        if (useOldModel != null) { 
-            ContextLoader.setupContext(map, request, response);            
-        }
+        loadOldModels(response, request, map);
         
         // Weblogs pages get the weblog page models
         String modelsString = 
             RollerConfig.getProperty("rendering.weblogPageModels");
         loadConfiguredPageModels(modelsString, request, map);
+        loadUtilityObjects(map);
+        loadWeblogHelperObjects(pageContext, map);
         
-        // Weblog pages get utilities, calendar and editor-menu
-        
-        UtilitiesPageHelper utils = new UtilitiesPageHelper();
-        map.put("utils", utils);
+        // Weblog pages get weblog's additional custom models too
+        if (weblog != null) {
+            loadAdditionalPageModels(weblog, request, map);
+        }
+    }
+
+    public static void loadWeblogHelperObjects(
+        PageContext pageContext, Map map) {
         
         CalendarPageHelper calendarTag = new CalendarPageHelper();
         calendarTag.init(pageContext);
@@ -74,57 +74,31 @@
         EditorMenuPageHelper menuTag = new EditorMenuPageHelper();
         menuTag.init(pageContext);
         map.put("menuTag", menuTag);
-        
-        // Weblog pages get weblog's additional custom models too
-        if (weblog != null) {
-            loadWeblogPageModels(weblog, request, map);
-        }
     }
-            
-    /** 
-     * Load page models needed for rendering a feed.
-     */
-    public static void loadFeedModels( 
-        WebsiteData         weblog,
-        HttpServletRequest  request,  
+
+    public static void loadUtilityObjects(Map map) {
+        UtilitiesPageHelper utils = new UtilitiesPageHelper();
+        map.put("utils", utils);
+    }
+
+    public static void loadOldModels(
         HttpServletResponse response, 
-        Map                 map) throws RollerException { 
-        
-        // TODO: remove this for Roller 3.0
+        HttpServletRequest  request,
+        Map                 map) throws RollerException {
+
+        // Only load old model if it's specified
         String useOldModel = 
             RollerConfig.getProperty("velocity.pagemodel.classname");        
         if (useOldModel != null) { 
             ContextLoader.setupContext(map, request, response);            
         }
-        
-        // Feeds get the weblog specific page model
-        String modelsString = RollerConfig.getProperty("rendering.weblogPageModels");
-        
-        // Unless the weblog is the frontpage weblog w/aggregated feeds
-        String frontPageHandle = 
-            RollerConfig.getProperty("velocity.pagemodel.classname");
-        boolean frontPageAggregated = 
-            RollerConfig.getBooleanProperty("frontpage.weblog.aggregatedFeeds");
-        if (weblog.getHandle().equals(frontPageHandle) && frontPageAggregated) {
-            modelsString = RollerConfig.getProperty("rendering.weblogPageModels");
-        }
-        loadConfiguredPageModels(modelsString, request, map);
-
-        // Feeds get utilities, but that's all
-        UtilitiesPageHelper utils = new UtilitiesPageHelper();
-        map.put("utils", utils);
-        
-        // Feeds get weblog's additional custom models too
-        if (weblog != null) {
-            loadWeblogPageModels(weblog, request, map);
-        }
     }
-    
+                
     /**
      * Load comma-separated list of configured page models and if any of the
      * models fail to load, throws an exception.
      */
-    private static void loadConfiguredPageModels(
+    public  static void loadConfiguredPageModels(
             String modelsString, 
             HttpServletRequest request, 
             Map map) throws RollerException {
@@ -153,7 +127,7 @@
      * Load comma-separated list of page models and does not fail if one of the 
      * models fails to load.
      */
-    private static void loadWeblogPageModels(
+    public static void loadAdditionalPageModels(
             WebsiteData weblog, 
             HttpServletRequest request, 
             Map map) {

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/WeblogPageModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/WeblogPageModel.java?rev=415761&r1=415760&r2=415761&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/WeblogPageModel.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/WeblogPageModel.java
Tue Jun 20 11:48:19 2006
@@ -36,6 +36,7 @@
 import org.apache.roller.pojos.WeblogEntryData;
 import org.apache.roller.pojos.WebsiteData;
 import org.apache.roller.pojos.wrapper.CommentDataWrapper;
+import org.apache.roller.pojos.wrapper.WeblogCategoryDataWrapper;
 import org.apache.roller.pojos.wrapper.WeblogEntryDataWrapper;
 import org.apache.roller.pojos.wrapper.WebsiteDataWrapper;
 import org.apache.roller.ui.authoring.struts.formbeans.CommentFormEx;
@@ -118,6 +119,21 @@
         return ret;
     }
         
+    /** 
+     * Get weblog category or null if request does not specify one.
+     */
+    public WeblogCategoryDataWrapper getWeblogCategory() {
+        
+        RollerRequest rreq = RollerRequest.getRollerRequest(request);
+        WeblogCategoryData cat = rreq.getWeblogCategory(); 
+        
+        WeblogCategoryDataWrapper ret = null;
+        if (cat != null) {
+            ret = WeblogCategoryDataWrapper.wrap(cat);
+        }
+        return ret;
+    }
+    
     /**
      * Get most recent weblog entries for date and category specified by request.
      * @return List of WeblogEntryDataWrapper objects. 

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/FeedServlet.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/FeedServlet.java?rev=415761&r1=415760&r2=415761&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/FeedServlet.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/FeedServlet.java
Tue Jun 20 11:48:19 2006
@@ -66,7 +66,7 @@
  * @web.servlet-mapping url-pattern="/flavor/*"
  * @web.servlet-mapping url-pattern="/rss/*"
  * @web.servlet-mapping url-pattern="/atom/*"
- */
+ */ 
 public class FeedServlet extends HttpServlet implements CacheHandler {
     
     private static Log log = LogFactory.getLog(FeedServlet.class);
@@ -265,7 +265,28 @@
             request.setAttribute("updateTime", updateTime);
             
             // populate the model
-            ModelLoader.loadFeedModels(rreq.getWebsite(), request, response, model);
+            
+            // TODO: remove this for Roller 3.0
+            ModelLoader.loadOldModels(response, request, model);
+
+            // Feeds get the weblog specific page model
+            String modelsString = RollerConfig.getProperty("rendering.weblogPageModels");
+
+            // Unless the weblog is the frontpage weblog w/aggregated feeds
+            String frontPageHandle = 
+                RollerConfig.getProperty("velocity.pagemodel.classname");
+            boolean frontPageAggregated = 
+                RollerConfig.getBooleanProperty("frontpage.weblog.aggregatedFeeds");
+            if (weblog.getHandle().equals(frontPageHandle) && frontPageAggregated)
{
+                modelsString = RollerConfig.getProperty("rendering.weblogPageModels");
+            }
+            ModelLoader.loadConfiguredPageModels(modelsString, request, model);
+            ModelLoader.loadUtilityObjects(model);
+
+            // Feeds get weblog's additional custom models too
+            if (weblog != null) {
+                ModelLoader.loadAdditionalPageModels(weblog, request, model);
+            }   
             
         } catch (RollerException ex) {
             log.error("ERROR loading model for page", ex);

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/PageServlet.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/PageServlet.java?rev=415761&r1=415760&r2=415761&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/PageServlet.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/PageServlet.java
Tue Jun 20 11:48:19 2006
@@ -57,7 +57,7 @@
 import org.apache.roller.util.cache.CacheHandler;
 import org.apache.roller.util.cache.CacheManager;
 import org.apache.roller.util.cache.LazyExpiringCacheEntry;
-
+ 
 
 /**
  * Responsible for rendering weblog pages.
@@ -262,8 +262,20 @@
         // looks like we need to render content
         try {
             // populate the model
-            ModelLoader.loadPageModels(rreq.getWebsite(), rreq.getPageContext(), model);
-            
+            ModelLoader.loadOldModels(response, request, model);
+
+            // Weblogs pages get the weblog page models
+            String modelsString = 
+                RollerConfig.getProperty("rendering.weblogPageModels");
+            ModelLoader.loadConfiguredPageModels(modelsString, request, model);
+            ModelLoader.loadUtilityObjects(model);
+            ModelLoader.loadWeblogHelperObjects(rreq.getPageContext(), model);
+
+            // Weblog pages get weblog's additional custom models too
+            if (rreq.getWebsite() != null) {
+                ModelLoader.loadAdditionalPageModels(rreq.getWebsite(), request, model);
+            }
+        
         } catch (RollerException ex) {
             log.error("ERROR loading model for page", ex);
             

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/PreviewServlet.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/PreviewServlet.java?rev=415761&r1=415760&r2=415761&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/PreviewServlet.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/PreviewServlet.java
Tue Jun 20 11:48:19 2006
@@ -51,7 +51,7 @@
 import org.apache.roller.ui.rendering.model.PageModel;
 import org.apache.roller.ui.rendering.model.UtilitiesPageHelper;
 import org.apache.roller.util.Utilities;
-
+ 
 /**
  * Responsible for rendering weblog page previews.
  *
@@ -183,7 +183,7 @@
         HashMap model = new HashMap();
         try {
             // populate the model
-            ModelLoader.loadPageModels(rreq.getWebsite(), rreq.getPageContext(), model);
+            ModelLoader.loadWeblogPageModels(rreq.getWebsite(), rreq.getPageContext(), model);
             
         } catch (RollerException ex) {
             log.error("ERROR loading model for page", ex);



Mime
View raw message