roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r355129 - /incubator/roller/trunk/src/org/roller/presentation/velocity/PageModel.java
Date Thu, 08 Dec 2005 15:43:02 GMT
Author: snoopdave
Date: Thu Dec  8 07:42:56 2005
New Revision: 355129

URL: http://svn.apache.org/viewcvs?rev=355129&view=rev
Log:
Fix in page model's per-request category cache

Modified:
    incubator/roller/trunk/src/org/roller/presentation/velocity/PageModel.java

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=355129&r1=355128&r2=355129&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/velocity/PageModel.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/velocity/PageModel.java Thu Dec  8
07:42:56 2005
@@ -38,32 +38,31 @@
 
 /**
  * Provides Roller page templates with access to Roller domain model objects.
- *  
+ *
  * @author llavandowska
  * @author David M Johnson
  */
-public class PageModel
-{
+public class PageModel {
     public final static String VELOCITY_NULL = "nil";
     
-    protected static Log mLogger = 
-       LogFactory.getFactory().getInstance(PageModel.class);
+    protected static Log mLogger =
+            LogFactory.getFactory().getInstance(PageModel.class);
     
     private BookmarkManager      mBookmarkMgr = null;
     private WeblogManager        mWeblogMgr = null;
     private UserManager          mUserMgr = null;
     private RefererManager       mRefererMgr = null;
-
+    
     private Map                  mCategories = new HashMap();
     private HashMap              mPageMap = new HashMap();
     private RollerRequest        mRollerReq = null;
     private String               mHandle = null;
-    private WebsiteData          mWebsite = null;    
+    private WebsiteData          mWebsite = null;
     private WeblogEntryDataWrapper      mNextEntry = null;
     private WeblogEntryDataWrapper      mPreviousEntry = null;
     private WeblogEntryDataWrapper      mLastEntry = null;
     private WeblogEntryDataWrapper      mFirstEntry = null;
-        
+    
     //------------------------------------------------------------------------
     
     /** init() must be called to complete construction */
@@ -74,49 +73,40 @@
      * @param rreq
      * @param ctx
      */
-    public void init(RollerRequest rreq)
-    {
+    public void init(RollerRequest rreq) {
         mRollerReq = rreq;
-        if ( rreq.getRequest().getAttribute(RollerRequest.OWNING_WEBSITE) != null)
-        {
+        if ( rreq.getRequest().getAttribute(RollerRequest.OWNING_WEBSITE) != null) {
             mWebsite = (WebsiteData)
-                rreq.getRequest().getAttribute(RollerRequest.OWNING_WEBSITE);
+            rreq.getRequest().getAttribute(RollerRequest.OWNING_WEBSITE);
             mHandle = mWebsite.getHandle();
-        }
-        else if ( rreq.getWebsite() != null )
-        {
+        } else if ( rreq.getWebsite() != null ) {
             mWebsite = rreq.getWebsite();
             mHandle = mWebsite.getHandle();
         }
         
-        try
-        {
+        try {
             mBookmarkMgr = RollerFactory.getRoller().getBookmarkManager();
             mRefererMgr  = RollerFactory.getRoller().getRefererManager();
             mUserMgr     = RollerFactory.getRoller().getUserManager();
             mWeblogMgr   = RollerFactory.getRoller().getWeblogManager();
-           
+            
             // Preload what we can for encapsulation.  What we cannot preload we
             // will use the Managers later to fetch.
-
+            
             // Get the pages, put into context & load map
-            if (mWebsite != null)
-            {
+            if (mWebsite != null) {
                 // if we have website from RollerRequest, use it
                 mWebsite = rreq.getWebsite();
                 
                 // Get the pages, put into context & load map
                 List pages = mWebsite.getPages();
                 Iterator pageIter = pages.iterator();
-                while (pageIter.hasNext())
-                {
+                while (pageIter.hasNext()) {
                     Template page = (Template) pageIter.next();
                     mPageMap.put(page.getName(), TemplateWrapper.wrap(page));
                 }
             }
-        }
-        catch (RollerException e)
-        {
+        } catch (RollerException e) {
             mLogger.error("PageModel Roller get*Manager Exception", e);
         }
     }
@@ -124,8 +114,7 @@
     //------------------------------------------------------------------------
     
     /** Encapsulates folder.getBookmarks() & sorting */
-    public Collection getBookmarks(FolderDataWrapper 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
@@ -142,13 +131,11 @@
     //------------------------------------------------------------------------
     
     /** Get top level bookmark folders. */
-    public Collection getTopLevelFolders()
-    {
+    public Collection getTopLevelFolders() {
         List tops = null;
-        try
-        {
+        try {
             Collection mTops = mBookmarkMgr.getRootFolder(
-                mUserMgr.getWebsiteByHandle(mHandle)).getFolders();
+                    mUserMgr.getWebsiteByHandle(mHandle)).getFolders();
             
             // wrap pojos
             tops = new ArrayList(mTops.size());
@@ -158,9 +145,7 @@
                 tops.add(i, FolderDataWrapper.wrap((FolderData) it.next()));
                 i++;
             }
-        }
-        catch (RollerException e)
-        {
+        } catch (RollerException e) {
             tops = new ArrayList();
         }
         return tops;
@@ -183,12 +168,12 @@
     }
     
     //------------------------------------------------------------------------
-     
+    
     /** Get comments for weblog entry specified by request */
     public List getComments(WeblogEntryDataWrapper entry) {
         return getComments(entry, true, true);
     }
-        
+    
     /** Get comments for weblog entry specified by request */
     public List getComments(WeblogEntryDataWrapper wrapper, boolean noSpam, boolean approvedOnly)
{
         WeblogEntryData entry = wrapper.getPojo();
@@ -205,14 +190,10 @@
     //------------------------------------------------------------------------
     
     /** Encapsulates RefererManager */
-    public int getDayHits()
-    {
-        try
-        {
+    public int getDayHits() {
+        try {
             return mRefererMgr.getDayHits(mRollerReq.getWebsite());
-        }
-        catch (RollerException e)
-        {
+        } catch (RollerException e) {
             mLogger.error("PageModel getDayHits()", e);
         }
         return 0;
@@ -221,44 +202,34 @@
     //------------------------------------------------------------------------
     
     /** Encapsulates BookmarkManager.getFolder() */
-    public FolderDataWrapper getFolder(String folderPath)
-    {
-        try
-        {
+    public FolderDataWrapper getFolder(String folderPath) {
+        try {
             return FolderDataWrapper.wrap(
-                    mBookmarkMgr.getFolder( 
-                        mUserMgr.getWebsiteByHandle(mHandle), folderPath));
-        }
-        catch (RollerException e)
-        {
+                    mBookmarkMgr.getFolder(
+                    mUserMgr.getWebsiteByHandle(mHandle), folderPath));
+        } catch (RollerException e) {
             mLogger.error("PageModel getFolder()", e);
         }
         return null;
     }
-        
+    
     //------------------------------------------------------------------------
     
     /** Encapsulates UserManager.getPageByName() */
-    public TemplateWrapper getUsersPageByName(WebsiteDataWrapper wrapper, String pageName)
-    {
+    public TemplateWrapper getUsersPageByName(WebsiteDataWrapper wrapper, String pageName)
{
         WebsiteData website = wrapper.getPojo();
         TemplateWrapper page = null;
-        try
-        {
-            if (website == null) 
+        try {
+            if (website == null)
                 throw new NullPointerException("website is null");
-                
-            if (pageName == null) 
+            
+            if (pageName == null)
                 throw new NullPointerException("pageName is null");
-                
+            
             page = TemplateWrapper.wrap(website.getPageByName(pageName));
-        }
-        catch (NullPointerException npe)
-        {
+        } catch (NullPointerException npe) {
             mLogger.warn(npe.getMessage());
-        }
-        catch (RollerException e)
-        {
+        } catch (RollerException e) {
             mLogger.error("ERROR getting user's page by name: " + e.getMessage(),e);
         }
         return page;
@@ -267,16 +238,14 @@
     //------------------------------------------------------------------------
     
     /** Encapsulates UserManager.getPageByName() */
-    public TemplateWrapper getPageByName(String pageName)
-    {
+    public TemplateWrapper getPageByName(String pageName) {
         return (TemplateWrapper) mPageMap.get(pageName);
     }
     
     //------------------------------------------------------------------------
     
     /** Encapsulates UserManager.getPageByName() */
-    public String getPageIdByName(String pageName)
-    {
+    public String getPageIdByName(String pageName) {
         mLogger.debug("looking up page ["+pageName+"]");
         
         String template_id = null;
@@ -299,70 +268,62 @@
      * Get collection of user pages.
      * @return
      */
-    public Object getPages()
-    {
+    public Object getPages() {
         return mPageMap.values();
     }
     
     //------------------------------------------------------------------------
     
-    /** 
-     * Returns a map of up to 100 recent weblog entries for the user and day 
-     * specified in the request, filtered by the category specified by the 
-     * request, limited by the 'maxEntries' argument, and sorted by reverse 
+    /**
+     * Returns a map of up to 100 recent weblog entries for the user and day
+     * specified in the request, filtered by the category specified by the
+     * request, limited by the 'maxEntries' argument, and sorted by reverse
      * chronological order.
-     * 
+     *
      * <p>This method will look for a category name in the following places
      * and in the following order:</p>
      * <ul>
      * <li>The request via RollerRequest.getWeblogCategory().</li>
      * <li>The categoryName argument to this method.</li>
-     * <li>The default category for the website specified by the request via 
+     * <li>The default category for the website specified by the request via
      *     RollerRequest.getWebsite().getDefaultCategory().</li>
      * <li></li>
      * </ul>
-     * 
+     *
      * @param maxEntries Maximum number of entries to be returned.
-     * @param categoryName Only return entries from this category and it's 
+     * @param categoryName Only return entries from this category and it's
      *         subcategories. If null, returns all categories of entry.
      * @return Map of Lists of WeblogEntryData, keyed by 8-char date strings.
      */
-    public Map getRecentWeblogEntries(int maxEntries, String categoryName)
-    {
+    public Map getRecentWeblogEntries(int maxEntries, String categoryName) {
         if (VELOCITY_NULL.equals(categoryName)) categoryName = null;
         Map ret = new HashMap();
-        try
-        {
+        try {
             Date day = mRollerReq.getDate();
             if (day == null) day = new Date();
             
             // If request specifies a category, then use that
             String catParam = null;
-            if (mRollerReq.getWeblogCategory() != null)
-            {
+            if (mRollerReq.getWeblogCategory() != null) {
                 catParam = mRollerReq.getWeblogCategory().getPath();
-            }
-            else if (categoryName != null)
-            {
+            } else if (categoryName != null) {
                 // use category argument instead
                 catParam = categoryName;
-            }
-            else if (mRollerReq.getWebsite() != null) // MAIN
+            } else if (mRollerReq.getWebsite() != null) // MAIN
             {
                 catParam = mRollerReq.getWebsite().getDefaultCategory().getPath();
-                if (catParam.equals("/"))
-                {
+                if (catParam.equals("/")) {
                     catParam = null;
                 }
             }
             
             Map mRet = RollerFactory.getRoller().getWeblogManager().getWeblogEntryObjectMap(
-                            mRollerReq.getWebsite(),  
-                            null,                     // startDate
-                            day,                 // endDate
-                            catParam,                 // catName
-                            WeblogEntryData.PUBLISHED,   // status
-                            new Integer(maxEntries)); // maxEntries
+                    mRollerReq.getWebsite(),
+                    null,                     // startDate
+                    day,                 // endDate
+                    catParam,                 // catName
+                    WeblogEntryData.PUBLISHED,   // status
+                    new Integer(maxEntries)); // maxEntries
             
             // need to wrap pojos
             java.util.Date key = null;
@@ -374,18 +335,16 @@
                 List wrappedEntries = new ArrayList();
                 List entries = (List) mRet.get(key);
                 for(int i=0; i < entries.size(); i++) {
-                    wrappedEntries.add(i, 
+                    wrappedEntries.add(i,
                             WeblogEntryDataWrapper.wrap((WeblogEntryData)entries.get(i)));
                 }
                 mRet.put(key, wrappedEntries);
             }
-
-	    ret = mRet;
+            
+            ret = mRet;
             
             setFirstAndLastEntries( ret );
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             mLogger.error("PageModel getRecentWeblogEntries()", e);
         }
         return ret;
@@ -397,8 +356,7 @@
      * Pull the last WeblogEntryData out of the Map.
      * @param ret
      */
-    private void setFirstAndLastEntries(Map days)
-    {
+    private void setFirstAndLastEntries(Map days) {
         int numDays = days.keySet().size();
         if (numDays > 0) // there is at least one day
         {
@@ -406,76 +364,67 @@
             Object[] keys = days.keySet().toArray(new Object[numDays]);
             List vals = (List)days.get( keys[0] );
             int valSize = vals.size();
-            if (valSize > 0) 
-            {
+            if (valSize > 0) {
                 mFirstEntry = (WeblogEntryDataWrapper)vals.get(0);
             }
             
             // get last entry in map
             vals = (List)days.get( keys[--numDays] );
             valSize = vals.size();
-            if (valSize > 0)
-            {
+            if (valSize > 0) {
                 mLastEntry = (WeblogEntryDataWrapper)vals.get(--valSize);
             }
         }
     }
-
+    
     //------------------------------------------------------------------------
     
-    /** 
-     * Returns list of recent weblog entries for the user and day specified in 
-     * the request, filtered by the category specified by the request, limited 
+    /**
+     * Returns list of recent weblog entries for the user and day specified in
+     * the request, filtered by the category specified by the request, limited
      * by the 'maxEntries' argument, and sorted by reverse chronological order.
-     * 
-     * <p>This method will look for a category name in the same places and 
+     *
+     * <p>This method will look for a category name in the same places and
      * same order as does the getRecentWeblogEntries() method.</p>
-     * 
+     *
      * @param maxEntries   Maximum number of entries to be returned.
-     * @param categoryName Only return entries from this category and it's 
+     * @param categoryName Only return entries from this category and it's
      *         subcategories. If null, returns all categories of entry.
      * @return List of WeblogEntryData objects in revese chronological order.
      */
-    public List getRecentWeblogEntriesArray(int maxEntries, String categoryName)
-    {
+    public List getRecentWeblogEntriesArray(int maxEntries, String categoryName) {
         if (VELOCITY_NULL.equals(categoryName)) categoryName = null;
         List ret = new ArrayList();
-        try
-        {
+        try {
             Date day = mRollerReq.getDate();
             if (day == null) day = new Date();
             
             // If request specifies a category, then use that
             String catParam = null;
-            if (mRollerReq.getWeblogCategory() != null)
-            {
+            if (mRollerReq.getWeblogCategory() != null) {
                 catParam = mRollerReq.getWeblogCategory().getPath();
-            }
-            else if (categoryName != null)
-            {
+            } else if (categoryName != null) {
                 // use category argument instead
                 catParam = categoryName;
-            }
-            else if (mRollerReq.getWebsite() != null) // MAIN
+            } else if (mRollerReq.getWebsite() != null) // MAIN
             {
                 catParam = mRollerReq.getWebsite().getDefaultCategory().getPath();
-                if (catParam.equals("/"))
-                {
+                if (catParam.equals("/")) {
                     catParam = null;
                 }
             }
             WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
             
-            //ret = mgr.getRecentWeblogEntriesArray( 
-                //name, day, catParam, maxEntries, true );
+            //ret = mgr.getRecentWeblogEntriesArray(
+            //name, day, catParam, maxEntries, true );
             
             List mEntries = mgr.getWeblogEntries(
-                            mRollerReq.getWebsite(), 
-                            null,                    // startDate
-                            day,                      // endDate
-                            catParam,                 // catName
-                            WeblogEntryData.PUBLISHED,   // status
-                            new Integer(maxEntries)); // maxEntries
+                    mRollerReq.getWebsite(),
+                    null,                    // startDate
+                    day,                      // endDate
+                    catParam,                 // catName
+                    WeblogEntryData.PUBLISHED,   // status
+                    new Integer(maxEntries)); // maxEntries
             
             // wrap pojos
             ret = new ArrayList(mEntries.size());
@@ -485,60 +434,50 @@
                 ret.add(i, WeblogEntryDataWrapper.wrap((WeblogEntryData) it.next()));
                 i++;
             }
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             mLogger.error("PageModel getRecentWeblogEntries()", e);
         }
         return ret;
-    }   
+    }
     
     //------------------------------------------------------------------------
     
     /** Encapsulates RefererManager **/
-    public List getReferers(String date)
-    {
+    public List getReferers(String date) {
         date = date.trim();
         ArrayList referers = new ArrayList();
-        try
-        {
-            List refs = 
-                mRefererMgr.getReferersToDate(mRollerReq.getWebsite(), date);
-            RollerSession rses = 
-                RollerSession.getRollerSession(mRollerReq.getRequest());
+        try {
+            List refs =
+                    mRefererMgr.getReferersToDate(mRollerReq.getWebsite(), date);
+            RollerSession rses =
+                    RollerSession.getRollerSession(mRollerReq.getRequest());
             
             for (Iterator rdItr = refs.iterator(); rdItr.hasNext();) {
                 RefererData referer = (RefererData) rdItr.next();
                 String title =referer.getTitle();
                 String excerpt = referer.getExcerpt();
-                if (   StringUtils.isNotEmpty(title) 
-                    && StringUtils.isNotEmpty(excerpt) )
-                {
-                    if (   referer.getVisible().booleanValue() 
-                        || rses.isUserAuthorizedToAdmin(referer.getWebsite()) )
-                    { 
+                if (   StringUtils.isNotEmpty(title)
+                && StringUtils.isNotEmpty(excerpt) ) {
+                    if (   referer.getVisible().booleanValue()
+                    || rses.isUserAuthorizedToAdmin(referer.getWebsite()) ) {
                         referers.add(RefererDataWrapper.wrap(referer));
                     }
                 }
             }
             
-        }
-        catch (Exception e)
-        {
-            mLogger.error("PageModel getReferersToDate() fails with URL" 
-                            + mRollerReq.getRequestURL(), e);
+        } catch (Exception e) {
+            mLogger.error("PageModel getReferersToDate() fails with URL"
+                    + mRollerReq.getRequestURL(), e);
         }
         return referers;
-    }   
+    }
     
     //------------------------------------------------------------------------
     
     /** Encapsulates RefererManager */
-    public List getTodaysReferers()
-    {
+    public List getTodaysReferers() {
         List referers = null;
-        try
-        {
+        try {
             List mReferers = mRefererMgr.getTodaysReferers(mRollerReq.getWebsite());
             
             // wrap pojos
@@ -549,10 +488,8 @@
                 referers.add(i, RefererDataWrapper.wrap((RefererData) it.next()));
                 i++;
             }
-         
-        }
-        catch (RollerException e)
-        {
+            
+        } catch (RollerException e) {
             mLogger.error("PageModel getTodaysReferers()", e);
         }
         return (referers == null ? Collections.EMPTY_LIST : referers);
@@ -561,14 +498,10 @@
     //------------------------------------------------------------------------
     
     /** Encapsulates RefererManager */
-    public int getTotalHits()
-    {
-        try
-        {
+    public int getTotalHits() {
+        try {
             return mRefererMgr.getTotalHits(mRollerReq.getWebsite());
-        }
-        catch (RollerException e)
-        {
+        } catch (RollerException e) {
             mLogger.error("PageModel getTotalHits()", e);
         }
         return 0;
@@ -580,53 +513,44 @@
      * @param weblogEntries Collection of weblog entries.
      * @return Most recent update time.
      */
-    public static Date getUpdateTime( ArrayList weblogEntries )
-    {
+    public static Date getUpdateTime( ArrayList weblogEntries ) {
         Date updateTime = null;
         Iterator iter = weblogEntries.iterator();
-        while (iter.hasNext())
-        {
+        while (iter.hasNext()) {
             // NOTE: this will need to be WeblogEntryDataWrapper
             WeblogEntryData wd = (WeblogEntryData)iter.next();
-            if ( updateTime == null )
-            {
+            if ( updateTime == null ) {
                 updateTime = wd.getUpdateTime();
             }
             //else if ( updateTime.compareTo(wd.getUpdateTime()) < 0 )
-            else if (updateTime.before( wd.getUpdateTime() ))
-            {
+            else if (updateTime.before( wd.getUpdateTime() )) {
                 updateTime = wd.getUpdateTime();
             }
         }
         return updateTime;
     }
-
+    
     //------------------------------------------------------------------------
     
     /** Encapsulates WeblogManager.getWeblogCategories() */
-    public List getWeblogCategories(String categoryName)
-    {
+    public List getWeblogCategories(String categoryName) {
         List ret = null;
         if (VELOCITY_NULL.equals(categoryName)) categoryName = null;
         
         // Make sure we have not already fetched this category.
-        if (categoryName != null)
-        {
+        if (categoryName != null) {
             ret = (List)mCategories.get(categoryName);
+        } else {
+            ret = (List)mCategories.get("zzz_null_zzz");
         }
         
-        if (null == ret) 
-        {
-            try 
-            {
-                WeblogCategoryData category = null;                
-                if (categoryName != null)
-                {
+        if (null == ret) {
+            try {
+                WeblogCategoryData category = null;
+                if (categoryName != null) {
                     category = mWeblogMgr.getWeblogCategoryByPath(
-                                  mRollerReq.getWebsite(), null, categoryName);         
          
-                }
-                else 
-                {
+                            mRollerReq.getWebsite(), null, categoryName);
+                } else {
                     category = mRollerReq.getWebsite().getDefaultCategory();
                 }
                 
@@ -637,25 +561,25 @@
                 Iterator it = mRet.iterator();
                 int i=0;
                 while(it.hasNext()) {
-                    ret.add(i, WeblogCategoryDataWrapper.wrap((WeblogCategoryData) it.next()));
+                    ret.add(i, WeblogCategoryDataWrapper.wrap((WeblogCategoryData)it.next()));
                     i++;
                 }
-        
-                mCategories.put(categoryName, ret);
-            }
-            catch (RollerException e) 
-            {
+                if (categoryName != null) {
+                    mCategories.put(categoryName, ret);
+                } else {
+                    mCategories.put("zzz_null_zzz", ret);
+                }
+            } catch (RollerException e) {
                 mLogger.error(e);
             }
-        }       
+        }
         return ret;
     }
     
     //------------------------------------------------------------------------
     
     /** Encapsulates RollerRequest.getWeblogEntry() */
-    public WeblogEntryDataWrapper getWeblogEntry()
-    {
+    public WeblogEntryDataWrapper getWeblogEntry() {
         WeblogEntryData entry = mRollerReq.getWeblogEntry();
         
         if(entry != null && entry.getStatus().equals(WeblogEntryData.PUBLISHED))
@@ -669,88 +593,70 @@
     /**
      * Get the next occurring Entry.
      */
-    public WeblogEntryDataWrapper getNextEntry()
-    {
+    public WeblogEntryDataWrapper getNextEntry() {
         WeblogEntryDataWrapper currentEntry = getWeblogEntry();
         if (mFirstEntry != null) currentEntry = mFirstEntry;
-        if (mNextEntry == null && currentEntry != null) 
-        {
+        if (mNextEntry == null && currentEntry != null) {
             String catName = null;
-            if (mRollerReq.getWeblogCategory() != null)
-            {
+            if (mRollerReq.getWeblogCategory() != null) {
                 catName = mRollerReq.getWeblogCategory().getName();
             }
-            try
-            {
-                WeblogEntryData nextEntry = 
+            try {
+                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 && 
-                    mNextEntry.getPubTime().after( new Date() ))
-                {
+                if (mNextEntry != null &&
+                        mNextEntry.getPubTime().after( new Date() )) {
                     mNextEntry = null;
                 }
-            }
-            catch (RollerException e)
-            {
+            } catch (RollerException e) {
                 mLogger.error("PageModel.getNextEntry)", e);
             }
         }
         return mNextEntry;
     }
-
+    
     //------------------------------------------------------------------------
     
     /**
      * Get the previous occurring Entry.
      */
-    public WeblogEntryDataWrapper getPreviousEntry()
-    {
+    public WeblogEntryDataWrapper getPreviousEntry() {
         WeblogEntryDataWrapper currentEntry = getWeblogEntry();
         if (mLastEntry != null) currentEntry = mLastEntry;
-        if (mPreviousEntry == null && currentEntry != null )
-        {   
+        if (mPreviousEntry == null && currentEntry != null ) {
             String catName = null;
-            if (mRollerReq.getWeblogCategory() != null)
-            {
+            if (mRollerReq.getWeblogCategory() != null) {
                 catName = mRollerReq.getWeblogCategory().getName();
             }
-            try
-            {
-                WeblogEntryData prevEntry = 
+            try {
+                WeblogEntryData prevEntry =
                         mWeblogMgr.getPreviousEntry(currentEntry.getPojo(), catName);
                 
                 if(prevEntry != null)
                     mPreviousEntry = WeblogEntryDataWrapper.wrap(prevEntry);
-            }
-            catch (RollerException e)
-            {
+            } catch (RollerException e) {
                 mLogger.error("PageModel.getPreviousEntry)", e);
-            }            
+            }
         }
         return mPreviousEntry;
     }
-
+    
     //------------------------------------------------------------------------
     
-    public boolean isUserAuthorizedToEdit()
-    {
-        try
-        {
-            RollerSession rses = 
-                RollerSession.getRollerSession(mRollerReq.getRequest());
-            if (rses.getAuthenticatedUser() != null 
-                   && mRollerReq.getWebsite() != null)
-            {
+    public boolean isUserAuthorizedToEdit() {
+        try {
+            RollerSession rses =
+                    RollerSession.getRollerSession(mRollerReq.getRequest());
+            if (rses.getAuthenticatedUser() != null
+                    && mRollerReq.getWebsite() != null) {
                 return rses.isUserAuthorizedToAuthor(mRollerReq.getWebsite());
             }
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             mLogger.warn("PageModel.isUserAuthorizedToEdit()", e);
         }
         return false;
@@ -758,20 +664,15 @@
     
     //------------------------------------------------------------------------
     
-    public boolean isUserAuthorizedToAdmin()
-    {
-        try
-        {
-            RollerSession rses = 
-                RollerSession.getRollerSession(mRollerReq.getRequest());
-            if (rses.getAuthenticatedUser() != null 
-                   && mRollerReq.getWebsite() != null)
-            {
+    public boolean isUserAuthorizedToAdmin() {
+        try {
+            RollerSession rses =
+                    RollerSession.getRollerSession(mRollerReq.getRequest());
+            if (rses.getAuthenticatedUser() != null
+                    && mRollerReq.getWebsite() != null) {
                 return rses.isUserAuthorizedToAdmin(mRollerReq.getWebsite());
             }
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             mLogger.warn("PageModel.isUserAuthorizedToAdmin()", e);
         }
         return false;
@@ -779,42 +680,36 @@
     
     //------------------------------------------------------------------------
     
-    public boolean isUserAuthenticated()
-    {
+    public boolean isUserAuthenticated() {
         return (mRollerReq.getRequest().getUserPrincipal() != null);
     }
     
     //------------------------------------------------------------------------
     
-    public String getRequestParameter(String key)
-    {
+    public String getRequestParameter(String key) {
         return mRollerReq.getRequest().getParameter(key);
     }
     
     //------------------------------------------------------------------------
     
-    public FolderDataWrapper getFolderByPath(String path)
-    {
-        try
-        {
+    public FolderDataWrapper getFolderByPath(String path) {
+        try {
             FolderData folder = mBookmarkMgr.getFolderByPath(
-                mWebsite, null, path);
+                    mWebsite, null, path);
             
             if(folder != null)
                 return FolderDataWrapper.wrap(folder);
-        }
-        catch (RollerException e)
-        {
+        } catch (RollerException e) {
             mLogger.error(e);
         }
         
         return null;
     }
-
+    
     /**
      * Facade for WeblogManager.getRecentComments().
      * Get the most recent (chronologically) posted Comments
-     * for this website, limited to maxCount.  
+     * for this website, limited to maxCount.
      * @return List of Comments.
      */
     public List getRecentComments(int maxCount) {
@@ -845,9 +740,8 @@
         }
         return recentComments;
     }
- 
-    public boolean getEmailComments() 
-    {
+    
+    public boolean getEmailComments() {
         WebsiteData website = mRollerReq.getWebsite();
         boolean emailComments = RollerRuntimeConfig.getBooleanProperty("users.comments.emailnotify");
         



Mime
View raw message