roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r415746 - in /incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering: model/ servlets/ velocity/ velocity/deprecated/
Date Tue, 20 Jun 2006 17:54:59 GMT
Author: snoopdave
Date: Tue Jun 20 10:54:59 2006
New Revision: 415746

URL: http://svn.apache.org/viewvc?rev=415746&view=rev
Log:
New PageModel interface and refactored ModelLoader to remove RollerRequest

Modified:
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ConfigPageModel.java
    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/PageModel.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/PlanetPageModel.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/SitePageModel.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
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/FlavorServlet.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/PageServlet.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/ContextLoader.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/OldWeblogPageModel.java

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ConfigPageModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ConfigPageModel.java?rev=415746&r1=415745&r2=415746&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ConfigPageModel.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ConfigPageModel.java
Tue Jun 20 10:54:59 2006
@@ -58,8 +58,8 @@
     }
 
     /** Init page model based on request */
-    public void init(HttpServletRequest request, Map map) {
-        this.request = request;
+    public void init(Map map) {
+        this.request = (HttpServletRequest)map.get("request");
     }
         
     /** Absolute URL of Roller server, e.g. http://localhost:8080/roller */

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=415746&r1=415745&r2=415746&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 10:54:59 2006
@@ -19,15 +19,16 @@
 
 import java.util.HashMap;
 import java.util.Map;
+
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.jsp.PageContext;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.RollerException;
 import org.apache.roller.config.RollerConfig;
 import org.apache.roller.pojos.WebsiteData;
-import org.apache.roller.ui.core.RollerRequest;
 import org.apache.roller.ui.rendering.velocity.deprecated.ContextLoader;
 import org.apache.roller.util.Utilities;
 
@@ -42,18 +43,18 @@
      * Load page models needed for rendering a weblog page.
      */
     public static void loadPageModels(
-        Map map,
-        HttpServletRequest request,  
-        HttpServletResponse response,
-        PageContext pageContext) throws RollerException { 
+        WebsiteData weblog,
+        PageContext pageContext,
+        Map         map) throws RollerException { 
         
-        RollerRequest rreq = RollerRequest.getRollerRequest(request);
+        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, rreq, response);            
+            ContextLoader.setupContext(map, request, response);            
         }
         
         // Weblogs pages get the weblog page models
@@ -75,27 +76,25 @@
         map.put("menuTag", menuTag);
         
         // Weblog pages get weblog's additional custom models too
-        if (rreq.getWebsite() != null) {
-            loadWeblogPageModels(rreq.getWebsite(), request, map);
+        if (weblog != null) {
+            loadWeblogPageModels(weblog, request, map);
         }
     }
             
     /** 
      * Load page models needed for rendering a feed.
      */
-    public static void loadFeedModels(
-            Map map,
-            HttpServletRequest request,  
-            HttpServletResponse response) throws RollerException { 
+    public static void loadFeedModels( 
+        WebsiteData         weblog,
+        HttpServletRequest  request,  
+        HttpServletResponse response, 
+        Map                 map) throws RollerException { 
         
-        RollerRequest rreq = RollerRequest.getRollerRequest(request);
-        WebsiteData weblog = rreq.getWebsite();
-
-        // Only load old model if it's specified
+        // TODO: remove this for Roller 3.0
         String useOldModel = 
             RollerConfig.getProperty("velocity.pagemodel.classname");        
         if (useOldModel != null) { 
-            ContextLoader.setupContext(map, rreq, response);            
+            ContextLoader.setupContext(map, request, response);            
         }
         
         // Feeds get the weblog specific page model
@@ -116,8 +115,8 @@
         map.put("utils", utils);
         
         // Feeds get weblog's additional custom models too
-        if (rreq.getWebsite() != null) {
-            loadWeblogPageModels(rreq.getWebsite(), request, map);
+        if (weblog != null) {
+            loadWeblogPageModels(weblog, request, map);
         }
     }
     
@@ -136,7 +135,9 @@
                 currentModel = models[i];
                 Class modelClass = Class.forName(currentModel);
                 PageModel pageModel = (PageModel)modelClass.newInstance();
-                pageModel.init(request, new HashMap());            
+                Map args = new HashMap();
+                args.put("request", request);
+                pageModel.init(args);            
                 map.put(pageModel.getModelName(), pageModel);
             }
         } catch (ClassNotFoundException cnfe) {
@@ -163,7 +164,9 @@
                 try { // don't die just because of one bad custom model
                     Class modelClass = Class.forName(weblogModels[i]);
                     PageModel pageModel = (PageModel)modelClass.newInstance();
-                    pageModel.init(request, new HashMap());            
+                    Map args = new HashMap();
+                    args.put("request", request);
+                    pageModel.init(args);             
                     map.put(pageModel.getModelName(), pageModel);
                 } catch (ClassNotFoundException cnfe) {
                     log.warn("ERROR: can't find page model: " + weblogModels[i]);

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/PageModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/PageModel.java?rev=415746&r1=415745&r2=415746&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/PageModel.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/PageModel.java
Tue Jun 20 10:54:59 2006
@@ -31,5 +31,5 @@
     /** 
      * Initialize via request.
      */
-    public void init(HttpServletRequest request, Map params);
+    public void init(Map params);
 }

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/PlanetPageModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/PlanetPageModel.java?rev=415746&r1=415745&r2=415746&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/PlanetPageModel.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/PlanetPageModel.java
Tue Jun 20 10:54:59 2006
@@ -47,7 +47,7 @@
         return "planetPageModel";
     }
     
-    public void init(HttpServletRequest request, Map map) {
+    public void init(Map map) {
         // no-op for now
     } 
     

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/SitePageModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/SitePageModel.java?rev=415746&r1=415745&r2=415746&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/SitePageModel.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/SitePageModel.java
Tue Jun 20 10:54:59 2006
@@ -55,7 +55,7 @@
         return "sitePageModel";
     }
         
-    public void init(HttpServletRequest request, Map map) {
+    public void init(Map map) {
         // no-op for now
     }
     

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=415746&r1=415745&r2=415746&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 10:54:59 2006
@@ -84,8 +84,8 @@
     }
 
     /** Init page model based on request */
-    public void init(HttpServletRequest request, Map map) {
-        this.request = request;
+    public void init(Map map) {
+        this.request = (HttpServletRequest)map.get("request");
     }
     
     /**

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=415746&r1=415745&r2=415746&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 10:54:59 2006
@@ -265,7 +265,7 @@
             request.setAttribute("updateTime", updateTime);
             
             // populate the model
-            ModelLoader.loadFeedModels(model, request, response);
+            ModelLoader.loadFeedModels(rreq.getWebsite(), request, response, 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=415746&r1=415745&r2=415746&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 10:54:59 2006
@@ -262,7 +262,7 @@
         // looks like we need to render content
         try {
             // populate the model
-            ModelLoader.loadPageModels(model, request, response, rreq.getPageContext());
+            ModelLoader.loadPageModels(rreq.getWebsite(), rreq.getPageContext(), 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=415746&r1=415745&r2=415746&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 10:54:59 2006
@@ -183,7 +183,7 @@
         HashMap model = new HashMap();
         try {
             // populate the model
-            ModelLoader.loadPageModels(model, request, response, rreq.getPageContext());
+            ModelLoader.loadPageModels(rreq.getWebsite(), rreq.getPageContext(), 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/velocity/FlavorServlet.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/FlavorServlet.java?rev=415746&r1=415745&r2=415746&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/FlavorServlet.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/FlavorServlet.java
Tue Jun 20 10:54:59 2006
@@ -115,7 +115,7 @@
             request.setAttribute("updateTime", updateTime);
             
             Map mapCtx = new HashMap();
-            ContextLoader.setupContext(mapCtx, rreq, response);
+            ContextLoader.setupContext(mapCtx, rreq.getRequest(), response);
             
             // hack.  put mapCtx info velocity ctx
             String key = null;

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/PageServlet.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/PageServlet.java?rev=415746&r1=415745&r2=415746&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/PageServlet.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/PageServlet.java
Tue Jun 20 10:54:59 2006
@@ -192,7 +192,7 @@
         
         // Made it this far, populate the Context
         Map mapCtx = new HashMap();
-        ContextLoader.setupContext( mapCtx, rreq, response );
+        ContextLoader.setupContext(mapCtx, rreq.getRequest(), response);
         
         // hack.  put mapCtx info velocity ctx
         String key = null;

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/ContextLoader.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/ContextLoader.java?rev=415746&r1=415745&r2=415746&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/ContextLoader.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/ContextLoader.java
Tue Jun 20 10:54:59 2006
@@ -80,22 +80,19 @@
     private static final String TOOLBOX_MANAGER_KEY =
             "org.apache.roller.presentation.velocity.toolboxManager";
     
-    private RollerRequest mRollerReq = null;
-    
-    
     /**
      * Setup the a Velocity context by loading it with objects, values, and
      * RollerPagePlugins needed for Roller page execution.
      */
     public static void setupContext(
-            Map ctx, 
-            RollerRequest rreq, 
+            Map                 ctx, 
+            HttpServletRequest  request, 
             HttpServletResponse response )
             throws RollerException {
         
         mLogger.debug("setupContext( ctx = "+ctx+")");
         
-        HttpServletRequest request = rreq.getRequest();
+        RollerRequest rreq = RollerRequest.getRollerRequest(request);
         RollerContext rollerCtx = RollerContext.getRollerContext( );
         
         try {
@@ -104,7 +101,9 @@
                 RollerConfig.getProperty("velocity.pagemodel.classname");
             Class pageModelClass = Class.forName(pageModelClassName);
             PageModel pageModel = (PageModel)pageModelClass.newInstance();
-            pageModel.init(rreq.getRequest(), new HashMap());            
+            Map args = new HashMap();
+            args.put("request", request);
+            pageModel.init(args);            
             ctx.put(pageModel.getModelName(), pageModel);
             
             // Add other page models

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/OldWeblogPageModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/OldWeblogPageModel.java?rev=415746&r1=415745&r2=415746&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/OldWeblogPageModel.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/OldWeblogPageModel.java
Tue Jun 20 10:54:59 2006
@@ -95,7 +95,8 @@
     /**
      * Initialize PageModel and allow PageModel to initialized VelocityContext.
      */
-    public void init(HttpServletRequest request, Map map) {
+    public void init(Map map) {
+        HttpServletRequest request = (HttpServletRequest)map.get("request");
         mRollerReq = RollerRequest.getRollerRequest(request);
         if ( request.getAttribute(RollerRequest.OWNING_WEBSITE) != null) {
             mWebsite = (WebsiteData)



Mime
View raw message