mcardle 2005/12/14 17:46:03 CET
Modified files:
src/org/jahia/esi Utils.java
Log:
* support for first step in rewrite of backend cache code
* pages with "cache/off" param in url will now generate a cache entry
Revision Changes Path
1.16 +33 -12 esi_server/src/org/jahia/esi/Utils.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/esi_server/src/org/jahia/esi/Utils.java.diff?r1=1.15&r2=1.16&f=h
Index: Utils.java
===================================================================
RCS file: /home/cvs/repository/esi_server/src/org/jahia/esi/Utils.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- Utils.java 6 Dec 2005 14:43:00 -0000 1.15
+++ Utils.java 14 Dec 2005 16:46:02 -0000 1.16
@@ -47,7 +47,7 @@
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jahia.esi.settings.GeneralSettings;
+import org.jahia.esi.settings.SettingsBean;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
@@ -85,9 +85,9 @@
public static boolean isCacheUrlParamPresent(String url) {
if (url !=null && (
- (GeneralSettings.getInstance().isEnableCacheOff() &&
url.indexOf("/cache/off")!=-1)
- ||
(GeneralSettings.getInstance().isEnableCacheOffOnce() &&
url.indexOf("/cache/offonce")!=-1)
- ||
(GeneralSettings.getInstance().isEnableCacheBypass() &&
url.indexOf("/cache/bypass")!=-1)
+ (SettingsBean.getInstance().isEnableCacheOff() &&
url.indexOf("/cache/off")!=-1)
+ ||
(SettingsBean.getInstance().isEnableCacheOffOnce() &&
url.indexOf("/cache/offonce")!=-1)
+ || (SettingsBean.getInstance().isEnableCacheBypass()
&& url.indexOf("/cache/bypass")!=-1)
) ) {
if (log.isDebugEnabled()) log.debug("Detected a Cache UrlParam
present in URL:"+url);
return true;
@@ -97,7 +97,7 @@
public static boolean isCacheBypass(String url) {
if (url !=null && (
- (GeneralSettings.getInstance().isEnableCacheBypass() &&
url.indexOf("/cache/bypass")!=-1)
+ (SettingsBean.getInstance().isEnableCacheBypass() &&
url.indexOf("/cache/bypass")!=-1)
) ) {
if (log.isDebugEnabled()) log.debug("Detected a Cache BYPASS
operation on URL:"+url);
return true;
@@ -107,7 +107,7 @@
public static boolean isCacheOffOnce(String url) {
if (url !=null && (
- (GeneralSettings.getInstance().isEnableCacheOffOnce() &&
url.indexOf("/cache/offonce")!=-1)
+ (SettingsBean.getInstance().isEnableCacheOffOnce() &&
url.indexOf("/cache/offonce")!=-1)
) ) {
if (log.isDebugEnabled()) log.debug("Detected a Cache OFF_ONCE
operation on URL:"+url);
return true;
@@ -117,7 +117,7 @@
public static boolean isCacheOff(String url) {
if (url !=null && (
- (GeneralSettings.getInstance().isEnableCacheOff() &&
url.indexOf("/cache/off")!=-1)
+ (SettingsBean.getInstance().isEnableCacheOff() &&
url.indexOf("/cache/off")!=-1)
) ) {
if (log.isDebugEnabled()) log.debug("Detected a Cache OFF
operation on URL:"+url);
return true;
@@ -133,10 +133,30 @@
return newUrl.replaceFirst("/cache/offonce/","/");
}
- public static String[] removeCacheOffOnce(String[] urls) {
+ public static String removeCacheOff(String url) {
+ String newUrl = url;
+ if (url.indexOf("/cache/off/")==-1) {
+ log.warn("Couldn't find /cache/off parameter in the given url
(when it should've) : "+ url);
+ }
+ return newUrl.replaceFirst("/cache/off/","/");
+ }
+
+ public static String removeCacheParam(String url, boolean cacheoffonce) {
+ if (cacheoffonce)
+ return removeCacheOffOnce(url);
+ else
+ return removeCacheOff(url);
+ }
+
+ public static String[] removeCacheParam(String[] urls, boolean
cacheoffonce) {
String[] newUrls = new String[urls.length];
for (int i=0; i < urls.length; i++) {
- newUrls[i] =
removeCacheOffOnce(urls[i]);//urls[i].replaceFirst("/cache/offonce/","/");
+ if (cacheoffonce) {
+ newUrls[i] =
removeCacheOffOnce(urls[i]);//urls[i].replaceFirst("/cache/offonce/","/");
+ }
+ else {
+ newUrls[i] =
removeCacheOff(urls[i]);//urls[i].replaceFirst("/cache/off/","/");
+ }
}
return newUrls;
}
@@ -352,9 +372,10 @@
page.append("</head>\n" );
page.append("\n" );
page.append("<body bgcolor=\"white\">\n" );
- page.append ("<pre> \n" );
- page.append (getJahiaWebCacheLogo());
- page.append ("</pre>\n");
+ page.append("<img src='img/esi_logo_mini.png' /><br>");
+ //page.append ("<pre> \n" );
+ //page.append (getJahiaWebCacheLogo());
+ //page.append ("</pre>\n");
page.append("<fieldset style='border-width: 7px; border-color: red;
border: inset'> <font color=\"red\">\n" );
page.append("<h1>Error due to Response from Application Web
Server</h1>\n" );
page.append("<p>No Response from Application Web Server</p>\n" );