Author: cmailleux
Date: Tue Oct  2 18:05:47 2007
New Revision: 18729

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D18729&repname=
=3Djahia
Log:
Always invalidate fragment are also binded to mode so do not invalidate fra=
gment in live if template is not invalidated in live also.

This will correct issue ESI-344

Modified:
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/esi/EsiIn=
validationWriterService.java

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/esi=
/EsiInvalidationWriterService.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/esi/EsiInvalidationWriterService.j=
ava&rev=3D18729&repname=3Djahia
=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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/esi/EsiIn=
validationWriterService.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/esi/EsiIn=
validationWriterService.java Tue Oct  2 18:05:47 2007
@@ -779,11 +779,12 @@
      *
      *
      * @param pageID
+     * @param aBoolean
      * @return
      */
     //TODO: if we detect alwaysInvalidate Fragment in JSP, then store this=
 in the JesiObject
     //TODO: and only then if there is one should we generate an alwaysInva=
lidate command
-    public String getHeaderBasedAlwaysInvalidateInvalidationString (int pa=
geID) {
+    public String getHeaderBasedAlwaysInvalidateInvalidationString(int pag=
eID, Boolean takeStagingIntoAccount) {
 =

         StringBuffer inv =3D new StringBuffer("");
 =

@@ -794,7 +795,9 @@
         inv.append("<HEADER NAME=3D\"").append(JesiConst.ESI_PID_HEADER).a=
ppend("\" TYPE=3D\"REGEX\" VALUE=3D\"")
                 .append("^").append(pageID).append("$")
                 .append("\"/> \n");
-
+        String stagingInvalidationString =3D "";
+        if (!takeStagingIntoAccount.booleanValue())
+            stagingInvalidationString =3D getHeaderBasedStagingInvalidatio=
nString();
         StringBuffer str =3D new StringBuffer("");
 =

         //cycle through each ESI IP/Port combination declared
@@ -806,6 +809,7 @@
             str.append(" SEARCHKEY=3D\"").append("_pid-").append(pageID).a=
ppend("_alwaysInv").append("\""); //used by Esi server to speed up search f=
or objects to invalidate
             str.append("> \n");
             str.append(inv.toString());
+            str.append(stagingInvalidationString);
             str.append("</ADVANCEDSELECTOR> \n");
             str.append("<ACTION REMOVALTTL=3D\"").append("0").append("\" /=
> \n");
             str.append("<INFO VALUE=3D\"remove-AlwaysInvalidate-on-PID-").=
append(pageID).append("\"/> \n");
@@ -848,7 +852,7 @@
         }
         */
         HashMap sitesToInvalidate =3D esiService.getSitesToInvalidate();
-
+        Map templatesLiveOrStagingOnly =3D new HashMap();
         try {
 =

             //clear all content objects that triggered fragment/template i=
nvalidations
@@ -885,8 +889,11 @@
                         //make sure all AlwaysInvalidate attributed Fragme=
nts are also invalidated on this page
                         Integer pageidInt =3D new Integer(tpl.getPageID());
                         //only add alwaysInv command for tpl containing al=
waysInv fragments
-                        if (tpl.containsAlwaysInvalidateFrags())
+                        if (tpl.containsAlwaysInvalidateFrags()){
                             pidsToInvalidateViaAlwayInvalidate.add(pageidI=
nt);
+                            templatesLiveOrStagingOnly.put(new Integer(tpl=
.getPageID()),tpl.isRequiresLiveInvalidation()?Boolean.TRUE:
+                                                                          =
 Boolean.FALSE);
+                        }
                     }
                     else {
                        logger.debug("[esi]: Template has already been dele=
ted from TreeCache : " + tpl);
@@ -940,8 +947,11 @@
                         //TODO: only add if it pid contains enclosed alway=
sInvalidate frags
 =

                         Template enclosingTpl =3D ServicesRegistry.getInst=
ance().getEsiService().getTemplate(pageidInt.intValue());
-                        if (enclosingTpl!=3Dnull && enclosingTpl.containsA=
lwaysInvalidateFrags())
+                        if (enclosingTpl!=3Dnull && enclosingTpl.containsA=
lwaysInvalidateFrags()) {
                             pidsToInvalidateViaAlwayInvalidate.add(pageidI=
nt);
+                            templatesLiveOrStagingOnly.put(pageidInt,frg.i=
sRequiresLiveInvalidation()?Boolean.TRUE:
+                                                                          =
 Boolean.FALSE);
+                        }
                    }
                     else {
                         logger.debug("[esi]: Fragment has already been del=
eted from TreeCache : " + frg);
@@ -968,7 +978,8 @@
                 while (pidsIter.hasNext()) {
                     Integer pidInt  =3D (Integer) pidsIter.next();
                     str.append(
-                            getHeaderBasedAlwaysInvalidateInvalidationStri=
ng( pidInt.intValue() )
+                            getHeaderBasedAlwaysInvalidateInvalidationStri=
ng( pidInt.intValue(),
+                                                                          =
    (Boolean) templatesLiveOrStagingOnly.get(pidInt) )
                     );
                 }
 =

@@ -1017,7 +1028,8 @@
                 Template enclosingTpl =3D ServicesRegistry.getInstance().g=
etEsiService().getTemplate(pid);
                 if (enclosingTpl!=3Dnull && enclosingTpl.containsAlwaysInv=
alidateFrags()) {
                     str.append(
-                            getHeaderBasedAlwaysInvalidateInvalidationStri=
ng( pid )
+                            getHeaderBasedAlwaysInvalidateInvalidationStri=
ng( pid,frg.isRequiresLiveInvalidation()?Boolean.TRUE:
+                                                                          =
 Boolean.FALSE)
                     );
                 }
 =

@@ -1130,7 +1142,9 @@
                     }
 =

                     str.append(
-                            getHeaderBasedAlwaysInvalidateInvalidationStri=
ng( tpl.getPageID() )
+                            getHeaderBasedAlwaysInvalidateInvalidationStri=
ng( tpl.getPageID(),
+                                                                          =
    tpl.isRequiresLiveInvalidation()?Boolean.TRUE:
+                                                                          =
 Boolean.FALSE)
                     );
 =

                     return str.toString();

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

Reply via email to