Author: cmailleux
Date: Thu Sep 13 17:57:12 2007
New Revision: 413

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D413&repname=
=3Desi_server
Log:
Turn WAS:ESIINCLUDETAG into html comment

Modified:
    trunk/src/net/sf/j2ep/responsehandlers/ResponseHandlerBase.java
    trunk/src/org/jahia/esi/FetcherTask.java

Modified: trunk/src/net/sf/j2ep/responsehandlers/ResponseHandlerBase.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/src/net/sf/j2ep=
/responsehandlers/ResponseHandlerBase.java&rev=3D413&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/net/sf/j2ep/responsehandlers/ResponseHandlerBase.java (origin=
al)
+++ trunk/src/net/sf/j2ep/responsehandlers/ResponseHandlerBase.java Thu Sep=
 13 17:57:12 2007
@@ -19,6 +19,7 @@
 import java.io.*;
 import java.net.*;
 import java.util.*;
+//import java.util.regex.Pattern;
 import java.util.zip.GZIPInputStream;
 import java.text.SimpleDateFormat;
 import java.text.ParseException;
@@ -62,7 +63,7 @@
 public abstract class ResponseHandlerBase implements ResponseHandler {
 =

     private static Log log =3D LogFactory.getLog(ResponseHandlerBase.class=
);
-
+//    private static Pattern pattern =3D Pattern.compile("<[/]?WAS:ESIINCL=
UDE_[0-9]{1,4}[ ]?>");
     private final static int NO_HTTP_RESPONSE_CODE =3D -1;
 =

     protected URL origRequestUrl;
@@ -1299,7 +1300,6 @@
         finally {
             cleanUp(fetchingSkeleton, runnableFetchers, mainCache, urlKey,=
 urlObj, userAclGroupKey, userName, requestInfo, futureTasks, success);
         }
-
         return new Object[]{wholePageBytes, (updatedUrlKey)?urlKey:null, n=
ew Boolean(fetchedNewData)};
     }
 =

@@ -1461,8 +1461,8 @@
                     fragUrlKey =3D (String) fragObj[0];
                     int fragPos =3D ((Integer) fragObj[1]).intValue();
 =

-                    String openTag =3D "WAS:ESIINCLUDE_"+fragPos+" >";  //=
TODO: for more robustness, could use htmlparser to find tags - but would be=
 slower
-                    String closeTag =3D  "/WAS:ESIINCLUDE_"+fragPos;
+                    String openTag =3D "<!--WAS:ESIINCLUDE_"+fragPos+"-->"=
;  //TODO: for more robustness, could use htmlparser to find tags - but wou=
ld be slower
+                    String closeTag =3D  "<!--/WAS:ESIINCLUDE_"+fragPos+"-=
->";
                     //String toReplace =3D StringUtils.getNestedString(new=
Str, openTag, closeTag); //TODO: this will not work for nested fragments
                     int openTagPos =3D oldSkelContent.indexOf (openTag);
                     int closeTagPos =3D oldSkelContent.indexOf(closeTag, o=
penTagPos);
@@ -1473,7 +1473,7 @@
                     }
 =

                     StringBuffer newTempSkelContent =3D new StringBuffer();
-                    newTempSkelContent.append( oldSkelContent.substring(0,=
openTagPos + openTag.length()) );
+                    newTempSkelContent.append(oldSkelContent.substring(0,o=
penTagPos + openTag.length()));
 =

                     CacheObject fragCacheObject =3D mainCache.get(fragUrlK=
ey);
                     String newFragContent=3Dnull;
@@ -1507,7 +1507,7 @@
                    }
 =

                     newTempSkelContent.append(newFragContent);
-                    newTempSkelContent.append( oldSkelContent.substring(cl=
oseTagPos-1) );
+                    newTempSkelContent.append(oldSkelContent.substring(clo=
seTagPos));
 =

                     //if (log.isDebugEnabled()) log.debug("AFTER: \n"+oldS=
kelContent);
 =

@@ -1551,6 +1551,16 @@
             }
             else
               log.warn("skeleton was invalidated when it shouldn't  : " +u=
rlKey);
+//            if (wholePageBytes !=3D null &&
+//                cacheObject !=3D null) {//sanity check due to http://www=
.jahia.org/jira/browse/ESI-115
+//                ContentCacheObject skeletonContentObj =3D cacheObject.ge=
tContentCacheObject();
+//                try {
+//                    String s =3D new String(wholePageBytes, skeletonCont=
entObj.getCharSet());
+//                    wholePageBytes =3D pattern.matcher(s).replaceAll(" "=
).getBytes(skeletonContentObj.getCharSet());
+//                } catch (UnsupportedEncodingException e) {
+//                    e.printStackTrace();//To change body of catch statem=
ent use File | Settings | File Templates.
+//                }
+//            }
         }
         return wholePageBytes;
     }

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=3D413&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 Thu Sep 13 17:57:12 2007
@@ -535,7 +535,7 @@
             for (NodeIterator e =3D list.elements (); e.hasMoreNodes (); )=
 {
                 /*if (log.isDebugEnabled()) log.debug ( "Final Output : " =
+ e.nextNode ().toHtml()); //can't do this line and one below it*/
                 String str =3D e.nextNode().toHtml();
-                if(!str.startsWith("</WAS:ESIINCLUDE_"))
+                if(!str.startsWith("<!--/WAS:ESIINCLUDE_"))
                     finalContents.append(str);
             }
             String finalContentsStr =3D finalContents.toString();
@@ -841,9 +841,9 @@
 =

             if (log.isDebugEnabled()) log.debug(id + " replacing node : "+=
esiTag.toHtml()+" with cached string content of length ["+cachedStringConte=
nt.length()+"]");
             //TODO: should really implement and contribute a NodeList.repl=
ace method
-            esiTag.getEndTag().setTagName("/WAS:ESIINCLUDE_"+pos);
-            esiTag.setTagName ("WAS:ESIINCLUDE_"+pos);
-            removeAllAttributes(esiTag, "WAS:ESIINCLUDE_"+pos);
+            esiTag.getEndTag().setTagName("!--/WAS:ESIINCLUDE_"+pos+"--");
+            esiTag.setTagName ("!--WAS:ESIINCLUDE_"+pos+"--");
+            removeAllAttributes(esiTag, "!--WAS:ESIINCLUDE_"+pos+"--");
             //(optionally) generate debug info
             if (settings.isAddCacheKeyDebugInfo()) {
                 if (tagCacheObject!=3Dnull) {
@@ -1491,15 +1491,16 @@
 =

     private void removeAllAttributes(TagNode tag, String attribToLeave) {
         Vector v =3D tag.getAttributesEx();
-
+        Vector result =3D new Vector(v.size());
         Enumeration enumAtt =3D v.elements();
         while (enumAtt.hasMoreElements()) {
             Attribute att =3D (Attribute) enumAtt.nextElement();
             //if (log.isDebugEnabled()) log.debug("name:"+att.getName()+" =
  Value:"+att.getValue()+ " -- " + att.toString());
-            if (att.getName()!=3Dnull && !attribToLeave.equalsIgnoreCase(a=
tt.getName())) {
-                tag.removeAttribute(att.getName());
+            if (att.getName()!=3Dnull && attribToLeave.equalsIgnoreCase(at=
t.getName())) {
+                result.add(att);
             }
         }
+        tag.setAttributesEx(result);
     }
 =

     private NodeList parseHtml(String stringOutput) throws ParserException=
 {

_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list

Reply via email to