roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r415905 - in /incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering: model/WeblogPageModel.java velocity/deprecated/ContextLoader.java velocity/deprecated/OldWeblogPageModel.java
Date Wed, 21 Jun 2006 04:35:22 GMT
Author: agilliland
Date: Tue Jun 20 21:35:22 2006
New Revision: 415905

URL: http://svn.apache.org/viewvc?rev=415905&view=rev
Log:
continued work to try and isolate old context loading stuff and EOL RollerRequest.

- new WeblogPageModel cannot be named "page" because it conflicts with existing object.

- old page model should not be tied together with new model stuff, we'll just keep it separate
and isolated from ongoing work with the new model code.

- updated old ContextLoader and removed most references to RollerRequest, still a little bit
to go though.


Modified:
    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/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/WeblogPageModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/WeblogPageModel.java?rev=415905&r1=415904&r2=415905&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 21:35:22 2006
@@ -81,7 +81,7 @@
     
     /** Template context name to be used for model */
     public String getModelName() {
-        return "page";
+        return "can't be just 'page' :(";
     }
 
     /** Init page model based on request */

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=415905&r1=415904&r2=415905&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 21:35:22 2006
@@ -41,6 +41,7 @@
 import org.apache.roller.pojos.CommentData;
 import org.apache.roller.pojos.RollerPropertyData;
 import org.apache.roller.pojos.Template;
+import org.apache.roller.pojos.WeblogCategoryData;
 import org.apache.roller.pojos.WeblogEntryData;
 import org.apache.roller.pojos.WebsiteData;
 import org.apache.roller.pojos.wrapper.CommentDataWrapper;
@@ -108,24 +109,13 @@
         
         try {
             // Add default page model object to context
+            // TODO 3.0: what to do about old PlanetPageModel?
             String pageModelClassName =
                     RollerConfig.getProperty("velocity.pagemodel.classname");
             Class pageModelClass = Class.forName(pageModelClassName);
-            PageModel pageModel = (PageModel)pageModelClass.newInstance();
-            Map args = new HashMap();
-            args.put("request", request);
-            pageModel.init(args);
-            ctx.put(pageModel.getModelName(), pageModel);
-            
-            // Add other page models
-            // TODO: ATLAS make page models configurable
-            PageModel sitePageModel = new SitePageModel();
-            ctx.put(sitePageModel.getModelName(), sitePageModel);
-            PageModel planetPageModel = new PlanetPageModel();
-            ctx.put(planetPageModel.getModelName(), planetPageModel);
-            
-            // TODO: ATLAS: figure out another way to do this:
-            //ctx.put("pages", pageModel.getPages());
+            OldWeblogPageModel pageModel = (OldWeblogPageModel)pageModelClass.newInstance();
+            pageModel.init(request);
+            ctx.put("pageModel", pageModel);
             
         } catch (Exception e) {
             throw new RollerException("ERROR creating Page Model",e);
@@ -139,44 +129,34 @@
         ctx.put("pageHelper", pageHelper);
         
         // Load standard Roller objects and values into the context
-        WebsiteData website =
-                loadWeblogValues(ctx, rreq, rollerCtx );
-        loadPathValues(       ctx, rreq, rollerCtx, website );
-        loadRssValues(        ctx, rreq, website );
-        loadUtilityObjects(   ctx, rreq, rollerCtx, website );
-        loadRequestParamKeys( ctx);
-        loadStatusMessage(    ctx, rreq );
+        WebsiteData website = loadWeblogValues(ctx, weblog, request);
+        loadPathValues(ctx, request, rollerCtx, website);
+        loadRssValues(ctx, request, website, rreq.getWeblogCategory());
+        loadUtilityObjects(ctx, request, rollerCtx, website, rreq.getPage());
+        loadRequestParamKeys(ctx);
+        loadStatusMessage(ctx, request);
         
         // If single entry is specified, load comments too
         if ( rreq.getWeblogEntry() != null ) {
-            loadCommentValues( ctx, rreq, rollerCtx );
+            loadCommentValues(ctx, request, rreq.getWeblogEntry());
         }
         
         // add Velocity Toolbox tools to context
         loadToolboxContext(request, response, ctx);
     }
     
+    
     /**
      * Load website object and related objects.
      */
-    protected static WebsiteData loadWeblogValues(
+    private static WebsiteData loadWeblogValues(
             Map ctx,
-            RollerRequest rreq,
-            RollerContext rollerCtx )
-            throws RollerException {
+            WebsiteData weblog,
+            HttpServletRequest request) throws RollerException {
         
         Roller mRoller = RollerFactory.getRoller();
         Map props = mRoller.getPropertiesManager().getProperties();
         
-        WebsiteData weblog = rreq.getWebsite();
-        if (weblog == null && rreq.getRequest().getParameter("entry") != null) {
-            String handle = rreq.getRequest().getParameter("entry");
-            weblog = RollerFactory.getRoller().getUserManager().getWebsiteByHandle(handle);
-        }
-        if (weblog == null && rreq.getRequest().getAttribute(RollerRequest.OWNING_WEBSITE)
!= null) {
-            weblog = (WebsiteData)rreq.getRequest().getAttribute(RollerRequest.OWNING_WEBSITE);
-        }
-        
         if (weblog != null) {
             ctx.put("userName",         weblog.getHandle());
             ctx.put("fullName",         weblog.getName() );
@@ -220,8 +200,7 @@
         ctx.put("siteShortName", siteShortName);
         
         // add language of the session (using locale of viewer set by Struts)
-        ctx.put("viewLocale",
-                LanguageUtil.getViewLocale(rreq.getRequest()));
+        ctx.put("viewLocale", LanguageUtil.getViewLocale(request));
         mLogger.debug("context viewLocale = "+ctx.get( "viewLocale"));
         
         // if there is an "_entry" page, only load it once
@@ -253,19 +232,17 @@
         return weblog;
     }
     
+    
     /**
      * Load comments for one weblog entry and related objects.
      */
-    protected static void loadCommentValues(
-            Map       ctx,
-            RollerRequest rreq,
-            RollerContext rollerCtx )
-            throws RollerException {
+    private static void loadCommentValues(
+            Map ctx,
+            HttpServletRequest request,
+            WeblogEntryData entry) throws RollerException {
         
         mLogger.debug("Loading comment values");
         
-        HttpServletRequest request = rreq.getRequest();
-        
         String escapeHtml =
                 RollerRuntimeConfig.getProperty("users.comments.escapehtml");
         String autoFormat =
@@ -297,25 +274,24 @@
             ctx.put("previewComments",list);
         }
         
-        WeblogEntryData entry = rreq.getWeblogEntry();
         if (entry.getStatus().equals(WeblogEntryData.PUBLISHED)) {
             ctx.put("entry", WeblogEntryDataWrapper.wrap(entry));
         }
     }
     
+    
     /**
      * Load objects needed for RSS and Atom newsfeed generation.
      */
-    protected static void loadRssValues(
+    private static void loadRssValues(
             Map ctx,
-            RollerRequest rreq,
-            WebsiteData website)
+            HttpServletRequest request,
+            WebsiteData website,
+            WeblogCategoryData category)
             throws RollerException {
         
         mLogger.debug("Loading rss values");
         
-        HttpServletRequest request = rreq.getRequest();
-        
         int entryLength = -1;
         String sExcerpts = request.getParameter("excerpts");
         if ( sExcerpts!=null && sExcerpts.equalsIgnoreCase("true")) {
@@ -337,9 +313,9 @@
         
         String catname = null;
         String catPath = null;
-        if ( rreq.getWeblogCategory() != null ) {
-            catname = rreq.getWeblogCategory().getName();
-            catPath = rreq.getWeblogCategory().getPath();
+        if (category != null ) {
+            catname = category.getName();
+            catPath = category.getPath();
         }
         ctx.put("catname", (catname!=null) ? catname : "");
         ctx.put("catPath", (catPath != null) ? catPath : "");
@@ -347,15 +323,16 @@
         ctx.put("now", new Date());
     }
     
+    
     /**
      * Load useful utility objects for string and date formatting.
      */
-    protected static void loadUtilityObjects(
+    private static void loadUtilityObjects(
             Map ctx,
-            RollerRequest rreq,
+            HttpServletRequest request,
             RollerContext rollerCtx,
-            WebsiteData website)
-            throws RollerException {
+            WebsiteData website,
+            Template page) throws RollerException {
         
         mLogger.debug("Loading utility objects");
         
@@ -374,7 +351,7 @@
         // the Entry Day link.
         ctx.put("plainFormat", "yyyyMMdd");
         
-        ctx.put("page",            TemplateWrapper.wrap(rreq.getPage()));
+        ctx.put("page",            TemplateWrapper.wrap(page));
         ctx.put("utilities",       new OldUtilities() );
         ctx.put("stringUtils",     new OldStringUtils() );
         ctx.put("rollerVersion",   rollerCtx.getRollerVersion() );
@@ -382,21 +359,22 @@
         ctx.put("rollerBuildUser", rollerCtx.getRollerBuildUser() );
         ctx.put("newsfeedCache",   NewsfeedCache.getInstance() );
         
-        ctx.put("requestParameters", rreq.getRequest().getParameterMap());
+        ctx.put("requestParameters", request.getParameterMap());
     }
     
+    
     /**
      * Load URL paths useful in page templates.
      */
-    protected static void loadPathValues(
-            Map ctx,  RollerRequest rreq,
+    private static void loadPathValues(
+            Map ctx,
+            HttpServletRequest request,
             RollerContext rollerCtx,
             WebsiteData   website)
             throws RollerException {
         
         mLogger.debug("Loading path values");
         
-        HttpServletRequest request = rreq.getRequest();
         String url = null;
         if (website != null  && !"zzz_none_zzz".equals(website.getHandle())) {
             url = OldUtilities.escapeHTML(
@@ -409,7 +387,7 @@
         ctx.put("baseURL",    rollerCtx.getContextUrl( request ) );
         ctx.put("absBaseURL", rollerCtx.getAbsoluteContextUrl( request ) );
         ctx.put("ctxPath",    request.getContextPath() );
-        ctx.put("uploadPath", ContextLoader.figureResourcePath( rreq ) );
+        ctx.put("uploadPath", ContextLoader.figureResourcePath());
         
         try {
             URL absUrl = RequestUtils.absoluteURL(request, "/");
@@ -419,10 +397,11 @@
         }
     }
     
+    
     /**
      * Determine URL path to Roller upload directory.
      */
-    private static String figureResourcePath(RollerRequest rreq) {
+    private static String figureResourcePath() {
         
         String uploadurl = null;
         try {
@@ -432,15 +411,16 @@
         return uploadurl;
     }
     
+    
     /**
      * If there is an ERROR or STATUS message in the session,
      * place it into the Context for rendering later.
      */
-    private static void loadStatusMessage(Map ctx, RollerRequest rreq) {
+    private static void loadStatusMessage(Map ctx, HttpServletRequest req) {
         
         mLogger.debug("Loading status message");
         
-        HttpSession session = rreq.getRequest().getSession(false);
+        HttpSession session = req.getSession(false);
         String msg = null;
         if (session != null)
             msg = (String)session.getAttribute(RollerSession.ERROR_MESSAGE);
@@ -457,7 +437,8 @@
         }
     }
     
-    protected static void loadRequestParamKeys(Map ctx) {
+    
+    private static void loadRequestParamKeys(Map ctx) {
         
         mLogger.debug("Loading request param keys");
         
@@ -481,6 +462,7 @@
         ctx.put("WEBLOGCOMMENTID_KEY",    RollerRequest.WEBLOGCOMMENTID_KEY);
     }
     
+    
     public static ToolboxContext loadToolboxContext(
             HttpServletRequest request,
             HttpServletResponse response,
@@ -510,17 +492,6 @@
         if (toolboxContext != null) {
             // add MessageTool to VelocityContext
             ctx.put("text", toolboxContext.internalGet("text"));
-            
-            /*
-            Object[] keys = toolboxContext.internalGetKeys();
-            for (int i=0;i<keys.length;i++) {
-                String key = (String)keys[i];
-                System.out.println("key = "+key);
-                Object tool = toolboxContext.get(key);
-                System.out.println("tool = "+tool);
-                ctx.put(key, tool);
-            }
-             */
         }
         
         return toolboxContext;

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=415905&r1=415904&r2=415905&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 21:35:22 2006
@@ -54,15 +54,13 @@
 import org.apache.roller.pojos.wrapper.WebsiteDataWrapper;
 import org.apache.roller.ui.core.RollerRequest;
 import org.apache.roller.ui.core.RollerSession;
-import org.apache.roller.ui.rendering.model.*;
 import org.apache.roller.util.DateUtil;
 import org.apache.commons.lang.StringUtils;
-import org.apache.velocity.context.Context;
 
 /**
  * Provides Roller page templates with access to Roller domain model objects.
  */
-public class OldWeblogPageModel implements PageModel {
+public class OldWeblogPageModel {
     public final static String VELOCITY_NULL = "nil";
     
     protected static Log mLogger =
@@ -95,8 +93,7 @@
     /**
      * Initialize PageModel and allow PageModel to initialized VelocityContext.
      */
-    public void init(Map map) {
-        HttpServletRequest request = (HttpServletRequest)map.get("request");
+    public void init(HttpServletRequest request) {
         mRollerReq = RollerRequest.getRollerRequest(request);
         if ( request.getAttribute(RollerRequest.OWNING_WEBSITE) != null) {
             mWebsite = (WebsiteData)



Mime
View raw message