roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r426657 - in /incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util: SiteWideCache.java WeblogPageCache.java WeblogPageRequest.java
Date Fri, 28 Jul 2006 19:56:04 GMT
Author: agilliland
Date: Fri Jul 28 12:56:03 2006
New Revision: 426657

URL: http://svn.apache.org/viewvc?rev=426657&view=rev
Log:
caching needs to take into account situations where arbitrary query params are allowed.  we
allow them on all pages for the frontpage blog and for custom pages in standard weblogs.


Modified:
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/SiteWideCache.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogPageCache.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogPageRequest.java

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/SiteWideCache.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/SiteWideCache.java?rev=426657&r1=426656&r2=426657&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/SiteWideCache.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/SiteWideCache.java
Fri Jul 28 12:56:03 2006
@@ -23,6 +23,7 @@
 import java.util.Date;
 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -36,6 +37,7 @@
 import org.apache.roller.pojos.WeblogEntryData;
 import org.apache.roller.pojos.WeblogTemplate;
 import org.apache.roller.pojos.WebsiteData;
+import org.apache.roller.util.Utilities;
 import org.apache.roller.util.cache.Cache;
 import org.apache.roller.util.cache.CacheHandler;
 import org.apache.roller.util.cache.CacheManager;
@@ -215,6 +217,14 @@
             key.append("/user=").append(pageRequest.getAuthenticUser());
         }
         
+        // we allow for arbitrary query params for custom pages
+        if(pageRequest.getCustomParams().size() > 0) {
+            String queryString = paramsToString(pageRequest.getCustomParams());
+            
+            key.append("/qp=").append(queryString);
+            log.info(queryString);
+        }
+
         return key.toString();
     }
     
@@ -337,6 +347,30 @@
      */
     public void invalidate(WeblogTemplate template) {
         // ignored
+    }
+    
+    
+    private String paramsToString(Map map) {
+        
+        if(map == null) {
+            return null;
+        }
+        
+        StringBuffer string = new StringBuffer();
+        
+        String key = null;
+        String[] value = null;
+        Iterator keys = map.keySet().iterator();
+        while(keys.hasNext()) {
+            key = (String) keys.next();
+            value = (String[]) map.get(key);
+            
+            if(value != null) {
+                string.append(",").append(key).append("=").append(value[0]);
+            }
+        }
+        
+        return Utilities.toBase64(string.toString().substring(1).getBytes());
     }
     
 }

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogPageCache.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogPageCache.java?rev=426657&r1=426656&r2=426657&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogPageCache.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogPageCache.java
Fri Jul 28 12:56:03 2006
@@ -22,6 +22,7 @@
 import java.net.URLEncoder;
 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -189,7 +190,40 @@
             key.append("/user=").append(pageRequest.getAuthenticUser());
         }
         
+        // we allow for arbitrary query params for custom pages
+        if(pageRequest.getWeblogPageName() != null &&
+                pageRequest.getCustomParams().size() > 0) {
+            String queryString = paramsToString(pageRequest.getCustomParams());
+            
+            key.append("/qp=").append(queryString);
+            log.info(queryString);
+        }
+        
         return key.toString();
+    }
+    
+    
+    private String paramsToString(Map map) {
+        
+        if(map == null) {
+            return null;
+        }
+        
+        StringBuffer string = new StringBuffer();
+        
+        String key = null;
+        String[] value = null;
+        Iterator keys = map.keySet().iterator();
+        while(keys.hasNext()) {
+            key = (String) keys.next();
+            value = (String[]) map.get(key);
+            
+            if(value != null) {
+                string.append(",").append(key).append("=").append(value[0]);
+            }
+        }
+        
+        return Utilities.toBase64(string.toString().substring(1).getBytes());
     }
     
 }

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogPageRequest.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogPageRequest.java?rev=426657&r1=426656&r2=426657&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogPageRequest.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/util/WeblogPageRequest.java
Fri Jul 28 12:56:03 2006
@@ -20,6 +20,8 @@
 
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
+import java.util.HashMap;
+import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
@@ -32,6 +34,7 @@
 import org.apache.roller.pojos.WeblogEntryData;
 import org.apache.roller.pojos.WeblogTemplate;
 
+
 /**
  * Represents a request for a Roller weblog page.
  *
@@ -53,6 +56,7 @@
     private String weblogCategoryName = null;
     private String weblogDate = null;
     private int pageNum = 0;
+    private Map customParams = new HashMap();
     
     // heavyweight attributes
     private WeblogEntryData weblogEntry = null;
@@ -203,6 +207,12 @@
             }
         }
         
+        // build customParams Map, we remove built-in params
+        customParams = new HashMap(request.getParameterMap());
+        customParams.remove("date");
+        customParams.remove("cat");
+        customParams.remove("page");
+            
         if(log.isDebugEnabled()) {
             log.debug("context = "+this.context);
             log.debug("weblogAnchor = "+this.weblogAnchor);
@@ -273,6 +283,14 @@
         this.pageNum = pageNum;
     }
 
+    public Map getCustomParams() {
+        return customParams;
+    }
+
+    public void setCustomParams(Map customParams) {
+        this.customParams = customParams;
+    }
+    
     public WeblogEntryData getWeblogEntry() {
         
         if(weblogEntry == null && weblogAnchor != null) {



Mime
View raw message