roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r349483 - in /incubator/roller/trunk/src/org/roller: presentation/bookmarks/actions/ presentation/servlets/ presentation/velocity/ presentation/weblog/actions/ presentation/website/actions/ presentation/xmlrpc/ util/
Date Mon, 28 Nov 2005 19:52:22 GMT
Author: agilliland
Date: Mon Nov 28 11:52:14 2005
New Revision: 349483

URL: http://svn.apache.org/viewcvs?rev=349483&view=rev
Log:
more changes for caching rewrite.

- update struts actions and servlets to invalidate using the CacheManager
- add toBase64() method in Utilities class


Modified:
    incubator/roller/trunk/src/org/roller/presentation/bookmarks/actions/BookmarksAction.java
    incubator/roller/trunk/src/org/roller/presentation/bookmarks/actions/FolderSaveAction.java
    incubator/roller/trunk/src/org/roller/presentation/servlets/CommentServlet.java
    incubator/roller/trunk/src/org/roller/presentation/servlets/TrackbackServlet.java
    incubator/roller/trunk/src/org/roller/presentation/velocity/FlavorServlet.java
    incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ImportEntriesAction.java
    incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ToggleLinkbackDisplayAction.java
    incubator/roller/trunk/src/org/roller/presentation/website/actions/MaintenanceAction.java
    incubator/roller/trunk/src/org/roller/presentation/website/actions/ThemeEditorAction.java
    incubator/roller/trunk/src/org/roller/presentation/website/actions/WebsiteFormAction.java
    incubator/roller/trunk/src/org/roller/presentation/xmlrpc/BaseAPIHandler.java
    incubator/roller/trunk/src/org/roller/util/Utilities.java

Modified: incubator/roller/trunk/src/org/roller/presentation/bookmarks/actions/BookmarksAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/bookmarks/actions/BookmarksAction.java?rev=349483&r1=349482&r2=349483&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/bookmarks/actions/BookmarksAction.java
(original)
+++ incubator/roller/trunk/src/org/roller/presentation/bookmarks/actions/BookmarksAction.java
Mon Nov 28 11:52:14 2005
@@ -34,8 +34,8 @@
 import org.roller.presentation.BasePageModel;
 import org.roller.presentation.RollerRequest;
 import org.roller.presentation.RollerSession;
-import org.roller.presentation.pagecache.PageCacheFilter;
 import org.roller.presentation.bookmarks.formbeans.BookmarksForm;
+import org.roller.presentation.cache.CacheManager;
 
 /**
  * Actions that are initiated from the BookmarksForm.
@@ -126,7 +126,8 @@
                 }
             }
             roller.commit();
-            PageCacheFilter.removeFromCache(request,website);
+                
+            CacheManager.invalidate(website);
 
             // recreate model now that folder  is deleted
             pageModel = new BookmarksPageModel(
@@ -210,7 +211,9 @@
                     }
                 }
                 roller.commit();
-                PageCacheFilter.removeFromCache(request,website);
+
+                CacheManager.invalidate(website);
+                
                 saveMessages(request, messages);
             }
             catch (RollerException e)

Modified: incubator/roller/trunk/src/org/roller/presentation/bookmarks/actions/FolderSaveAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/bookmarks/actions/FolderSaveAction.java?rev=349483&r1=349482&r2=349483&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/bookmarks/actions/FolderSaveAction.java
(original)
+++ incubator/roller/trunk/src/org/roller/presentation/bookmarks/actions/FolderSaveAction.java
Mon Nov 28 11:52:14 2005
@@ -19,8 +19,8 @@
 import org.roller.pojos.WebsiteData;
 import org.roller.presentation.RollerRequest;
 import org.roller.presentation.RollerSession;
-import org.roller.presentation.pagecache.PageCacheFilter;
 import org.roller.presentation.bookmarks.formbeans.FolderFormEx;
+import org.roller.presentation.cache.CacheManager;
 
 /**
  * @struts.action path="/editor/folderSave" name="folderFormEx" 
@@ -68,7 +68,8 @@
             form.copyTo(fd, request.getLocale());
             fd.save();
             RollerFactory.getRoller().commit();
-            PageCacheFilter.removeFromCache(request,website);
+            
+            CacheManager.invalidate(fd);
         }
         else
         {

Modified: incubator/roller/trunk/src/org/roller/presentation/servlets/CommentServlet.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/servlets/CommentServlet.java?rev=349483&r1=349482&r2=349483&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/servlets/CommentServlet.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/servlets/CommentServlet.java Mon Nov
28 11:52:14 2005
@@ -32,13 +32,13 @@
 import org.roller.pojos.UserData;
 import org.roller.pojos.WeblogEntryData;
 import org.roller.pojos.WebsiteData;
-import org.roller.presentation.pagecache.PageCacheFilter;
 import org.roller.presentation.velocity.CommentAuthenticator;
 import org.roller.presentation.weblog.formbeans.CommentFormEx;
 import org.roller.util.CommentSpamChecker;
 import org.roller.util.MailUtil;
 import org.roller.util.StringUtils;
 import org.roller.presentation.*;
+import org.roller.presentation.cache.CacheManager;
 
 
 /**
@@ -171,7 +171,8 @@
                     reindexEntry(entry);
                     
                     // Refresh user's entries in page cache
-                    PageCacheFilter.removeFromCache(request, website);
+                    //PageCacheFilter.removeFromCache(request, website);
+                    CacheManager.invalidate(comment);
                     
                     // Send email notifications
                     sendEmailNotification(request, rreq, entry, comment);

Modified: incubator/roller/trunk/src/org/roller/presentation/servlets/TrackbackServlet.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/servlets/TrackbackServlet.java?rev=349483&r1=349482&r2=349483&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/servlets/TrackbackServlet.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/servlets/TrackbackServlet.java Mon
Nov 28 11:52:14 2005
@@ -20,7 +20,7 @@
 import org.roller.model.RollerFactory;
 import org.roller.pojos.WeblogEntryData;
 import org.roller.presentation.RollerRequest;
-import org.roller.presentation.pagecache.PageCacheFilter;
+import org.roller.presentation.cache.CacheManager;
 
 
 /**
@@ -152,7 +152,8 @@
                         RollerFactory.getRoller().commit();
                         
                         // Refresh user's entries in page cache
-                        PageCacheFilter.removeFromCache(req, entry.getWebsite());
+                        //PageCacheFilter.removeFromCache(req, entry.getWebsite());
+                        CacheManager.invalidate(comment);
                     
                         // Send email notifications
                         CommentServlet.sendEmailNotification(req, rreq, entry, comment);

Modified: incubator/roller/trunk/src/org/roller/presentation/velocity/FlavorServlet.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/velocity/FlavorServlet.java?rev=349483&r1=349482&r2=349483&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/velocity/FlavorServlet.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/velocity/FlavorServlet.java Mon Nov
28 11:52:14 2005
@@ -9,11 +9,16 @@
 import org.roller.RollerException;
 import org.roller.presentation.RollerRequest;
 import java.io.IOException;
+import java.util.Date;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.jsp.JspFactory;
 import javax.servlet.jsp.PageContext;
+import org.roller.model.Roller;
+import org.roller.model.RollerFactory;
+import org.roller.model.UserManager;
+import org.roller.model.WeblogManager;
 
 /////////////////////////////////////////////////////////////////////////////
 /**
@@ -44,8 +49,8 @@
 {
     static final long serialVersionUID = -2720532269434186051L;
     
-    private static Log mLogger = LogFactory.getFactory()
-                                           .getInstance(RollerRequest.class);
+    private static Log mLogger = LogFactory.getLog(FlavorServlet.class);
+    
     public Template handleRequest(HttpServletRequest request,
                                   HttpServletResponse response, Context ctx)
     {
@@ -90,6 +95,23 @@
                 JspFactory.getDefaultFactory().getPageContext(
                 this, request,  response, "", true, 8192, true);
             rreq.setPageContext(pageContext);
+            
+            // get update time before loading context
+            // TODO: this should really be handled elsewhere
+            if(rreq.getWebsite() != null) {
+                String catname =
+                        request.getParameter(RollerRequest.WEBLOGCATEGORYNAME_KEY);
+                
+                Roller roller = RollerFactory.getRoller();
+                UserManager umgr = roller.getUserManager();
+                WeblogManager wmgr = roller.getWeblogManager();
+                
+                Date updateTime = wmgr.getWeblogLastPublishTime(
+                        umgr.getWebsiteByHandle(rreq.getWebsite().getHandle()), catname);
+                
+                request.setAttribute("updateTime", updateTime);
+            }
+            
             ContextLoader.setupContext(ctx, rreq, response);
 
             final String useTemplate;

Modified: incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ImportEntriesAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ImportEntriesAction.java?rev=349483&r1=349482&r2=349483&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ImportEntriesAction.java
(original)
+++ incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ImportEntriesAction.java
Mon Nov 28 11:52:14 2005
@@ -21,11 +21,10 @@
 import org.apache.struts.action.ActionMessages;
 import org.apache.struts.actions.DispatchAction;
 import org.roller.pojos.WebsiteData;
-import org.roller.presentation.MainPageAction;
 import org.roller.presentation.RollerContext;
 import org.roller.presentation.RollerRequest;
 import org.roller.presentation.RollerSession;
-import org.roller.presentation.pagecache.PageCacheFilter;
+import org.roller.presentation.cache.CacheManager;
 import org.roller.presentation.weblog.formbeans.ImportEntriesForm;
 import org.roller.util.StringUtils;
 
@@ -87,7 +86,8 @@
                         saveMessages(request, notices);
 
                         // Flush the page cache
-                        PageCacheFilter.removeFromCache(request, website);
+                        //PageCacheFilter.removeFromCache(request, website);
+                        CacheManager.invalidate(website);
                     }
                     else
                     {

Modified: incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ToggleLinkbackDisplayAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ToggleLinkbackDisplayAction.java?rev=349483&r1=349482&r2=349483&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ToggleLinkbackDisplayAction.java
(original)
+++ incubator/roller/trunk/src/org/roller/presentation/weblog/actions/ToggleLinkbackDisplayAction.java
Mon Nov 28 11:52:14 2005
@@ -16,7 +16,7 @@
 import org.roller.presentation.RollerContext;
 import org.roller.presentation.RollerRequest;
 import org.roller.presentation.RollerSession;
-import org.roller.presentation.pagecache.PageCacheFilter;
+import org.roller.presentation.cache.CacheManager;
 
 
 /**
@@ -57,7 +57,8 @@
                     
                     RollerFactory.getRoller().commit();
                     
-                    PageCacheFilter.removeFromCache( req, rreq.getWebsite() );
+                    //PageCacheFilter.removeFromCache( req, rreq.getWebsite() );
+                    CacheManager.invalidate(rreq.getWebsite());
                 }                
             }
         }

Modified: incubator/roller/trunk/src/org/roller/presentation/website/actions/MaintenanceAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/website/actions/MaintenanceAction.java?rev=349483&r1=349482&r2=349483&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/website/actions/MaintenanceAction.java
(original)
+++ incubator/roller/trunk/src/org/roller/presentation/website/actions/MaintenanceAction.java
Mon Nov 28 11:52:14 2005
@@ -27,7 +27,7 @@
 import org.roller.presentation.BasePageModel;
 import org.roller.presentation.RollerRequest;
 import org.roller.presentation.RollerSession;
-import org.roller.presentation.pagecache.PageCacheFilter;
+import org.roller.presentation.cache.CacheManager;
 
 /**
  * Allows user to perform Website maintenence operations such as flushing
@@ -123,7 +123,8 @@
             RollerSession rses = RollerSession.getRollerSession(request);
 			if ( rses.isUserAuthorizedToAdmin(website) )
 			{
-	            PageCacheFilter.removeFromCache(request, website);
+	            //PageCacheFilter.removeFromCache(request, website);
+                CacheManager.invalidate(website);
 
                  ActionMessages messages = new ActionMessages();
                  messages.add(null, new ActionMessage("maintenance.message.flushed"));

Modified: incubator/roller/trunk/src/org/roller/presentation/website/actions/ThemeEditorAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/website/actions/ThemeEditorAction.java?rev=349483&r1=349482&r2=349483&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/website/actions/ThemeEditorAction.java
(original)
+++ incubator/roller/trunk/src/org/roller/presentation/website/actions/ThemeEditorAction.java
Mon Nov 28 11:52:14 2005
@@ -30,7 +30,7 @@
 import org.roller.pojos.ThemeTemplate;
 import org.roller.presentation.BasePageModel;
 import org.roller.presentation.RollerSession;
-import org.roller.presentation.pagecache.PageCacheFilter;
+import org.roller.presentation.cache.CacheManager;
 
 
 /**
@@ -287,8 +287,9 @@
                                 " for "+username);
                         
                         // make sure to flush the page cache so ppl can see the change
-                        PageCacheFilter.removeFromCache(request, website);
-                
+                        //PageCacheFilter.removeFromCache(request, website);
+                        CacheManager.invalidate(website);
+                        
                         // update complete ... now just send them back to edit
                         return this.edit(mapping, form, request, response);
                         
@@ -361,7 +362,8 @@
                         }
                         
                         // make sure to flush the page cache so ppl can see the change
-                        PageCacheFilter.removeFromCache(request, website);
+                        //PageCacheFilter.removeFromCache(request, website);
+                        CacheManager.invalidate(website);
                     }
                     
                 } catch(ThemeNotFoundException tnfe) {

Modified: incubator/roller/trunk/src/org/roller/presentation/website/actions/WebsiteFormAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/website/actions/WebsiteFormAction.java?rev=349483&r1=349482&r2=349483&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/website/actions/WebsiteFormAction.java
(original)
+++ incubator/roller/trunk/src/org/roller/presentation/website/actions/WebsiteFormAction.java
Mon Nov 28 11:52:14 2005
@@ -37,7 +37,7 @@
 import org.roller.presentation.BasePageModel;
 import org.roller.presentation.RollerRequest;
 import org.roller.presentation.RollerSession;
-import org.roller.presentation.pagecache.PageCacheFilter;
+import org.roller.presentation.cache.CacheManager;
 import org.roller.presentation.velocity.ContextLoader;
 import org.roller.presentation.velocity.PagePlugin;
 import org.roller.presentation.website.formbeans.WebsiteFormEx;
@@ -175,7 +175,8 @@
                         RollerRequest.WEBSITEID_KEY, form.getId());
 
                     // clear the page cache for this user
-                    PageCacheFilter.removeFromCache(request, wd);
+                    //PageCacheFilter.removeFromCache(request, wd);
+                    CacheManager.invalidate(wd);
 
                     // set the Editor Page list
                     ServletContext ctx = request.getSession().getServletContext();
@@ -284,7 +285,9 @@
                 website.remove();
                 RollerFactory.getRoller().commit();
 
-                PageCacheFilter.removeFromCache(request, website);                    
+                //PageCacheFilter.removeFromCache(request, website);
+                CacheManager.invalidate(website);
+                
                 actionForm.reset(mapping, request);
             }
             else

Modified: incubator/roller/trunk/src/org/roller/presentation/xmlrpc/BaseAPIHandler.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/xmlrpc/BaseAPIHandler.java?rev=349483&r1=349482&r2=349483&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/xmlrpc/BaseAPIHandler.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/xmlrpc/BaseAPIHandler.java Mon Nov
28 11:52:14 2005
@@ -13,10 +13,9 @@
 import org.roller.model.UserManager;
 import org.roller.pojos.UserData;
 import org.roller.pojos.WebsiteData;
-import org.roller.presentation.MainPageAction;
 import org.roller.presentation.RollerContext;
 import org.roller.presentation.RollerRequest;
-import org.roller.presentation.pagecache.PageCacheFilter;
+import org.roller.presentation.cache.CacheManager;
 import org.roller.util.Utilities;
 
 /**
@@ -201,6 +200,7 @@
     protected void flushPageCache(WebsiteData website) throws Exception
     {
         RollerRequest rreq = RollerRequest.getRollerRequest();
-        PageCacheFilter.removeFromCache( rreq.getRequest(), website);
+        //PageCacheFilter.removeFromCache( rreq.getRequest(), website);
+        CacheManager.invalidate(website);
     }
 }

Modified: incubator/roller/trunk/src/org/roller/util/Utilities.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/util/Utilities.java?rev=349483&r1=349482&r2=349483&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/util/Utilities.java (original)
+++ incubator/roller/trunk/src/org/roller/util/Utilities.java Mon Nov 28 11:52:14 2005
@@ -1123,4 +1123,35 @@
     {
         return StringEscapeUtils.unescapeHtml(str);
     }
+    
+    
+    /**
+     * Convert a byte array into a Base64 string (as used in mime formats)
+     */
+    public static String toBase64(byte[] aValue) {
+        
+        final String m_strBase64Chars =
+            "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+        
+        int byte1;
+        int byte2;
+        int byte3;
+        int iByteLen = aValue.length;
+        StringBuffer tt = new StringBuffer();
+        
+        for (int i = 0; i < iByteLen; i += 3) {
+            boolean bByte2 = (i + 1) < iByteLen;
+            boolean bByte3 = (i + 2) < iByteLen;
+            byte1 = aValue[i] & 0xFF;
+            byte2 = (bByte2) ? (aValue[i + 1] & 0xFF) : 0;
+            byte3 = (bByte3) ? (aValue[i + 2] & 0xFF) : 0;
+            
+            tt.append(m_strBase64Chars.charAt(byte1 / 4));
+            tt.append(m_strBase64Chars.charAt((byte2 / 16) + ((byte1 & 0x3) * 16)));
+            tt.append(((bByte2) ? m_strBase64Chars.charAt((byte3 / 64) + ((byte2 & 0xF)
* 4)) : '='));
+            tt.append(((bByte3) ? m_strBase64Chars.charAt(byte3 & 0x3F) : '='));
+        }
+        
+        return tt.toString();
+    }
 }



Mime
View raw message