roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r416157 - in /incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering: model/ servlets/ util/
Date Wed, 21 Jun 2006 23:05:41 GMT
Author: agilliland
Date: Wed Jun 21 16:05:40 2006
New Revision: 416157

URL: http://svn.apache.org/viewvc?rev=416157&view=rev
Log:

- created new WeblogPreviewRequest for parsing preview requests
- updated PreviewServlet to rip out RollerRequest
- made some tweaks to ModelLoader methods to make them more generic
- updated Page, Feed, and Preview servlets to adjust to ModelLoader tweaks


Added:
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogPreviewRequest.java
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/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/util/WeblogRequest.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=416157&r1=416156&r2=416157&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
Wed Jun 21 16:05:40 2006
@@ -15,15 +15,14 @@
  * copyright in this work, please see the NOTICE file in the top level
  * directory of this distribution.
  */
+
 package org.apache.roller.ui.rendering.model;
 
 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;
@@ -32,123 +31,103 @@
 import org.apache.roller.ui.rendering.velocity.deprecated.ContextLoader;
 import org.apache.roller.util.Utilities;
 
+
 /**
  * Loads page models (read-only data access objects which implement PageModel) 
  * and helpers (which "help" with HTML gen.) needed by page rendering process.
  */
 public class ModelLoader {
     
-    private static Log log = LogFactory.getLog(ModelLoader.class);   
+    private static Log log = LogFactory.getLog(ModelLoader.class);
+    
     
-    /** 
-     * Load page models needed by PageServlet and PreviewServlet.
-     */
-    public static void loadWeblogPageModels(
-        WebsiteData weblog,
-        PageContext pageContext,
-        Map map) throws RollerException { 
-        
-        HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
-        HttpServletResponse response = (HttpServletResponse)pageContext.getRequest();
-        loadOldModels(response, request, map);
-        
-        // Weblogs pages get the weblog page models
-        String modelsString = 
-            RollerConfig.getProperty("rendering.weblogPageModels");
-        loadConfiguredPageModels(modelsString, request, map);
-        loadUtilityHelpers(map);
-        loadWeblogHelpers(pageContext, map);
-        loadPluginHelpers(weblog, map);
-        
-        // Weblog pages get weblog's additional custom models too
-        if (weblog != null) {
-            loadAdditionalPageModels(weblog, request, map);
-        }
-    }
-
     /** 
      * Load helpers needed in weblog pages (e.g. calendar, menu).
      */
-    public static void loadWeblogHelpers(
-        PageContext pageContext, Map map) {
+    public static void loadWeblogHelpers(PageContext pageContext, Map model) {
         
         CalendarHelper calendarTag = new CalendarHelper(pageContext);
-        map.put("calendarTag", calendarTag);
+        model.put("calendarTag", calendarTag);
         
         EditorMenuHelper menuTag = new EditorMenuHelper(pageContext);
-        map.put("menuTag", menuTag);
+        model.put("menuTag", menuTag);
     }
-
+    
+    
     /**
      * Load generic utility helpers.
      */
-    public static void loadUtilityHelpers(Map map) {
+    public static void loadUtilityHelpers(Map model) {
         UtilitiesHelper utils = new UtilitiesHelper();
-        map.put("utils", utils);
+        model.put("utils", utils);
     }
-
+    
+    
     /**
      * Load weblog entry plugin helpers.
      */
-    public static void loadPluginHelpers(WebsiteData weblog, Map map) 
+    public static void loadPluginHelpers(WebsiteData weblog, Map model) 
         throws RollerException {
-        WeblogEntryPluginsHelper plugins = new WeblogEntryPluginsHelper(weblog, map);
-        map.put("plugins", plugins);
+        WeblogEntryPluginsHelper plugins = new WeblogEntryPluginsHelper(weblog, model);
+        model.put("plugins", plugins);
     }
-
+    
+    
     /**
      * Load old page models, but only if velocity.pagemodel.classname defined.
      */
     public static void loadOldModels(
         HttpServletResponse response, 
         HttpServletRequest  request,
-        Map map) throws RollerException {
+        Map model) 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);            
+            ContextLoader.setupContext(model, request, response);            
         }
     }
-                
+    
+    
     /**
-     * Load comma-separated list of configured page models and if any of the
-     * models fail to load, throws an exception.
+     * Load set of common weblog models.
+     *
+     * This is the list of models defined by rendering.weblogPageModels
      */
-    public  static void loadConfiguredPageModels(
-        String modelsString, 
-        HttpServletRequest request, 
-        Map map) throws RollerException {
-        String currentModel = null;
-        try { // if we can't load a configued page models, then bail out
-            String[] models = Utilities.stringToStringArray(modelsString, ",");
-            for (int i=0; i<models.length; i++) {
-                currentModel = models[i];
-                Class modelClass = Class.forName(currentModel);
-                PageModel pageModel = (PageModel)modelClass.newInstance();
-                Map args = new HashMap();
-                args.put("request", request);
-                pageModel.init(args);            
-                map.put(pageModel.getModelName(), pageModel);
-            }
-        } catch (ClassNotFoundException cnfe) {
-            throw new RollerException("ERROR: can't find page model: " + currentModel);
-        } catch (InstantiationException ie) {
-            throw new RollerException("ERROR: insantiating page model: " + currentModel);
-        } catch (IllegalAccessException iae) {
-            throw new RollerException("ERROR: access exception page model: " + currentModel);
-        }
+    public static void loadWeblogModels(Map model, Map initData)
+            throws RollerException {
+        
+        String weblogModels = 
+                RollerConfig.getProperty("rendering.weblogPageModels");
+        loadModels(weblogModels, model, initData);
+    }
+    
+    
+    /**
+     * Load set of common site-wide models.
+     *
+     * This is the list of models defined by rendering.sitePageModels
+     */
+    public static void loadSiteModels(Map model, Map initData)
+            throws RollerException {
+        
+        String weblogModels = 
+                RollerConfig.getProperty("rendering.sitePageModels");
+        loadModels(weblogModels, model, initData);
     }
     
+    
     /**
-     * Load comma-separated list of page models and does not fail if one of the 
-     * models fails to load.
+     * Load set of custom models allowed for the given weblog.
+     *
+     * Does not fail if there is a problem with one of the models.
      */
-    public static void loadAdditionalPageModels(
+    public static void loadCustomModels(
             WebsiteData weblog, 
-            HttpServletRequest request, 
-            Map map) {
+            Map model,
+            Map initData) {
+        
         if (weblog.getPageModels() != null) {
             String[] weblogModels = 
                 Utilities.stringToStringArray(weblog.getPageModels(), ",");
@@ -156,10 +135,8 @@
                 try { // don't die just because of one bad custom model
                     Class modelClass = Class.forName(weblogModels[i]);
                     PageModel pageModel = (PageModel)modelClass.newInstance();
-                    Map args = new HashMap();
-                    args.put("request", request);
-                    pageModel.init(args);             
-                    map.put(pageModel.getModelName(), pageModel);
+                    pageModel.init(initData);             
+                    model.put(pageModel.getModelName(), pageModel);
                 } catch (RollerException re) {
                     log.warn("ERROR: initializing a plugin: " + weblogModels[i]);
                 } catch (ClassNotFoundException cnfe) {
@@ -172,4 +149,34 @@
             }
         }     
     }
+    
+    
+    /**
+     * Convenience method to load a comma-separated list of page models.
+     * If any of the models fail to load, throws an exception.
+     */
+    private static void loadModels(
+            String modelsString,
+            Map model,
+            Map initData) throws RollerException {
+        
+        String currentModel = null;
+        try { // if we can't load a configued page models, then bail out
+            String[] models = Utilities.stringToStringArray(modelsString, ",");
+            for (int i=0; i<models.length; i++) {
+                currentModel = models[i];
+                Class modelClass = Class.forName(currentModel);
+                PageModel pageModel = (PageModel) modelClass.newInstance();
+                pageModel.init(initData);            
+                model.put(pageModel.getModelName(), pageModel);
+            }
+        } catch (ClassNotFoundException cnfe) {
+            throw new RollerException("ERROR: can't find page model: " + currentModel);
+        } catch (InstantiationException ie) {
+            throw new RollerException("ERROR: insantiating page model: " + currentModel);
+        } catch (IllegalAccessException iae) {
+            throw new RollerException("ERROR: access exception page model: " + currentModel);
+        }
+    }
+    
 }

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=416157&r1=416156&r2=416157&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
Wed Jun 21 16:05:40 2006
@@ -193,20 +193,23 @@
             }
             
             // populate the rendering model
-
+            Map initData = new HashMap();
+            initData.put("request", request);
+            
             // Feeds get the weblog specific page model
-            String modelsString = RollerConfig.getProperty("rendering.weblogPageModels");
+            ModelLoader.loadWeblogModels(model, initData);
             
             // special handling for site wide feed
             if (rollerContext.isSiteWideWeblog(weblog.getHandle())) {
-                modelsString = RollerConfig.getProperty("rendering.weblogPageModels");
+                ModelLoader.loadSiteModels(model, initData);
             }
-            ModelLoader.loadConfiguredPageModels(modelsString, request, model);
+            
+            // utility helpers and plugin helpers
             ModelLoader.loadUtilityHelpers(model);
             ModelLoader.loadPluginHelpers(weblog, model);
 
-            // Feeds get weblog's additional custom models too
-            ModelLoader.loadAdditionalPageModels(weblog, request, model);
+            // Feeds get weblog's custom models too
+            ModelLoader.loadCustomModels(weblog, model, initData);
             
         } 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=416157&r1=416156&r2=416157&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
Wed Jun 21 16:05:40 2006
@@ -34,6 +34,8 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.RollerException;
 import org.apache.roller.config.RollerConfig;
+import org.apache.roller.model.RollerFactory;
+import org.apache.roller.model.UserManager;
 import org.apache.roller.pojos.BookmarkData;
 import org.apache.roller.pojos.CommentData;
 import org.apache.roller.pojos.FolderData;
@@ -126,11 +128,20 @@
         // used for rendering
         HashMap model = new HashMap();
         
-        WebsiteData website = null;
+        WebsiteData weblog = null;
         
         WeblogPageRequest pageRequest = null;
         try {
             pageRequest = new WeblogPageRequest(request);
+            
+            // lookup weblog specified by feed request
+            UserManager uMgr = RollerFactory.getRoller().getUserManager();
+            weblog = uMgr.getWebsiteByHandle(pageRequest.getWeblogHandle());
+            
+            if(weblog == null) {
+                throw new RollerException("unable to lookup weblog: "+
+                        pageRequest.getWeblogHandle());
+            }
         } catch (Exception e) {
             // some kind of error parsing the request
             log.error("error creating page request", e);
@@ -141,18 +152,13 @@
         // first off lets parse the incoming request and validate it
         // TODO: this is old logic from pre 3.0 that we'll remove when possible
         RollerRequest rreq = null;
+        PageContext pageContext = null;
         try {
-            PageContext pageContext = 
-                    JspFactory.getDefaultFactory().getPageContext(
+            pageContext = JspFactory.getDefaultFactory().getPageContext(
                     this, request, response,"", true, 8192, true);
             
             rreq = RollerRequest.getRollerRequest(pageContext);
             
-            // make sure the website is valid
-            website = rreq.getWebsite();
-            if(website == null)
-                throw new InvalidRequestException("invalid weblog");
-            
         } catch (Exception e) {
             // An error initializing the request is considered to be a 404
             response.sendError(HttpServletResponse.SC_NOT_FOUND);
@@ -167,14 +173,14 @@
         if (request.getParameter("popup") != null) {
             try {
                 // Does user have a popupcomments page?
-                page = website.getPageByName("_popupcomments");
+                page = weblog.getPageByName("_popupcomments");
             } catch(Exception e ) {
                 // ignored ... considered page not found
             }
             
             // User doesn't have one so return the default
             if(page == null) {
-                page = new WeblogTemplate("templates/weblog/popupcomments.vm", website,
+                page = new WeblogTemplate("templates/weblog/popupcomments.vm", weblog,
                         "Comments", "Comments", "dummy_link",
                         "dummy_template", new Date());
             }
@@ -186,9 +192,9 @@
             page = rreq.getPage();
             
         } else {
-            // If page not available from request, then use website's default
+            // If page not available from request, then use weblog's default
             try {
-                page = website.getDefaultPage();
+                page = weblog.getDefaultPage();
                 rreq.setPage(page);
             } catch(Exception e) {
                 log.error(e);
@@ -206,7 +212,7 @@
         // 304 if-modified-since checking
         long sinceDate = request.getDateHeader("If-Modified-Since");
         log.debug("since date = "+sinceDate);
-        if(website.getLastModified().getTime() <= sinceDate) {
+        if(weblog.getLastModified().getTime() <= sinceDate) {
             log.debug("NOT MODIFIED "+request.getRequestURL());
             response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
             return;
@@ -223,7 +229,7 @@
         }
         
         // set last-modified date
-        response.setDateHeader("Last-Modified", website.getLastModified().getTime());
+        response.setDateHeader("Last-Modified", weblog.getLastModified().getTime());
         
         // cached content checking
         String cacheKey = this.CACHE_ID+":"+this.generateKey(pageRequest);
@@ -261,23 +267,33 @@
         
         // looks like we need to render content
         try {
-            // populate the model
-            ModelLoader.loadOldModels(response, request, model);
-
-            // Weblogs pages get the weblog page models
-            String modelsString = 
-                RollerConfig.getProperty("rendering.weblogPageModels");
-            ModelLoader.loadConfiguredPageModels(modelsString, request, model);
+            RollerContext rollerContext = RollerContext.getRollerContext();
+            
+            // populate the rendering model
+            Map initData = new HashMap();
+            initData.put("request", request);
+            
+            // Feeds get the weblog specific page model
+            ModelLoader.loadWeblogModels(model, initData);
+            
+            // special handling for site wide feed
+            if (rollerContext.isSiteWideWeblog(weblog.getHandle())) {
+                ModelLoader.loadSiteModels(model, initData);
+            }
+            
+            // add helpers
             ModelLoader.loadUtilityHelpers(model);
-            ModelLoader.loadWeblogHelpers(rreq.getPageContext(), model);
+            ModelLoader.loadWeblogHelpers(pageContext, model);
+            ModelLoader.loadPluginHelpers(weblog, model);
 
-            // Weblog pages get weblog's additional custom models too
-            if (rreq.getWebsite() != null) {
-                ModelLoader.loadAdditionalPageModels(rreq.getWebsite(), request, model);
-            }
-        
+            // Feeds get weblog's custom models too
+            ModelLoader.loadCustomModels(weblog, model, initData);
+            
+            // ick, gotta load pre-3.0 model stuff as well :(
+            ModelLoader.loadOldModels(response, request, model);
+            
         } catch (RollerException ex) {
-            log.error("ERROR loading model for page", ex);
+            log.error("Error loading model objects for page", ex);
             
             if(!response.isCommitted()) response.reset();
             response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);

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=416157&r1=416156&r2=416157&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
Wed Jun 21 16:05:40 2006
@@ -32,26 +32,20 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.RollerException;
 import org.apache.roller.ThemeNotFoundException;
-import org.apache.roller.config.RollerConfig;
 import org.apache.roller.model.RollerFactory;
 import org.apache.roller.model.ThemeManager;
+import org.apache.roller.model.UserManager;
 import org.apache.roller.pojos.Template;
 import org.apache.roller.pojos.Theme;
 import org.apache.roller.pojos.WebsiteData;
-import org.apache.roller.ui.rendering.util.InvalidRequestException;
 import org.apache.roller.ui.core.RollerContext;
-import org.apache.roller.ui.core.RollerRequest;
-import org.apache.roller.ui.rendering.velocity.deprecated.ContextLoader;
 import org.apache.roller.util.cache.CachedContent;
 import org.apache.roller.ui.rendering.Renderer;
 import org.apache.roller.ui.rendering.RendererManager;
-import org.apache.roller.ui.rendering.model.CalendarHelper;
-import org.apache.roller.ui.rendering.model.EditorMenuHelper;
 import org.apache.roller.ui.rendering.model.ModelLoader;
-import org.apache.roller.ui.rendering.model.PageModel;
-import org.apache.roller.ui.rendering.model.UtilitiesHelper;
-import org.apache.roller.util.Utilities;
- 
+import org.apache.roller.ui.rendering.util.WeblogPreviewRequest;
+
+
 /**
  * Responsible for rendering weblog page previews.
  *
@@ -83,15 +77,33 @@
         log.debug("Entering");
         
         Theme previewTheme = null;
-        WebsiteData website = null;
+        WebsiteData weblog = null;
+        
+        WeblogPreviewRequest previewRequest = null;
+        try {
+            previewRequest = new WeblogPreviewRequest(request);
+            
+            // lookup weblog specified by preview request
+            UserManager uMgr = RollerFactory.getRoller().getUserManager();
+            weblog = uMgr.getWebsiteByHandle(previewRequest.getWeblogHandle());
+            
+            if(weblog == null) {
+                throw new RollerException("unable to lookup weblog: "+
+                        previewRequest.getWeblogHandle());
+            }
+        } catch (Exception e) {
+            // some kind of error parsing the request
+            log.error("error creating preview request", e);
+            response.sendError(HttpServletResponse.SC_NOT_FOUND);
+            return;
+        }
         
         // try getting the preview theme
-        String themeName = request.getParameter("theme");
-        log.debug("preview theme = "+themeName);
-        if (themeName != null) {
+        log.debug("preview theme = "+previewRequest.getTheme());
+        if(previewRequest.getTheme() != null) {
             try {
                 ThemeManager themeMgr = RollerFactory.getRoller().getThemeManager();
-                previewTheme = themeMgr.getTheme(themeName);
+                previewTheme = themeMgr.getTheme(previewRequest.getTheme());
                 
             } catch(ThemeNotFoundException tnfe) {
                 // bogus theme specified ... don't worry about it
@@ -99,56 +111,32 @@
             } catch(RollerException re) {
                 
                 response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
-                log.error("Error doing page preview", re);
+                log.error("Error doing theme preview", re);
                 return;
             }
         }
         
-        // TODO 3.0: change to previewRequest
-//        WeblogPageRequest pageRequest = null;
-//        try {
-//            pageRequest = new WeblogPageRequest(request);
-//        } catch (Exception e) {
-//            // some kind of error parsing the request
-//            log.error("error creating page request", e);
-//            response.sendError(HttpServletResponse.SC_NOT_FOUND);
-//            return;
-//        }
-        
-        // TODO: this is old logic from pre 3.0 that we'll remove when possible
-        RollerRequest rreq = null;
-        try {
-            PageContext pageContext = 
-                    JspFactory.getDefaultFactory().getPageContext(
+        // construct page context
+        PageContext pageContext = JspFactory.getDefaultFactory().getPageContext(
                     this, request, response,"", true, 8192, true);
-            
-            rreq = RollerRequest.getRollerRequest(pageContext);
-            
-            // make sure the website is valid
-            website = rreq.getWebsite();
-            if(website == null)
-                throw new InvalidRequestException("invalid weblog");
-            
-        } catch (Exception e) {
-            // An error initializing the request is considered to be a 404
-            response.sendError(HttpServletResponse.SC_NOT_FOUND);
-            log.error("ERROR initializing RollerRequest", e);
-            return;
-        }
         
         // construct a temporary Website object for this request
         // and set the EditorTheme to our previewTheme
         WebsiteData tmpWebsite = new WebsiteData();
-        tmpWebsite.setData(website);
+        tmpWebsite.setData(weblog);
         if(previewTheme != null && previewTheme.isEnabled()) {
             tmpWebsite.setEditorTheme(previewTheme.getName());
-        } else if(themeName.equals(Theme.CUSTOM)) {
+        } else if(previewRequest.getTheme().equals(Theme.CUSTOM)) {
             tmpWebsite.setEditorTheme(Theme.CUSTOM);
         }
         
         Template page = null;
         try {
             page = tmpWebsite.getDefaultPage();
+            
+            if(page == null) {
+                throw new RollerException("Weblog's default page was null");
+            }
         } catch(RollerException re) {
             // couldn't get page
             response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
@@ -156,17 +144,6 @@
             return;
         }
         
-        if (page == null) {
-            // previewing a custom theme when they have no templates
-            response.sendError(HttpServletResponse.SC_NOT_FOUND);
-            log.error("No page found for rendering");
-            return;
-        }
-        
-        // update our roller request object
-        rreq.setPage(page);
-        rreq.setWebsite(tmpWebsite);
-        
         log.debug("preview page found, dealing with it");
         
         // set the content type
@@ -180,10 +157,32 @@
         }
         
         // looks like we need to render content
-        HashMap model = new HashMap();
+        Map model = new HashMap();
         try {
-            // populate the model
-            ModelLoader.loadWeblogPageModels(rreq.getWebsite(), rreq.getPageContext(), model);
+            RollerContext rollerContext = RollerContext.getRollerContext();
+            
+            // populate the rendering model
+            Map initData = new HashMap();
+            initData.put("request", request);
+            
+            // Feeds get the weblog specific page model
+            ModelLoader.loadWeblogModels(model, initData);
+            
+            // special handling for site wide feed
+            if (rollerContext.isSiteWideWeblog(tmpWebsite.getHandle())) {
+                ModelLoader.loadSiteModels(model, initData);
+            }
+            
+            // add helpers
+            ModelLoader.loadUtilityHelpers(model);
+            ModelLoader.loadWeblogHelpers(pageContext, model);
+            ModelLoader.loadPluginHelpers(tmpWebsite, model);
+
+            // Feeds get weblog's custom models too
+            ModelLoader.loadCustomModels(tmpWebsite, model, initData);
+            
+            // ick, gotta load pre-3.0 model stuff as well :(
+            ModelLoader.loadOldModels(response, request, model);
             
         } catch (RollerException ex) {
             log.error("ERROR loading model for page", ex);

Added: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogPreviewRequest.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogPreviewRequest.java?rev=416157&view=auto
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogPreviewRequest.java
(added)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogPreviewRequest.java
Wed Jun 21 16:05:40 2006
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.ui.rendering.util;
+
+import javax.servlet.http.HttpServletRequest;
+
+
+/**
+ * Represents a request for a weblog preview.
+ */
+public class WeblogPreviewRequest extends WeblogRequest {
+    
+    private String theme = null;
+    
+    
+    public WeblogPreviewRequest(HttpServletRequest request) 
+            throws InvalidRequestException {
+        
+        // our parent will determine the weblog handle for us
+        super(request);
+        
+        // all we need to worry about is the query params
+        // the only param we expect is "theme"
+        if(request.getParameter("theme") != null) {
+            this.theme = request.getParameter("theme");
+        }
+    }
+
+    
+    public String getTheme() {
+        return theme;
+    }
+    
+}

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogRequest.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogRequest.java?rev=416157&r1=416156&r2=416157&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogRequest.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogRequest.java
Wed Jun 21 16:05:40 2006
@@ -39,7 +39,7 @@
         
         String pathInfo = request.getPathInfo();
         
-        // we expect a path info of /<handle/*
+        // we expect a path info of /<handle>/*
         if(pathInfo != null && pathInfo.trim().length() > 1) {
             // strip off the leading slash
             pathInfo = pathInfo.substring(1);



Mime
View raw message