Author: cmailleux
Date: Mon Oct 8 10:25:37 2007
New Revision: 416
URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D416&repname=
=3Desi_server
Log:
ESI-359
Correctly handle files with special charcaters in xml invalidation messages
Modified:
trunk/src/org/jahia/esi/FetcherTask.java
trunk/src/org/jahia/esi/invalidation/services/Invalidator.java
Modified: trunk/src/org/jahia/esi/FetcherTask.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/src/org/jahia/e=
si/FetcherTask.java&rev=3D416&repname=3Desi_server
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/src/org/jahia/esi/FetcherTask.java (original)
+++ trunk/src/org/jahia/esi/FetcherTask.java Mon Oct 8 10:25:37 2007
@@ -41,50 +41,54 @@
=
package org.jahia.esi;
=
+import edu.emory.mathcs.backport.java.util.concurrent.*;
+import net.sf.j2ep.model.ServerContainer;
+import net.sf.j2ep.responsehandlers.ResponseHandlerBase;
+import net.sf.j2ep.rules.executor.RuleExecutor;
+import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.params.HostParams;
+import org.apache.commons.httpclient.util.DateParseException;
+import org.apache.commons.httpclient.util.DateUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.htmlparser.*;
-import org.htmlparser.lexer.Lexer;
+import org.htmlparser.Attribute;
+import org.htmlparser.Node;
+import org.htmlparser.PrototypicalNodeFactory;
+import org.htmlparser.Tag;
import org.htmlparser.filters.NodeClassFilter;
import org.htmlparser.filters.OrFilter;
-import org.htmlparser.util.NodeList;
+import org.htmlparser.lexer.Lexer;
+import org.htmlparser.nodes.TagNode;
+import org.htmlparser.nodes.TextNode;
import org.htmlparser.util.NodeIterator;
+import org.htmlparser.util.NodeList;
import org.htmlparser.util.ParserException;
-import org.htmlparser.nodes.TextNode;
-import org.htmlparser.nodes.TagNode;
-import org.jahia.esi.cache.*;
-import org.jahia.esi.cache.objects.RequestInfo;
+import org.jahia.esi.cache.CacheKeyGenerator;
+import org.jahia.esi.cache.MainCache;
import org.jahia.esi.cache.objects.CacheObject;
+import org.jahia.esi.cache.objects.RequestInfo;
import org.jahia.esi.cache.objects.UrlCacheObject;
-import org.jahia.esi.tags.EsiIncludeTag;
-import org.jahia.esi.tags.EsiRemoveTag;
-import org.jahia.esi.settings.SettingsBean;
-import org.jahia.esi.settings.SystemInit;
-import org.jahia.esi.exceptions.*;
+import org.jahia.esi.exceptions.ConnectionResetByPeerException;
+import org.jahia.esi.exceptions.DetailedServerException;
import org.jahia.esi.exceptions.RedirectException;
+import org.jahia.esi.exceptions.TransferFailedException;
import org.jahia.esi.invalidation.piggyback.PiggyBackInvalidator;
-import net.sf.j2ep.rules.executor.RuleExecutor;
-import net.sf.j2ep.model.ServerContainer;
-import net.sf.j2ep.responsehandlers.ResponseHandlerBase;
-import javax.servlet.http.HttpServletResponse;
+import org.jahia.esi.settings.SettingsBean;
+import org.jahia.esi.settings.SystemInit;
+import org.jahia.esi.tags.EsiIncludeTag;
+import org.jahia.esi.tags.EsiRemoveTag;
+
import javax.servlet.http.HttpServletRequest;
-import java.util.*;
-import java.io.InputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.net.MalformedURLException;
import java.net.SocketException;
import java.net.URL;
-import java.net.MalformedURLException;
-import java.text.SimpleDateFormat;
+import java.net.URLDecoder;
import java.text.ParseException;
-
-import org.apache.commons.httpclient.*;
-import org.apache.commons.httpclient.params.HostParams;
-import org.apache.commons.httpclient.util.DateUtil;
-import org.apache.commons.httpclient.util.DateParseException;
-import edu.emory.mathcs.backport.java.util.concurrent.*;
+import java.text.SimpleDateFormat;
+import java.util.*;
=
/**
* Fetches a resource - recursively if necessary. Resource can be : skelet=
on, fragment or non-esi-parsable
@@ -170,6 +174,7 @@
this.clientRequestUrl =3D clientRequestUrl;
this.httpClient =3D httpClient;
this.methodToServer =3D methodToServer;
+// this.methodToServer.setFollowRedirects(true);
this.responseHandlerBase =3D responseHandlerBase;
this.clientResponse =3D clientResponse;
this.clientRequest =3D clientRequest;
@@ -1076,55 +1081,79 @@
}
=
=
- private boolean fetchNonEsiParsableObjects (byte[] bytes) {
- //Deal with non-esi-parsable objects and exit
- if (methodToServer.getResponseHeader(EsiConst.JAHIAESI_PID) =3D=3D=
null //this is not a page
- || (methodToServer.getResponseHeader("Content-Type") !=3D=
null && !methodToServer.getResponseHeader("Content-Type").getValue().start=
sWith("text/html"))) {
+ private boolean fetchNonEsiParsableObjects(byte[] bytes) {
+ //Deal with non-esi-parsable objects and exit
+ if (methodToServer.getResponseHeader(EsiConst.JAHIAESI_PID) =3D=3D=
null
+ //this is not a page
+ ||
+ (methodToServer.getResponseHeader("Content-Type") !=3D null &&
+ !methodToServer.getResponseHeader("Content-Type").getValue().=
startsWith("text/html"))) {
//TODO: or could also use isContentEsi10=3D=3Dtrue, EsiConst.J=
AHIAESI_SITEID, or contentType.indexOf("text/html")=3D=3D-1 && contentType.=
indexOf("text/xhtml")=3D=3D-1
=
//do we want to store this object?
if (streamToCache) {
//this object returned an expiry date, so we should make o=
ur cache entry time-limited
- if (expiresHeaderDate!=3Dnull || maxAgeHeaderExpirationDat=
e!=3Dnull) {
+ if (expiresHeaderDate !=3D null || maxAgeHeaderExpirationD=
ate !=3D null) {
long expiryDate;
- if (expiresHeaderDate!=3Dnull)
- expiryDate =3D expiresHeaderDate.getTime();
- else
- expiryDate =3D maxAgeHeaderExpirationDate.getTime(=
);
+ if (expiresHeaderDate !=3D null) expiryDate =3D expire=
sHeaderDate.getTime();
+ else expiryDate =3D maxAgeHeaderExpirationDate.getTime=
();
=
long now =3D System.currentTimeMillis();
=
- if (log.isDebugEnabled()) log.debug(id + "- expiration=
time extracted from expiry Headers. Expires in ["+(expiryDate - now)/1000+=
"secs]");
+ if (log.isDebugEnabled()) log.debug(id +
+ "- expiration time=
extracted from expiry Headers. Expires in [" +
+ (expiryDate - now)=
/ 1000 +
+ "secs]");
=
requestInfo =3D new RequestInfo(false, EsiConst.USERAC=
LS_UNSET, null);
mainCache.addRequestInfo(requestInfoKey, requestInfo);
=
- mainCache.add(urlKey, this.methodToServer, bytes,
- this.clientRequestUrl,
- null, null, null ,null,null,
- (expiryDate - now)/1000,
- expiryDate/1000,
- settings.getDefaultMaxRemovalDelay(),
- true,
- false, //can put inUse=3Dfalse since we've s=
ent it already and won't use it again until another request
- !fetchingSkeleton,
- null,
- requestInfoKey,
- userAclGroupKey);
+ try {
+ mainCache.add(urlKey,
+ this.methodToServer,
+ bytes,
+ URLDecoder.decode(this.clientRequest=
Url, "UTF-8"),
+ null,
+ null,
+ null,
+ null,
+ null,
+ (expiryDate - now) / 1000,
+ expiryDate / 1000,
+ settings.getDefaultMaxRemovalDelay(),
+ true,
+ false,
+ //can put inUse=3Dfalse since we've =
sent it already and won't use it again until another request
+ !fetchingSkeleton,
+ null,
+ requestInfoKey,
+ userAclGroupKey);
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();//To change body of catch stat=
ement use File | Settings | File Templates.
+ }
}
//no expiry info in response, so set cache entry to defaul=
t expirations for the moment
else {
- mainCache.add ( urlKey ,
- this.methodToServer ,
- bytes ,
- this.clientRequestUrl,
- null, null, null ,null,null,
- true,
- false, //can put inUse=3Dfalse since we've sen=
t it already and won't use it again until another request
- !fetchingSkeleton,
- null,
- requestInfoKey,
- userAclGroupKey);
+ try {
+ mainCache.add(urlKey,
+ this.methodToServer,
+ bytes,
+ URLDecoder.decode(this.clientRequest=
Url, "UTF-8"),
+ null,
+ null,
+ null,
+ null,
+ null,
+ true,
+ false,
+ //can put inUse=3Dfalse since we've =
sent it already and won't use it again until another request
+ !fetchingSkeleton,
+ null,
+ requestInfoKey,
+ userAclGroupKey);
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();//To change body of catch stat=
ement use File | Settings | File Templates.
+ }
=
}
}
@@ -1132,7 +1161,7 @@
}
=
return false;
- }
+ }
=
private byte[] retrieveBytesFromServer()
throws TransferFailedException, RedirectException, DetailedSer=
verException, ConnectionResetByPeerException {
Modified: trunk/src/org/jahia/esi/invalidation/services/Invalidator.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/src/org/jahia/e=
si/invalidation/services/Invalidator.java&rev=3D416&repname=3Desi_server
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/src/org/jahia/esi/invalidation/services/Invalidator.java (origina=
l)
+++ trunk/src/org/jahia/esi/invalidation/services/Invalidator.java Mon Oct =
8 10:25:37 2007
@@ -52,6 +52,7 @@
import java.util.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
+import java.net.URLDecoder;
=
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.digester.Digester;
@@ -634,7 +635,12 @@
if ("URI".equals(other.getNAME()) &&
other.getVALUE() !=3D null) {
=
- Matcher mOtherpUriExp =3D getReformatedMatcher(oth=
er.getVALUE());
+ Matcher mOtherpUriExp =3D null;
+ try {
+ mOtherpUriExp =3D getReformatedMatcher(URLDeco=
der.decode(other.getVALUE(),"UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();//To change body of catch =
statement use File | Settings | File Templates.
+ }
Integer type =3D MATCHES;
if ("REGEX".equals(other.getTYPE()))
type =3D MATCHES;
_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list