roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r224390 - in /incubator/roller/trunk/src/org/roller/presentation: velocity/ velocity/wrappers/ weblog/actions/ weblog/tags/
Date Fri, 22 Jul 2005 19:33:21 GMT
Author: agilliland
Date: Fri Jul 22 12:33:16 2005
New Revision: 224390

URL: http://svn.apache.org/viewcvs?rev=224390&view=rev
Log:
modifying velocity rendering process to ensure that all pojos are properly wrapped.

removed old TemplateWrapper object because we have a new one that gets generated via xdoclet.

Removed:
    incubator/roller/trunk/src/org/roller/presentation/velocity/wrappers/TemplateWrapper.java
Modified:
    incubator/roller/trunk/src/org/roller/presentation/velocity/ContextLoader.java
    incubator/roller/trunk/src/org/roller/presentation/velocity/Macros.java
    incubator/roller/trunk/src/org/roller/presentation/velocity/PageHelper.java
    incubator/roller/trunk/src/org/roller/presentation/velocity/PageModel.java
    incubator/roller/trunk/src/org/roller/presentation/weblog/actions/WeblogEntryFormAction.java
    incubator/roller/trunk/src/org/roller/presentation/weblog/tags/ApplyPluginsTag.java
    incubator/roller/trunk/src/org/roller/presentation/weblog/tags/WeblogEntryMacros.java

Modified: incubator/roller/trunk/src/org/roller/presentation/velocity/ContextLoader.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/velocity/ContextLoader.java?rev=224390&r1=224389&r2=224390&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/velocity/ContextLoader.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/velocity/ContextLoader.java Fri Jul
22 12:33:16 2005
@@ -33,12 +33,15 @@
 import org.roller.pojos.UserData;
 import org.roller.pojos.WeblogEntryData;
 import org.roller.pojos.WebsiteData;
+import org.roller.pojos.wrapper.CommentDataWrapper;
+import org.roller.pojos.wrapper.TemplateWrapper;
+import org.roller.pojos.wrapper.WeblogEntryDataWrapper;
+import org.roller.pojos.wrapper.WebsiteDataWrapper;
 import org.roller.presentation.LanguageUtil;
 import org.roller.presentation.RollerContext;
 import org.roller.presentation.RollerRequest;
 import org.roller.presentation.RollerSession;
 import org.roller.presentation.newsfeeds.NewsfeedCache;
-import org.roller.presentation.velocity.wrappers.TemplateWrapper;
 import org.roller.presentation.weblog.formbeans.CommentFormEx;
 import org.roller.util.RegexUtil;
 import org.roller.util.StringUtils;
@@ -129,6 +132,8 @@
      */
     private static void loadStatusMessage(Context ctx, RollerRequest rreq)
     {
+        mLogger.debug("Loading status message");
+        
         HttpSession session = rreq.getRequest().getSession(false);
         String msg = null;
         if (session != null)
@@ -160,8 +165,10 @@
        Context ctx, RollerRequest rreq, RollerContext rollerCtx, String userName)
        throws RollerException
     {
+        mLogger.debug("Loading weblog values");
+        
         // if there is an "_entry" page, only load it once
-        WebsiteData website = rreq.getRoller().getUserManager().getWebsite(userName);
+        WebsiteData website = RollerFactory.getRoller().getUserManager().getWebsite(userName);
         //PageModel pageModel = (PageModel)ctx.get("pageModel");
         if (website != null) 
         {
@@ -169,12 +176,12 @@
             Template entryPage = website.getPageByName("_entry");
             if (entryPage != null)
             {
-                ctx.put("entryPage", new TemplateWrapper(entryPage));
+                ctx.put("entryPage", TemplateWrapper.wrap(entryPage));
             }
             Template descPage = website.getPageByName("_desc");
             if (descPage != null)
             {
-                ctx.put("descPage", new TemplateWrapper(descPage));
+                ctx.put("descPage", TemplateWrapper.wrap(descPage));
             }
         }
     }
@@ -210,6 +217,8 @@
        Context ctx, RollerRequest rreq, RollerContext rollerCtx ) 
        throws RollerException
     {
+        mLogger.debug("Loading comment values");
+        
         HttpServletRequest request = rreq.getRequest();
         
         String escapeHtml = RollerRuntimeConfig.getProperty("users.comments.escapehtml");
@@ -241,11 +250,11 @@
             ArrayList list = new ArrayList();
             CommentData cd = new CommentData();
             commentForm.copyTo(cd, request.getLocale());
-            list.add(cd);
+            list.add(CommentDataWrapper.wrap(cd));
             ctx.put("previewComments",list);            
         }
         WeblogEntryData entry = rreq.getWeblogEntry();
-        ctx.put("entry",entry);            
+        ctx.put("entry", WeblogEntryDataWrapper.wrap(entry));            
     }   
 
     //------------------------------------------------------------------------
@@ -254,6 +263,8 @@
         Context ctx, RollerRequest rreq, RollerContext rollerCtx, String userName) 
         throws RollerException
     {
+        mLogger.debug("Loading path values");
+        
         HttpServletRequest request = rreq.getRequest();
         String url = null;
         if ( userName != null && !userName.equals("zzz_none_zzz"))
@@ -286,6 +297,8 @@
     
     protected static void loadRequestParamKeys(Context ctx)
     {
+        mLogger.debug("Loading request param keys");
+        
         // Since Velocity *requires* accessor methods, these values from
         // RollerRequest are not available to it, put them into the context
         ctx.put("USERNAME_KEY",           RollerRequest.USERNAME_KEY);
@@ -311,6 +324,8 @@
     protected static void loadRssValues(
        Context ctx, RollerRequest rreq, String userName) throws RollerException
     {
+        mLogger.debug("Loading rss values");
+        
         HttpServletRequest request = rreq.getRequest();
         
         int entryLength = -1;
@@ -357,13 +372,14 @@
         Context ctx, RollerRequest rreq, RollerContext rollerCtx, String username)
         throws RollerException
     {
-
+        mLogger.debug("Loading utility objects");
+        
         // date formatter for macro's
         // set this up with the Locale to make sure we can reuse it with other patterns
         // in the macro's
         Locale viewLocale = (Locale) ctx.get("viewLocale");
         SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd", viewLocale);
-        WebsiteData website = rreq.getRoller().getUserManager().getWebsite(username);
+        WebsiteData website = RollerFactory.getRoller().getUserManager().getWebsite(username);
         if (website != null)
         {
             sdf.setTimeZone(website.getTimeZoneInstance());
@@ -376,7 +392,7 @@
         // the Entry Day link.
         ctx.put("plainFormat", "yyyyMMdd");
 
-        ctx.put("page",            new TemplateWrapper(rreq.getPage()));
+        ctx.put("page",            TemplateWrapper.wrap(rreq.getPage()));
         ctx.put("utilities",       new Utilities() );
         ctx.put("stringUtils",     new StringUtils() );        
         ctx.put("rollerVersion",   rollerCtx.getRollerVersion() );
@@ -393,6 +409,8 @@
         Context ctx, RollerRequest rreq, RollerContext rollerCtx )
         throws RollerException
     {
+        mLogger.debug("Loading website values");
+        
         String userName = null;
         UserData user = null;
         WebsiteData website = null;
@@ -413,7 +431,7 @@
         if ( user != null )
         {
             userName = user.getUserName();
-            website = rreq.getRoller().getUserManager().getWebsite(userName);
+            website = RollerFactory.getRoller().getUserManager().getWebsite(userName);
             ctx.put("userName",      user.getUserName() );
             ctx.put("fullName",      user.getFullName() );
             ctx.put("emailAddress",  user.getEmailAddress() );
@@ -441,7 +459,7 @@
             ctx.put("locale", Locale.getDefault());
             ctx.put("timezone", TimeZone.getDefault());
         }
-        ctx.put("website", website );
+        ctx.put("website", WebsiteDataWrapper.wrap(website) );
 
         String siteName = ((RollerPropertyData)props.get("site.name")).getValue();
         if ("Roller-based Site".equals(siteName)) siteName = "Main";
@@ -468,6 +486,8 @@
      */
     public static void initializePagePlugins(ServletContext mContext)
     {
+        mLogger.debug("Initializing page plugins");
+        
         String pluginStr = RollerConfig.getProperty("plugins.page");
         if (mLogger.isDebugEnabled()) mLogger.debug(pluginStr);
         if (pluginStr != null)
@@ -540,6 +560,8 @@
     private static ToolboxContext loadToolboxContext(
                     HttpServletRequest request, HttpServletResponse response, Context ctx)

     {
+        mLogger.debug("Loading toolbox context");
+        
         ServletContext servletContext = RollerContext.getServletContext();
 
         // get the toolbox manager

Modified: incubator/roller/trunk/src/org/roller/presentation/velocity/Macros.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/velocity/Macros.java?rev=224390&r1=224389&r2=224390&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/velocity/Macros.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/velocity/Macros.java Fri Jul 22 12:33:16
2005
@@ -7,8 +7,6 @@
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.runtime.RuntimeSingleton;
 import org.roller.model.RefererManager;
-import org.roller.model.UserManager;
-import org.roller.pojos.WeblogTemplate;
 import org.roller.pojos.RefererData;
 import org.roller.pojos.UserData;
 import org.roller.pojos.WeblogCategoryData;
@@ -37,6 +35,8 @@
 import javax.servlet.jsp.PageContext;
 import org.roller.config.RollerRuntimeConfig;
 import org.roller.model.RollerFactory;
+import org.roller.pojos.wrapper.UserDataWrapper;
+import org.roller.pojos.wrapper.WebsiteDataWrapper;
 
 /**
  * Provides the macros object that is available to Roller templates and 
@@ -279,11 +279,11 @@
      * @see org.roller.pojos.UserData
      * @return User object.
      */
-    public UserData getUser()
+    public UserDataWrapper getUser()
     {
         try
         {
-            return getRollerRequest().getUser();
+            return UserDataWrapper.wrap(getRollerRequest().getUser());
         }
         catch (Exception e)
         {
@@ -300,11 +300,11 @@
      * @see org.roller.pojos.WebsiteData
      * @return Website object.
      */
-    public WebsiteData getWebsite()
+    public WebsiteDataWrapper getWebsite()
     {
         try
         {
-            return getRollerRequest().getWebsite();
+            return WebsiteDataWrapper.wrap(getRollerRequest().getWebsite());
         }
         catch (Exception e)
         {
@@ -494,7 +494,7 @@
             sb.append("excerpts</a>]");
             sb.append("<br />");
 
-			List cats = rreq.getRoller().getWeblogManager()
+			List cats = RollerFactory.getRoller().getWeblogManager()
                 .getWeblogCategories(rreq.getWebsite(), false);
 			for (Iterator wbcItr = cats.iterator(); wbcItr.hasNext();) {
 				WeblogCategoryData category = (WeblogCategoryData) wbcItr.next();
@@ -1022,7 +1022,7 @@
         try
         {
             RollerRequest rreq = getRollerRequest();
-            RefererManager refmgr = rreq.getRoller().getRefererManager();
+            RefererManager refmgr = RollerFactory.getRoller().getRefererManager();
 
             StringBuffer sb = new StringBuffer();
             

Modified: incubator/roller/trunk/src/org/roller/presentation/velocity/PageHelper.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/velocity/PageHelper.java?rev=224390&r1=224389&r2=224390&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/velocity/PageHelper.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/velocity/PageHelper.java Fri Jul 22
12:33:16 2005
@@ -5,10 +5,8 @@
 import org.apache.struts.Globals;
 import org.apache.struts.util.RequestUtils;
 import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.Velocity;
 import org.apache.velocity.context.Context;
 import org.roller.RollerException;
-import org.roller.pojos.RefererData;
 import org.roller.pojos.UserData;
 import org.roller.pojos.WeblogEntryData;
 import org.roller.presentation.LanguageUtil;
@@ -21,8 +19,6 @@
 import org.roller.presentation.weblog.tags.BigWeblogCalendarModel;
 import org.roller.presentation.weblog.tags.WeblogCalendarModel;
 import org.roller.util.StringUtils;
-
-import java.io.StringWriter;
 import java.net.MalformedURLException;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -35,6 +31,8 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.jsp.PageContext;
+import org.roller.pojos.wrapper.RefererDataWrapper;
+import org.roller.pojos.wrapper.WeblogEntryDataWrapper;
 
 /**
  * Provides assistance to VelociMacros, filling in where Velocity falls.
@@ -181,7 +179,7 @@
     }
    
     /** Build the URL for editing an WeblogEntry **/
-    public String getEntryEditUrl(WeblogEntryData entry)
+    public String getEntryEditUrl(WeblogEntryDataWrapper entry)
     {
         Hashtable params = new Hashtable();
         params.put( RollerRequest.WEBLOGENTRYID_KEY, entry.getId());
@@ -204,7 +202,7 @@
     }
     
     //-------------------------------------------------------------------------
-    public String getToggleLinkbackDisplayHTML(RefererData referer)
+    public String getToggleLinkbackDisplayHTML(RefererDataWrapper referer)
     {
         String ret = "";
         String link = null;
@@ -473,14 +471,21 @@
      */
     public String renderPlugins(String str)
     {
+        mLogger.debug("Rendering page plugins on String");
+        
         if (mPagePlugins != null)
         {
             Iterator iter = mPagePlugins.iterator();
+            PagePlugin plugin = null;
             while (iter.hasNext())
             {
-                str = ((PagePlugin)iter.next()).render(str);
+                plugin = (PagePlugin) iter.next();
+                
+                mLogger.debug("applying plugin - ");
+                str = plugin.render(str);
             }
         }
+        
         return str;
     }
     
@@ -491,12 +496,14 @@
      * @param str
      * @return
      */
-    public String renderPlugins(WeblogEntryData entry)
+    public String renderPlugins(WeblogEntryDataWrapper entry)
     {
+        mLogger.debug("Rendering page plugins on WeblogEntryData");
+        
         // we have to make a copy to temporarily store the
         // changes wrought by Plugins (otherwise they might
         // end up persisted!).
-        WeblogEntryData copy = new WeblogEntryData(entry);
+        WeblogEntryData copy = new WeblogEntryData(entry.getPojo());
         
         if (mPagePlugins != null)
         {
@@ -526,6 +533,7 @@
                 }
             }
         }
+        
         return copy.getText();
     }
     

Modified: incubator/roller/trunk/src/org/roller/presentation/velocity/PageModel.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/velocity/PageModel.java?rev=224390&r1=224389&r2=224390&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/velocity/PageModel.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/velocity/PageModel.java Fri Jul 22
12:33:16 2005
@@ -15,19 +15,25 @@
 import org.roller.config.RollerRuntimeConfig;
 import org.roller.model.BookmarkManager;
 import org.roller.model.RefererManager;
+import org.roller.model.Roller;
+import org.roller.model.RollerFactory;
 import org.roller.pojos.Template;
 import org.roller.model.UserManager;
 import org.roller.model.WeblogManager;
-import org.roller.pojos.BookmarkComparator;
+import org.roller.pojos.CommentData;
 import org.roller.pojos.FolderData;
-import org.roller.pojos.WeblogTemplate;
 import org.roller.pojos.RefererData;
 import org.roller.pojos.UserData;
 import org.roller.pojos.WeblogCategoryData;
 import org.roller.pojos.WeblogEntryData;
 import org.roller.pojos.WebsiteData;
+import org.roller.pojos.wrapper.CommentDataWrapper;
+import org.roller.pojos.wrapper.FolderDataWrapper;
+import org.roller.pojos.wrapper.RefererDataWrapper;
+import org.roller.pojos.wrapper.TemplateWrapper;
+import org.roller.pojos.wrapper.WeblogCategoryDataWrapper;
+import org.roller.pojos.wrapper.WeblogEntryDataWrapper;
 import org.roller.presentation.RollerRequest;
-import org.roller.presentation.velocity.wrappers.TemplateWrapper;
 import org.roller.util.StringUtils;
 
 /**
@@ -54,12 +60,12 @@
     private String               mUsername = null;
     private WebsiteData          mWebsite = null;
     
-    private WeblogEntryData      mNextEntry = null;
-    private WeblogEntryData      mPreviousEntry = null;
+    private WeblogEntryDataWrapper      mNextEntry = null;
+    private WeblogEntryDataWrapper      mPreviousEntry = null;
 
-    private WeblogEntryData      mLastEntry = null;
+    private WeblogEntryDataWrapper      mLastEntry = null;
 
-    private WeblogEntryData mFirstEntry;
+    private WeblogEntryDataWrapper      mFirstEntry = null;
         
     //------------------------------------------------------------------------
     
@@ -91,10 +97,11 @@
         
         try
         {
-            mBookmarkMgr = rreq.getRoller().getBookmarkManager();
-            mRefererMgr  = rreq.getRoller().getRefererManager();
-            mUserMgr     = rreq.getRoller().getUserManager();
-            mWeblogMgr   = rreq.getRoller().getWeblogManager();
+            Roller mRoller = RollerFactory.getRoller();
+            mBookmarkMgr = mRoller.getBookmarkManager();
+            mRefererMgr  = mRoller.getRefererManager();
+            mUserMgr     = mRoller.getUserManager();
+            mWeblogMgr   = mRoller.getWeblogManager();
             
             /** 
              * Preload what we can for encapsulation.  What we cannot preload we
@@ -113,7 +120,7 @@
                 while (pageIter.hasNext())
                 {
                     Template page = (Template) pageIter.next();
-                    mPageMap.put(page.getName(), new TemplateWrapper(page));
+                    mPageMap.put(page.getName(), TemplateWrapper.wrap(page));
                 }
             }
             
@@ -127,12 +134,19 @@
     //------------------------------------------------------------------------
     
     /** Encapsulates folder.getBookmarks() & sorting */
-    public Collection getBookmarks(FolderData folder)
+    public Collection getBookmarks(FolderDataWrapper folder)
     {
+        mLogger.debug("Getting bookmarks for folder : "+folder.getName());
+        
+        // since we already have a wrapped pojo we know the output
+        // will be wrapped as well :)
         Collection bookmarks = folder.getBookmarks();
-        List list = new ArrayList(bookmarks);
-        Collections.sort( list, new BookmarkComparator() );
-        return list;
+        
+        // TODO: need to setup new BookmarkWrapperComparator
+        //List mBookmarks = new ArrayList(bookmarks);
+        //Collections.sort( mBookmarks, new BookmarkComparator() );
+        
+        return bookmarks;
     }
     
     //------------------------------------------------------------------------
@@ -140,10 +154,19 @@
     /** Get top level bookmark folders. */
     public Collection getTopLevelFolders()
     {
-        Collection tops = null;
+        List tops = null;
         try
         {
-         tops= mBookmarkMgr.getRootFolder(mWebsite).getFolders();
+            Collection mTops = mBookmarkMgr.getRootFolder(mWebsite).getFolders();
+            
+            // wrap pojos
+            tops = new ArrayList(mTops.size());
+            Iterator it = mTops.iterator();
+            int i=0;
+            while(it.hasNext()) {
+                tops.add(i, FolderDataWrapper.wrap((FolderData) it.next()));
+                i++;
+            }
         }
         catch (RollerException e)
         {
@@ -173,15 +196,25 @@
     /** Get comments for weblog entry specified by request */
     public List getComments( WeblogEntryData entry )
     {
+        List comments = new ArrayList();
         try
         {
-            return mWeblogMgr.getComments( entry.getId() );
+            Collection mComments = mWeblogMgr.getComments( entry.getId() );
+            
+            // wrap pojos
+            comments = new ArrayList(mComments.size());
+            Iterator it = mComments.iterator();
+            int i=0;
+            while(it.hasNext()) {
+                comments.add(i, CommentDataWrapper.wrap((CommentData) it.next()));
+                i++;
+            }
         }
         catch (RollerException e)
         {
             mLogger.error("PageModel getComments()", e);
         }
-        return new ArrayList();
+        return comments;
     }
     
     //------------------------------------------------------------------------
@@ -203,12 +236,12 @@
     //------------------------------------------------------------------------
     
     /** Encapsulates BookmarkManager.getFolder() */
-    public FolderData getFolder(String folderPath)
+    public FolderDataWrapper getFolder(String folderPath)
     {
         try
         {
-            return mBookmarkMgr.getFolder(
-                mWebsite, folderPath);
+            return FolderDataWrapper.wrap(
+                    mBookmarkMgr.getFolder(mWebsite, folderPath));
         }
         catch (RollerException e)
         {
@@ -220,9 +253,9 @@
     //------------------------------------------------------------------------
     
     /** Encapsulates UserManager.getPageByName() */
-    public Template getUsersPageByName(WebsiteData website, String pageName)
+    public TemplateWrapper getUsersPageByName(WebsiteData website, String pageName)
     {
-        Template page = null;
+        TemplateWrapper page = null;
         try
         {
             if (website == null) 
@@ -231,7 +264,7 @@
             if (pageName == null) 
                 throw new NullPointerException("pageName is null");
                 
-            page = website.getPageByName(pageName);
+            page = TemplateWrapper.wrap(website.getPageByName(pageName));
         }
         catch (NullPointerException npe)
         {
@@ -247,9 +280,9 @@
     //------------------------------------------------------------------------
     
     /** Encapsulates UserManager.getPageByName() */
-    public WeblogTemplate getPageByName(String pageName)
+    public TemplateWrapper getPageByName(String pageName)
     {
-        return (WeblogTemplate)mPageMap.get(pageName);
+        return (TemplateWrapper) mPageMap.get(pageName);
     }
     
     //------------------------------------------------------------------------
@@ -336,7 +369,7 @@
                 }
             }
             
-            ret = mRollerReq.getRoller().getWeblogManager().getWeblogEntryObjectMap(
+            Map mRet = RollerFactory.getRoller().getWeblogManager().getWeblogEntryObjectMap(
                             mRollerReq.getWebsite(),  
                             null,                     // startDate
                             day,                 // endDate
@@ -344,6 +377,22 @@
                             WeblogManager.PUB_ONLY,   // status
                             new Integer(maxEntries)); // maxEntries
             
+            // need to wrap pojos
+            java.util.Date key = null;
+            Iterator days = mRet.keySet().iterator();
+            while(days.hasNext()) {
+                key = (java.util.Date)days.next();
+                
+                // now we need to go through each entry in a day and wrap
+                List wrappedEntries = new ArrayList();
+                List entries = (List) mRet.get(key);
+                for(int i=0; i < entries.size(); i++) {
+                    wrappedEntries.add(i, 
+                            WeblogEntryDataWrapper.wrap((WeblogEntryData)entries.get(i)));
+                }
+                ret.put(key, wrappedEntries);
+            }
+            
             setFirstAndLastEntries( ret );
         }
         catch (Exception e)
@@ -370,7 +419,7 @@
             int valSize = vals.size();
             if (valSize > 0) 
             {
-                mFirstEntry = (WeblogEntryData)vals.get(0);
+                mFirstEntry = (WeblogEntryDataWrapper)vals.get(0);
             }
             
             // get last entry in map
@@ -378,7 +427,7 @@
             valSize = vals.size();
             if (valSize > 0)
             {
-                mLastEntry = (WeblogEntryData)vals.get(--valSize);
+                mLastEntry = (WeblogEntryDataWrapper)vals.get(--valSize);
             }
         }
     }
@@ -426,18 +475,27 @@
                     catParam = null;
                 }
             }
-            WeblogManager mgr = mRollerReq.getRoller().getWeblogManager();
+            WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
             
             //ret = mgr.getRecentWeblogEntriesArray( 
                 //name, day, catParam, maxEntries, true );
             
-            ret = mgr.getWeblogEntries(
+            List mEntries = mgr.getWeblogEntries(
                             mRollerReq.getWebsite(), 
                             null,                    // startDate
                             day,                      // endDate
                             catParam,                 // catName
                             WeblogManager.PUB_ONLY,   // status
                             new Integer(maxEntries)); // maxEntries
+            
+            // wrap pojos
+            ret = new ArrayList(mEntries.size());
+            Iterator it = mEntries.iterator();
+            int i=0;
+            while(it.hasNext()) {
+                ret.add(i, WeblogEntryDataWrapper.wrap((WeblogEntryData) it.next()));
+                i++;
+            }
         }
         catch (Exception e)
         {
@@ -468,7 +526,7 @@
                     if (   referer.getVisible().booleanValue() 
                         || this.mRollerReq.isUserAuthorizedToEdit() )
                     { 
-                        referers.add(referer);
+                        referers.add(RefererDataWrapper.wrap(referer));
                     }
                 }
             }
@@ -490,7 +548,16 @@
         List referers = null;
         try
         {
-            referers = mRefererMgr.getTodaysReferers(mRollerReq.getWebsite());
+            List mReferers = mRefererMgr.getTodaysReferers(mRollerReq.getWebsite());
+            
+            // wrap pojos
+            referers = new ArrayList(mReferers.size());
+            Iterator it = mReferers.iterator();
+            int i=0;
+            while(it.hasNext()) {
+                referers.add(i, RefererDataWrapper.wrap((RefererData) it.next()));
+                i++;
+            }
          
         }
         catch (RollerException e)
@@ -528,6 +595,7 @@
         Iterator iter = weblogEntries.iterator();
         while (iter.hasNext())
         {
+            // NOTE: this will need to be WeblogEntryDataWrapper
             WeblogEntryData wd = (WeblogEntryData)iter.next();
             if ( updateTime == null )
             {
@@ -570,7 +638,18 @@
                 {
                     category = mRollerReq.getWebsite().getDefaultCategory();
                 }
-                ret = category.getWeblogCategories();
+                
+                List mRet = category.getWeblogCategories();
+                
+                // wrap pojos
+                ret = new ArrayList(mRet.size());
+                Iterator it = mRet.iterator();
+                int i=0;
+                while(it.hasNext()) {
+                    ret.add(i, WeblogCategoryDataWrapper.wrap((WeblogCategoryData) it.next()));
+                    i++;
+                }
+        
                 mCategories.put(categoryName, ret);
             }
             catch (RollerException e) 
@@ -584,9 +663,14 @@
     //------------------------------------------------------------------------
     
     /** Encapsulates RollerRequest.getWeblogEntry() */
-    public WeblogEntryData getWeblogEntry()
+    public WeblogEntryDataWrapper getWeblogEntry()
     {
-        return mRollerReq.getWeblogEntry();
+        WeblogEntryData entry = mRollerReq.getWeblogEntry();
+        
+        if(entry != null)
+            return WeblogEntryDataWrapper.wrap(entry);
+        else
+            return null;
     }
     
     //------------------------------------------------------------------------
@@ -594,9 +678,9 @@
     /**
      * Get the next occurring Entry.
      */
-    public WeblogEntryData getNextEntry()
+    public WeblogEntryDataWrapper getNextEntry()
     {
-        WeblogEntryData currentEntry = getWeblogEntry();
+        WeblogEntryDataWrapper currentEntry = getWeblogEntry();
         if (mFirstEntry != null) currentEntry = mFirstEntry;
         if (mNextEntry == null && currentEntry != null) 
         {
@@ -607,7 +691,11 @@
             }
             try
             {
-                mNextEntry = mWeblogMgr.getNextEntry(currentEntry, catName);
+                WeblogEntryData nextEntry = 
+                        mWeblogMgr.getNextEntry(currentEntry.getPojo(), catName);
+                
+                if(nextEntry != null)
+                    mNextEntry = WeblogEntryDataWrapper.wrap(nextEntry);
                 
                 // make sure that mNextEntry is not published to future
                 if (mNextEntry != null && 
@@ -629,12 +717,12 @@
     /**
      * Get the previous occurring Entry.
      */
-    public WeblogEntryData getPreviousEntry()
+    public WeblogEntryDataWrapper getPreviousEntry()
     {
-        WeblogEntryData currentEntry = getWeblogEntry();
+        WeblogEntryDataWrapper currentEntry = getWeblogEntry();
         if (mLastEntry != null) currentEntry = mLastEntry;
         if (mPreviousEntry == null && currentEntry != null )
-        {
+        {   
             String catName = null;
             if (mRollerReq.getWeblogCategory() != null)
             {
@@ -642,7 +730,11 @@
             }
             try
             {
-                mPreviousEntry = mWeblogMgr.getPreviousEntry(currentEntry, catName);
+                WeblogEntryData prevEntry = 
+                        mWeblogMgr.getPreviousEntry(currentEntry.getPojo(), catName);
+                
+                if(prevEntry != null)
+                    mPreviousEntry = WeblogEntryDataWrapper.wrap(prevEntry);
             }
             catch (RollerException e)
             {
@@ -676,18 +768,22 @@
     
     //------------------------------------------------------------------------
     
-    public FolderData getFolderByPath(String path)
+    public FolderDataWrapper getFolderByPath(String path)
     {
         try
         {
-            return mBookmarkMgr.getFolderByPath(
+            FolderData folder = mBookmarkMgr.getFolderByPath(
                 mUserMgr.getWebsite(mUsername), null, path);
+            
+            if(folder != null)
+                return FolderDataWrapper.wrap(folder);
         }
         catch (RollerException e)
         {
             mLogger.error(e);
-            return null;
         }
+        
+        return null;
     }
 
     /**
@@ -698,15 +794,25 @@
      */
     public List getRecentComments(int maxCount)
     {
+        List recentComments = new ArrayList();
         try
         {
-            return mWeblogMgr.getRecentComments(mRollerReq.getWebsite(), maxCount);
+            List recent = mWeblogMgr.getRecentComments(mRollerReq.getWebsite(), maxCount);
+            
+            // wrap pojos
+            recentComments = new ArrayList(recent.size());
+            Iterator it = recent.iterator();
+            int i=0;
+            while(it.hasNext()) {
+                recentComments.add(i, CommentDataWrapper.wrap((CommentData) it.next()));
+                i++;
+            }
         }
         catch (RollerException e)
         {
             mLogger.error(e);
-            return new ArrayList();
         }
+        return recentComments;
     }
  
     public boolean getEmailComments() 

Modified: incubator/roller/trunk/src/org/roller/presentation/weblog/actions/WeblogEntryFormAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/weblog/actions/WeblogEntryFormAction.java?rev=224390&r1=224389&r2=224390&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/weblog/actions/WeblogEntryFormAction.java
(original)
+++ incubator/roller/trunk/src/org/roller/presentation/weblog/actions/WeblogEntryFormAction.java
Fri Jul 22 12:33:16 2005
@@ -44,6 +44,7 @@
 import org.roller.pojos.UserData;
 import org.roller.pojos.WeblogEntryData;
 import org.roller.pojos.WebsiteData;
+import org.roller.pojos.wrapper.WeblogEntryDataWrapper;
 import org.roller.presentation.MainPageAction;
 import org.roller.presentation.RollerContext;
 import org.roller.presentation.RollerRequest;
@@ -53,6 +54,7 @@
 import org.roller.util.Utilities;
 
 import com.swabunga.spell.event.SpellCheckEvent;
+import org.roller.model.RollerFactory;
 
 
 
@@ -126,7 +128,7 @@
             RollerRequest rreq = RollerRequest.getRollerRequest(request);
             if ( rreq.isUserAuthorizedToEdit() )
             {
-                WeblogManager wmgr = rreq.getRoller().getWeblogManager();
+                WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
                 WeblogEntryData entry = rreq.getWeblogEntry();
                 WeblogEntryFormEx form = (WeblogEntryFormEx)actionForm;
                 if (entry == null && form.getId() != null)
@@ -233,8 +235,8 @@
             RollerRequest rreq = RollerRequest.getRollerRequest(request);
             if ( rreq.isUserAuthorizedToEdit() )
             {
-                UserManager userMgr = rreq.getRoller().getUserManager();
-                WeblogManager weblogMgr = rreq.getRoller().getWeblogManager();
+                UserManager userMgr = RollerFactory.getRoller().getUserManager();
+                WeblogManager weblogMgr = RollerFactory.getRoller().getWeblogManager();
 
                 UserData user = rreq.getUser();
                 WebsiteData site = userMgr.getWebsite( user.getUserName() );
@@ -290,12 +292,12 @@
                 entry.setUpdateTime(new Timestamp(new Date().getTime()));
                 mLogger.debug("Saving entry");
                 entry.save();
-                rreq.getRoller().commit();
+                RollerFactory.getRoller().commit();
 
                 mLogger.debug("Populating form");
                 wf.copyFrom(entry, request.getLocale());
                 
-                reindexEntry(rreq.getRoller(), entry);
+                reindexEntry(RollerFactory.getRoller(), entry);
                 
                 // open up a new session, because we will forward to the edit action
                 //rreq.getRoller().begin(); // begin already called by RequestFilter
@@ -424,7 +426,7 @@
             {
                 WeblogEntryFormEx wf = (WeblogEntryFormEx)actionForm;
                 WeblogEntryData wd = 
-                    rreq.getRoller().getWeblogManager().retrieveWeblogEntry(wf.getId());
+                    RollerFactory.getRoller().getWeblogManager().retrieveWeblogEntry(wf.getId());
                 wf.copyFrom(wd, request.getLocale());
                 if (wd == null || wd.getId() == null)
                 {
@@ -462,17 +464,17 @@
             RollerRequest rreq = RollerRequest.getRollerRequest(request);
             if ( rreq.isUserAuthorizedToEdit() )
             {
-                WeblogManager mgr = rreq.getRoller().getWeblogManager();
+                WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
                 WeblogEntryData wd = mgr.retrieveWeblogEntry(request.getParameter("id"));
                 UserData user = rreq.getUser();
                 
 				// remove the index for it
                 wd.setPublishEntry(Boolean.FALSE);
-		        reindexEntry(rreq.getRoller(), wd);
+		        reindexEntry(RollerFactory.getRoller(), wd);
 
                 // remove entry itself
                 wd.remove();
-                rreq.getRoller().commit();
+                RollerFactory.getRoller().commit();
 
 				// flush caches
                 PageCacheFilter.removeFromCache(request, user);
@@ -628,7 +630,7 @@
                 WeblogEntryFormEx form = (WeblogEntryFormEx)actionForm;
 
                 // If form indicates that comments should be deleted, then delete
-                WeblogManager mgr = rreq.getRoller().getWeblogManager();
+                WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
                 String[] deleteIds = form.getDeleteComments();
                 if (deleteIds != null && deleteIds.length > 0)
                 {
@@ -659,9 +661,9 @@
                     }
                 }
 
-                rreq.getRoller().commit();
+                RollerFactory.getRoller().commit();
                 
-                reindexEntry(rreq.getRoller(), wd);
+                reindexEntry(RollerFactory.getRoller(), wd);
                 
                 request.setAttribute("model",
                         new WeblogEntryPageModel(request, response, mapping, 
@@ -712,7 +714,7 @@
                }
 
                RollerContext rctx= RollerContext.getRollerContext(request);
-               WeblogManager wmgr= rreq.getRoller().getWeblogManager();
+               WeblogManager wmgr= RollerFactory.getRoller().getWeblogManager();
                entry = wmgr.retrieveWeblogEntry(entryid);
 
                String title = entry.getTitle();
@@ -720,7 +722,9 @@
                // Run entry through registered PagePlugins
                PageHelper pageHelper = PageHelper.createPageHelper(request, response);
                pageHelper.setSkipFlag(true); // don't process ReadMorePlugin
-               String excerpt = pageHelper.renderPlugins(entry);
+               // we have to wrap the entry for rendering because the
+               // page helper requires wrapped objects
+               String excerpt = pageHelper.renderPlugins(WeblogEntryDataWrapper.wrap(entry));
                excerpt = StringUtils.left( Utilities.removeHTML(excerpt),255 );
 
                String url = rctx.createEntryPermalink(entry, request, true);

Modified: incubator/roller/trunk/src/org/roller/presentation/weblog/tags/ApplyPluginsTag.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/weblog/tags/ApplyPluginsTag.java?rev=224390&r1=224389&r2=224390&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/weblog/tags/ApplyPluginsTag.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/weblog/tags/ApplyPluginsTag.java Fri
Jul 22 12:33:16 2005
@@ -16,6 +16,7 @@
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.tagext.TagSupport;
+import org.roller.pojos.wrapper.WeblogEntryDataWrapper;
 
 /**
  * Apply configured PagePlugins to WeblogEntryData and display the result.
@@ -58,7 +59,7 @@
             }
             helper.setSkipFlag(skipFlag);
     
-            xformed = helper.renderPlugins(entry);
+            xformed = helper.renderPlugins(WeblogEntryDataWrapper.wrap(entry));
         }
         else
         {

Modified: incubator/roller/trunk/src/org/roller/presentation/weblog/tags/WeblogEntryMacros.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/weblog/tags/WeblogEntryMacros.java?rev=224390&r1=224389&r2=224390&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/weblog/tags/WeblogEntryMacros.java
(original)
+++ incubator/roller/trunk/src/org/roller/presentation/weblog/tags/WeblogEntryMacros.java
Fri Jul 22 12:33:16 2005
@@ -7,7 +7,6 @@
 import org.roller.model.Roller;
 import org.roller.model.WeblogManager;
 import org.roller.pojos.RefererData;
-import org.roller.pojos.WeblogEntryData;
 import org.roller.presentation.RollerRequest;
 import org.roller.presentation.velocity.Macros;
 
@@ -20,6 +19,9 @@
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.jsp.PageContext;
+import org.roller.model.RollerFactory;
+import org.roller.pojos.wrapper.RefererDataWrapper;
+import org.roller.pojos.wrapper.WeblogEntryDataWrapper;
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -53,11 +55,11 @@
         {
             List refs = null;
             
-            Roller roller = getRollerRequest().getRoller();
+            Roller roller = RollerFactory.getRoller();
             String userName = getRollerRequest().getUser().getUserName();
             RefererManager refmgr = roller.getRefererManager();
              
-            refs = refmgr.getReferersToDate( getWebsite(), view("yyyyMMdd") ); 
+            refs = refmgr.getReferersToDate( getWebsite().getPojo(), view("yyyyMMdd") );

                 
             for (Iterator rdItr = refs.iterator(); rdItr.hasNext();) {
 					RefererData referer = (RefererData) rdItr.next();
@@ -70,7 +72,7 @@
 					if (   referer.getVisible().booleanValue() 
 						|| getRollerRequest().isUserAuthorizedToEdit() )
 					{ 
-						list.add( referer );
+						list.add( RefererDataWrapper.wrap(referer) );
 					}
 				}
               
@@ -115,7 +117,7 @@
      * instead.
      * @return HTML for displaying entry permalink icon with permalink.
      */
-    public String showEntryPermalink( WeblogEntryData entry )
+    public String showEntryPermalink( WeblogEntryDataWrapper entry )
     {
         HttpServletRequest request = getRollerRequest().getRequest();
         String userName = getRollerRequest().getUser().getUserName();
@@ -189,7 +191,7 @@
 
     //-----------------------------------------------------------------------
 
-    public String showCommentsLink( WeblogEntryData entry )
+    public String showCommentsLink( WeblogEntryDataWrapper entry )
     {
         if (entry.getWebsite().getAllowComments().booleanValue())
         {
@@ -201,7 +203,7 @@
             try
             {
                 rreq = RollerRequest.getRollerRequest(request);
-                WeblogManager mgr = rreq.getRoller().getWeblogManager();
+                WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
                 List comments = mgr.getComments( entry.getId() );
                 commentCount = comments.size();
             }



Mime
View raw message