roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r416091 - in /incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated: ContextLoader.java OldPageHelper.java OldWeblogPageModel.java
Date Wed, 21 Jun 2006 19:51:46 GMT
Author: agilliland
Date: Wed Jun 21 12:51:45 2006
New Revision: 416091

URL: http://svn.apache.org/viewvc?rev=416091&view=rev
Log:
almost done with RollerRequest cleanup, OldPageHelper and OldWeblogPageModel are now clean
of RollerRequest and ContextLoader is almost there.


Modified:
    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/OldPageHelper.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/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=416091&r1=416090&r2=416091&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
Wed Jun 21 12:51:45 2006
@@ -22,7 +22,6 @@
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
 import java.util.TimeZone;
@@ -39,6 +38,7 @@
 import org.apache.roller.model.Roller;
 import org.apache.roller.model.RollerFactory;
 import org.apache.roller.pojos.CommentData;
+import org.apache.roller.pojos.FolderData;
 import org.apache.roller.pojos.RollerPropertyData;
 import org.apache.roller.pojos.Template;
 import org.apache.roller.pojos.WeblogCategoryData;
@@ -53,9 +53,6 @@
 import org.apache.roller.ui.core.RollerContext;
 import org.apache.roller.ui.core.RollerRequest;
 import org.apache.roller.ui.core.RollerSession;
-import org.apache.roller.ui.rendering.model.PageModel;
-import org.apache.roller.ui.rendering.model.PlanetPageModel;
-import org.apache.roller.ui.rendering.model.SitePageModel;
 import org.apache.roller.ui.rendering.newsfeeds.NewsfeedCache;
 import org.apache.roller.ui.rendering.util.WeblogPageRequest;
 import org.apache.roller.util.RegexUtil;
@@ -96,9 +93,6 @@
         
         mLogger.debug("setupContext( ctx = "+ctx+")");
         
-        RollerRequest rreq = RollerRequest.getRollerRequest(request);
-        RollerContext rollerCtx = RollerContext.getRollerContext( );
-        
         // if this is a weblog page request then parse it out
         WeblogPageRequest pageRequest = null;
         try {
@@ -107,6 +101,20 @@
             // ignored, just assume it's not a page request
         }
         
+        RollerContext rollerCtx = RollerContext.getRollerContext( );
+        
+        // grab data from the request that we'll need to use
+        RollerRequest rreq = RollerRequest.getRollerRequest(request);
+        PageContext pageContext = rreq.getPageContext();
+        WebsiteData weblog = rreq.getWebsite();
+        WeblogEntryData entry = rreq.getWeblogEntry();
+        WeblogCategoryData category = rreq.getWeblogCategory();
+        Template page = rreq.getPage();
+        FolderData folder = rreq.getFolder();
+        Date date = rreq.getDate();
+        boolean isDay = rreq.isDaySpecified();
+        boolean isMonth = rreq.isMonthSpecified();
+        
         try {
             // Add default page model object to context
             // TODO 3.0: what to do about old PlanetPageModel?
@@ -114,31 +122,41 @@
                     RollerConfig.getProperty("velocity.pagemodel.classname");
             Class pageModelClass = Class.forName(pageModelClassName);
             OldWeblogPageModel pageModel = (OldWeblogPageModel)pageModelClass.newInstance();
-            pageModel.init(request);
+            pageModel.init(request,
+                    weblog,
+                    entry,
+                    category,
+                    date,
+                    isDay,
+                    isMonth);
             ctx.put("pageModel", pageModel);
             
         } catch (Exception e) {
             throw new RollerException("ERROR creating Page Model",e);
         }
         
-        // Add Velocity page helper to context
-        WebsiteData weblog = rreq.getWebsite();
-        PageContext pageContext = rreq.getPageContext();
-        OldPageHelper pageHelper = new OldPageHelper(request, response, ctx, weblog, pageContext,
pageRequest);
-        Roller roller = RollerFactory.getRoller();
+        // Add page helper to context
+        OldPageHelper pageHelper = new OldPageHelper(request, 
+                response, 
+                ctx, 
+                weblog, 
+                (date == null) ? new Date() : date, 
+                folder, 
+                page.getName(), 
+                pageContext);
         ctx.put("pageHelper", pageHelper);
         
         // Load standard Roller objects and values into the context
         WebsiteData website = loadWeblogValues(ctx, weblog, request);
         loadPathValues(ctx, request, rollerCtx, website);
-        loadRssValues(ctx, request, website, rreq.getWeblogCategory());
-        loadUtilityObjects(ctx, request, rollerCtx, website, rreq.getPage());
+        loadRssValues(ctx, request, website, category);
+        loadUtilityObjects(ctx, request, rollerCtx, website, page);
         loadRequestParamKeys(ctx);
         loadStatusMessage(ctx, request);
         
         // If single entry is specified, load comments too
-        if ( rreq.getWeblogEntry() != null ) {
-            loadCommentValues(ctx, request, rreq.getWeblogEntry());
+        if (entry != null) {
+            loadCommentValues(ctx, request, entry);
         }
         
         // add Velocity Toolbox tools to context

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/OldPageHelper.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/OldPageHelper.java?rev=416091&r1=416090&r2=416091&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/OldPageHelper.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/OldPageHelper.java
Wed Jun 21 12:51:45 2006
@@ -82,25 +82,22 @@
                       HttpServletResponse response,
                       Map ctx,
                       WebsiteData website,
-                      PageContext pageContext,
-                      WeblogPageRequest pageRequest) throws RollerException {
+                      Date date,
+                      FolderData folder,
+                      String pageName,
+                      PageContext pageContext) throws RollerException {
         
+        // general request objects
+        mRequest = request;
+        mResponse = response;
         mPageContext = pageContext;
         
-        // store the parsed page request
-        mPageRequest = pageRequest;
-        mPageName = mPageRequest.getWeblogPage();
-        
-        // old roller request, going to be eoled
-        RollerRequest mRollerReq = RollerRequest.getRollerRequest(request);
+        // data that we'll be reusing
         mWebsite = website;
-        mDate = mRollerReq.getDate(true);
-        mFolder = mRollerReq.getFolder();
-        
-        // save original request and response objects
-        mRequest = request;
-        mResponse = response;
+        mDate = date;
+        mFolder = folder;
         
+        // init plugins
         Roller roller = RollerFactory.getRoller();
         PluginManager ppmgr = roller.getPagePluginManager();
         mPagePlugins = ppmgr.getWeblogEntryPlugins(mWebsite, ctx);

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=416091&r1=416090&r2=416091&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
Wed Jun 21 12:51:45 2006
@@ -1,20 +1,21 @@
 /*
-* 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.
-*/
+ * 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.velocity.deprecated;
 
 import java.util.ArrayList;
@@ -28,7 +29,6 @@
 import java.util.Map;
 import java.util.TimeZone;
 import javax.servlet.http.HttpServletRequest;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.RollerException;
@@ -52,11 +52,10 @@
 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.core.RollerRequest;
 import org.apache.roller.ui.core.RollerSession;
 import org.apache.roller.util.DateUtil;
 import org.apache.commons.lang.StringUtils;
-import org.apache.roller.ui.rendering.util.WeblogPageRequest;
+
 
 /**
  * Provides Roller page templates with access to Roller domain model objects.
@@ -75,7 +74,6 @@
     private Map                  mCategories = new HashMap();
     private HashMap              mPageMap = new HashMap();
     private HttpServletRequest   mRequest = null;
-    private String               mHandle = null;
     private WebsiteData          mWebsite = null;
     private WeblogEntryData      mEntry = null;
     private WeblogCategoryData   mCategory = null;
@@ -99,27 +97,23 @@
     /**
      * Initialize PageModel and allow PageModel to initialized VelocityContext.
      */
-    public void init(HttpServletRequest request) {
+    public void init(HttpServletRequest request,
+            WebsiteData website,
+            WeblogEntryData entry,
+            WeblogCategoryData category,
+            Date date,
+            boolean isDay,
+            boolean isMonth) {
         
         mRequest = request;
         
-        WeblogPageRequest pageRequest = null;
-        try {
-            pageRequest = new WeblogPageRequest(request);
-        } catch(Exception e) {
-            // this should never happen because the old page model
-            // is only supposed to be use on weblog pages
-            mLogger.error("error parsing request", e);
-        }
-        
-        RollerRequest mRollerReq = RollerRequest.getRollerRequest(request);
-        mWebsite = mRollerReq.getWebsite();
-        mHandle = mWebsite.getHandle();
-        mEntry = mRollerReq.getWeblogEntry();
-        mCategory = mRollerReq.getWeblogCategory();
-        mDate = mRollerReq.getDate();
-        mIsDaySpecified = mRollerReq.isDaySpecified();
-        mIsMonthSpecified = mRollerReq.isMonthSpecified();
+        // data we'll need in the methods
+        mWebsite = website;
+        mEntry = entry;
+        mCategory = category;
+        mDate = date;
+        mIsDaySpecified = isDay;
+        mIsMonthSpecified = isMonth;
         
         try {
             mBookmarkMgr = RollerFactory.getRoller().getBookmarkManager();
@@ -173,7 +167,7 @@
         List tops = null;
         try {
             Collection mTops = mBookmarkMgr.getRootFolder(
-                    mUserMgr.getWebsiteByHandle(mHandle)).getFolders();
+                    mUserMgr.getWebsiteByHandle(mWebsite.getHandle())).getFolders();
             
             // wrap pojos
             tops = new ArrayList(mTops.size());
@@ -244,7 +238,7 @@
         try {
             return FolderDataWrapper.wrap(
                     mBookmarkMgr.getFolder(
-                    mUserMgr.getWebsiteByHandle(mHandle), folderPath));
+                    mUserMgr.getWebsiteByHandle(mWebsite.getHandle()), folderPath));
         } catch (RollerException e) {
             mLogger.error("PageModel getFolder()", e);
         }



Mime
View raw message