Author: cmailleux
Date: Thu Aug 30 17:54:18 2007
New Revision: 18317

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D18317&repname=
=3Djahia
Log:
Try to invalidate correctly container cache and esi template/fragment on ac=
l changes on fields, container, files

Modified:
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/engines/filemanage=
r/DAVFilemanager_Engine.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/engines/rights/Man=
ageRights.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/esi/EsiIn=
validationEventListener.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/esi/EsiIn=
validationWriterService.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/esi/EsiSO=
APInvalidatorService.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/esi/EsiSe=
rvice.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/esi/tagst=
ack/JesiObject.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/taglibs/container/=
ContainerCacheTag.java
    branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/taglibs/container/=
ContainerTag.java

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/engines/file=
manager/DAVFilemanager_Engine.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/engines/filemanager/DAVFilemanager_Engine.j=
ava&rev=3D18317&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/engines/filemanage=
r/DAVFilemanager_Engine.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/engines/filemanage=
r/DAVFilemanager_Engine.java Thu Aug 30 17:54:18 2007
@@ -39,6 +39,7 @@
 import org.jahia.engines.users.SelectUG_Engine;
 import org.jahia.engines.validation.EngineValidationHelper;
 import org.jahia.exceptions.JahiaException;
+import org.jahia.exceptions.JahiaInitializationException;
 import org.jahia.hibernate.model.JahiaAclEntry;
 import org.jahia.params.ParamBean;
 import org.jahia.params.ProcessingContext;
@@ -53,10 +54,17 @@
 import org.jahia.services.webdav.JahiaWebdavBaseService;
 import org.jahia.services.webdav.UsageEntry;
 import org.jahia.services.webdav.model.PropertyDefinition;
+import org.jahia.services.esi.ContentInfo;
+import org.jahia.services.esi.EsiService;
+import org.jahia.services.esi.EsiInvalidationEventListener;
+import org.jahia.services.cache.ContainerHTMLCache;
+import org.jahia.services.containers.ContentContainer;
+import org.jahia.services.containers.ContentContainerList;
 import org.jahia.tools.files.FileUpload;
 import org.jahia.utils.zip.ZipInputStream;
 import org.jahia.utils.zip.ZipEntry;
 import org.jahia.utils.zip.ZipOutputStream;
+import org.jahia.content.ContentObject;
 =

 import javax.servlet.ServletException;
 import javax.transaction.Status;
@@ -465,36 +473,77 @@
                                     .setAttribute("error",
                                             "org.jahia.engines.filemanager=
.Filemanager_Engine.readPermissionError.label");
                         }
-                        if (Jahia.getSettings().isEsiCacheActivated()) {
-                            final List usages =3D jahiaWebdavBaseService
-                                    .findUsages(objectDav.getPath(), jPara=
ms,
-                                            false);
-                            final Set list =3D new HashSet(usages.size());
-                            for (int i =3D 0; i < usages.size(); i++) {
-                                final UsageEntry theEntry =3D (UsageEntry)=
 usages
-                                        .get(i);
-                                list
-                                        .add(new Integer(theEntry.getPage()
-                                                .getID()));
-                            }
-                            if (list.size() < 50) {
-                                ServicesRegistry.getInstance()
-                                        .getEsiSOAPInvalidatorService()
-                                        .SOAPInvalidatePagesAndAllFrags(
-                                                Jahia.getThreadParamBean(),
-                                                list, true, true);
-                            } else {
-                                JahiaEvent flushEsiEvent =3D new JahiaEven=
t(this,
-                                        jParams, objectDav);
-                                try {
-                                    ServicesRegistry.getInstance()
-                                            .getJahiaEventService()
-                                            .fireFlushEsiCacheEvent(
-                                                    flushEsiEvent);
-                                } catch (JahiaException e) {
-                                    e.printStackTrace();
+                        else {
+                            try {
+                                ContainerHTMLCache cacheInstance =3D
+                                        ServicesRegistry.getInstance()
+                                                .getCacheService()
+                                                .getContainerHTMLCacheInst=
ance();
+                                ArrayList languageSettings =3D jParams.get=
Site().getLanguageSettingsAsLocales(true);
+
+                                final List usages =3D
+                                        jahiaWebdavBaseService.findUsages(=
objectDav.getPath(), jParams, false);
+                                final Set list =3D new HashSet(usages.size=
());
+                                for (int i =3D 0; i < usages.size(); i++) {
+                                    final UsageEntry theEntry =3D (UsageEn=
try) usages.get(i);
+                                    int ctnid =3D theEntry.getField().getc=
tnid();
+                                    ContentObject contentObject =3D (Conte=
ntObject) ContentContainer.getContainer(ctnid);
+                                    if (contentObject instanceof ContentCo=
ntainer) {
+                                        ContentContainer contentContainer =
=3D (ContentContainer) contentObject;
+                                        list.add(contentContainer);
+                                        ContentContainerList containerList=
 =3D
+                                                (ContentContainerList) con=
tentContainer.getParent(EntryLoadRequest.STAGED);
+                                        for (int j =3D 0; j < languageSett=
ings.size(); j++) {
+                                            Locale locale =3D (Locale) lan=
guageSettings.get(j);
+                                            cacheInstance.invalidateContai=
nerEntries(contentContainer.getObjectKey().toString(),
+                                                                          =
           EntryLoadRequest.STAGING_WORKFLOW_STATE,
+                                                                          =
           locale.toString());
+                                            cacheInstance.invalidateContai=
nerEntries(contentContainer.getObjectKey().toString(),
+                                                                          =
           EntryLoadRequest.ACTIVE_WORKFLOW_STATE,
+                                                                          =
           locale.toString());
+                                            cacheInstance.invalidateContai=
nerEntries(containerList.getObjectKey().toString(),
+                                                                          =
           EntryLoadRequest.ACTIVE_WORKFLOW_STATE,
+                                                                          =
           locale.toString());
+                                            cacheInstance.invalidateContai=
nerEntries(containerList.getObjectKey().toString(),
+                                                                          =
           EntryLoadRequest.ACTIVE_WORKFLOW_STATE,
+                                                                          =
           locale.toString());
+                                        }
+                                    }
                                 }
+                                if (Jahia.getSettings().isEsiCacheActivate=
d()) {
+                                    if (list.size() < 50) {
+                                        EsiService esiService =3D Services=
Registry.getInstance().getEsiService();
+                                        Iterator it =3D list.iterator();
+                                        while (it.hasNext()) {
+                                            ContentContainer ctnid =3D (Co=
ntentContainer) it.next();
+                                            esiService
+                                                    .ctnRequiresInvalidati=
on(ctnid.getID() + 1000,
+                                                                          =
   new ContentInfo(EsiService.CONTAINER,
+                                                                          =
                   ctnid.getID() + 1000,
+                                                                          =
                   EsiInvalidationEventListener.ACL_CHANGE_EVENT));
+                                            esiService
+                                                    .ctnListRequiresInvali=
dation(ctnid.getParentContainerListID(),
+                                                                          =
       new ContentInfo(EsiService.CONTAINERLIST,
+                                                                          =
                       ctnid.getParentContainerListID(),
+                                                                          =
                       EsiInvalidationEventListener.ACL_CHANGE_EVENT));
+                                        }
+                                    }
+                                    else {
+                                        JahiaEvent flushEsiEvent =3D new J=
ahiaEvent(this, jParams, objectDav);
+                                        try {
+                                            ServicesRegistry.getInstance()
+                                                    .getJahiaEventService()
+                                                    .fireFlushEsiCacheEven=
t(flushEsiEvent);
+                                        } catch (JahiaException e) {
+                                            e.printStackTrace();
+                                        }
 =

+                                    }
+                                }
+                            } catch (JahiaInitializationException e) {
+                                e.printStackTrace();//To change body of ca=
tch statement use File | Settings | File Templates.
+                            } catch (JahiaException e) {
+                                e.printStackTrace();//To change body of ca=
tch statement use File | Settings | File Templates.
                             }
                         }
                     }

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/engines/righ=
ts/ManageRights.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/engines/rights/ManageRights.java&rev=3D1831=
7&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/engines/rights/Man=
ageRights.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/engines/rights/Man=
ageRights.java Thu Aug 30 17:54:18 2007
@@ -21,6 +21,7 @@
 import org.jahia.bin.Jahia;
 import org.jahia.content.*;
 import org.jahia.data.containers.JahiaContainer;
+import org.jahia.data.containers.JahiaContainerList;
 import org.jahia.data.events.JahiaEvent;
 import org.jahia.engines.EngineMessage;
 import org.jahia.engines.EngineMessages;
@@ -37,6 +38,7 @@
 import org.jahia.registries.ServicesRegistry;
 import org.jahia.services.acl.*;
 import org.jahia.services.cache.HtmlCache;
+import org.jahia.services.cache.ContainerHTMLCache;
 import org.jahia.services.esi.ContentInfo;
 import org.jahia.services.esi.EsiInvalidationEventListener;
 import org.jahia.services.esi.EsiService;
@@ -48,6 +50,8 @@
 import org.jahia.services.pages.JahiaPage;
 import org.jahia.services.pages.JahiaPageService;
 import org.jahia.services.usermanager.*;
+import org.jahia.services.version.EntryLoadRequest;
+import org.jahia.services.containers.ContentContainer;
 import org.jahia.utils.JahiaTools;
 =

 import javax.servlet.ServletException;
@@ -990,29 +994,101 @@
 =

                 // Flush PageCache
                 JahiaPageService pageService =3D ServicesRegistry.getInsta=
nce().getJahiaPageService();
+                EsiService esiService =3D ServicesRegistry.getInstance().g=
etEsiService();
                 int pageID =3D processingContext.getPageID();
-                if(engineMap.containsKey("thePage")) {
-                    JahiaPage jahiaPage =3D ((JahiaPage) engineMap.get("th=
ePage"));
-                    pageID =3D jahiaPage.getID();
+                if (engineMap.containsKey("thePage")) {
+                    if (esiCacheActivated) {
+                        JahiaPage jahiaPage =3D ((JahiaPage) engineMap.get=
("thePage"));
+                        pageID =3D jahiaPage.getID();
+                        esiService.pageRequiresInvalidation(pageID,
+                                                            new ContentInf=
o(EsiService.PAGE,
+                                                                          =
  pageID,
+                                                                          =
  EsiInvalidationEventListener.ACL_CHANGE_EVENT));
+                        try {
+                            ContentObject object =3D jahiaPage.getContentP=
age().getParent(EntryLoadRequest.STAGED);
+                            if (object !=3D null) {
+                                ContentObject parent =3D object.getParent(=
EntryLoadRequest.STAGED);
+                                int i =3D parent.getID() + 1000;
+                                esiService.ctnRequiresInvalidation(i,
+                                                                   new Con=
tentInfo(EsiService.FIELD,
+                                                                          =
         i,
+                                                                          =
         EsiInvalidationEventListener.ACL_CHANGE_EVENT));
+                                ContentContainer contentObject =3D (Conten=
tContainer) parent;
+                                esiService.ctnListRequiresInvalidation(con=
tentObject.getParentContainerListID(),
+                                                                       new=
 ContentInfo(EsiService.CONTAINERLIST,
+                                                                          =
             contentObject.getParentContainerListID(),
+                                                                          =
             EsiInvalidationEventListener.ACL_CHANGE_EVENT));
+                            }
+                        } catch (JahiaException e) {
+                            logger.warn("Could not found the page parent f=
ield");
+                        }
+                    }
                 }
-                else if(engineMap.containsKey("theContainer")) {
+                else if (engineMap.containsKey("theContainer")) {
                     JahiaContainer jahiaContainer =3D ((JahiaContainer) en=
gineMap.get("theContainer"));
                     pageID =3D jahiaContainer.getPageID();
                     if (esiCacheActivated) {
-                        if (logger.isDebugEnabled())
-                            logger.debug("ACL ["+acl+"] was altered so tri=
ggering invalidation of container :" + jahiaContainer.getID() );
-                        ServicesRegistry.getInstance().getEsiService().ctn=
RequiresInvalidation(
-                                jahiaContainer,
-                                new ContentInfo(EsiService.CONTAINER,jahia=
Container.getID(), EsiInvalidationEventListener.ACL_CHANGE_EVENT)
-                        );
+                        if (logger.isDebugEnabled()) logger.debug("ACL [" +
+                                                                  acl +
+                                                                  "] was a=
ltered so triggering invalidation of container :" +
+                                                                  jahiaCon=
tainer.getID());
+                        esiService.templateReferencingContainerRequiresInv=
alidation(processingContext.getSiteID(),
+                                                                          =
          jahiaContainer.getID() + 1000,
+                                                                          =
          new ContentInfo(EsiService.CONTAINER,
+                                                                          =
                          jahiaContainer.getID() +
+                                                                          =
                          1000,
+                                                                          =
                          EsiInvalidationEventListener.ACL_CHANGE_EVENT));
                         int parentContainerListID =3D jahiaContainer.getLi=
stID();
-                        if (parentContainerListID>0) {
-                            if (logger.isDebugEnabled())
-                                logger.debug("ACL ["+acl+"] was altered so=
 triggering invalidation of parent container :" + parentContainerListID );
-                            ServicesRegistry.getInstance().getEsiService()=
.ctnRequiresInvalidation(
-                                    jahiaContainer,
-                                    new ContentInfo(EsiService.CONTAINERLI=
ST,jahiaContainer.getListID(), EsiInvalidationEventListener.ACL_CHANGE_EVEN=
T)
-                            );
+                        if (parentContainerListID > 0) {
+                            if (logger.isDebugEnabled()) logger.debug("ACL=
 [" +
+                                                                      acl +
+                                                                      "] w=
as altered so triggering invalidation of parent container :" +
+                                                                      pare=
ntContainerListID);
+                            esiService.ctnListRequiresInvalidation(parentC=
ontainerListID,
+                                                                   new Con=
tentInfo(EsiService.CONTAINERLIST,
+                                                                          =
         parentContainerListID,
+                                                                          =
         EsiInvalidationEventListener.ACL_CHANGE_EVENT));
+                        }
+                    }
+                }
+                else if (engineMap.containsKey("theContainerList")) {
+                    JahiaContainerList jahiaContainerList =3D ((JahiaConta=
inerList) engineMap.get("theContainerList"));
+
+                    ArrayList list =3D jahiaContainerList.getContentContai=
nerList()
+                            .getChilds(JahiaAdminUser.getAdminUser(0), Ent=
ryLoadRequest.STAGED);
+                    ContainerHTMLCache cacheInstance =3D
+                            ServicesRegistry.getInstance().getCacheService=
().getContainerHTMLCacheInstance();
+                    ArrayList languageSettings =3D processingContext.getSi=
te().getLanguageSettingsAsLocales(true);
+                    for (int i =3D 0; i < list.size(); i++) {
+                        ContentObject contentObject =3D (ContentObject) li=
st.get(i);
+                        if (contentObject instanceof ContentContainer) {
+                            ContentContainer contentContainer =3D (Content=
Container) contentObject;
+                            int id =3D contentContainer.getID() + 1000;
+                            ContentObject ctnList =3D contentContainer.get=
Parent(EntryLoadRequest.STAGED);
+                            for (int j =3D 0; j < languageSettings.size();=
 j++) {
+                                Locale locale =3D (Locale) languageSetting=
s.get(j);
+                                cacheInstance.invalidateContainerEntries(c=
ontentContainer.getObjectKey().toString(),
+                                                                         E=
ntryLoadRequest.STAGING_WORKFLOW_STATE,
+                                                                         l=
ocale.toString());
+                                cacheInstance.invalidateContainerEntries(c=
ontentContainer.getObjectKey().toString(),
+                                                                         E=
ntryLoadRequest.ACTIVE_WORKFLOW_STATE,
+                                                                         l=
ocale.toString());
+                                cacheInstance.invalidateContainerEntries(c=
tnList.getObjectKey().toString(),
+                                                                         E=
ntryLoadRequest.ACTIVE_WORKFLOW_STATE,
+                                                                         l=
ocale.toString());
+                            }
+                            if (esiCacheActivated) {
+                                esiService.ctnRequiresInvalidation(id,
+                                                                   new Con=
tentInfo(EsiService.CONTAINER,
+                                                                          =
         id,
+                                                                          =
         EsiInvalidationEventListener.ACL_CHANGE_EVENT));
+                            }
+                        }
+                        if (esiCacheActivated) {
+                            esiService.ctnListRequiresInvalidation(jahiaCo=
ntainerList.getID(),
+                                                                   new Con=
tentInfo(EsiService.CONTAINERLIST,
+                                                                          =
         jahiaContainerList.getID(),
+                                                                          =
         EsiInvalidationEventListener.ACL_CHANGE_EVENT));
                         }
                     }
                 }
@@ -1023,14 +1099,18 @@
                     pageService.invalidatePageCache(childPageId.intValue()=
);
                     //only invalidate esi cache entries of sub-pages if in=
heritance is changed
                     if (aclInheritanceAltered && esiCacheActivated) {
-                        if (logger.isDebugEnabled())
-                            logger.debug("ACL ["+acl+"] was altered so tri=
ggering invalidation of subpage :" + childPageId);
+                        if (logger.isDebugEnabled()) logger.debug("ACL [" +
+                                                                  acl +
+                                                                  "] was a=
ltered so triggering invalidation of subpage :" +
+                                                                  childPag=
eId);
                         esiPagesToInvalidate.add(childPageId);
                     }
                 }
                 if (esiCacheActivated) {
-                    if (logger.isDebugEnabled())
-                        logger.debug("ACL ["+acl+"] was altered so trigger=
ing invalidation of root page :" + pageID );
+                    if (logger.isDebugEnabled()) logger.debug("ACL [" +
+                                                              acl +
+                                                              "] was alter=
ed so triggering invalidation of root page :" +
+                                                              pageID);
                     esiPagesToInvalidate.add(new Integer(pageID));
                 }
                 pageService.invalidatePageCache(pageID);
@@ -1038,27 +1118,28 @@
                 if (esiCacheActivated) {
                     if (logger.isDebugEnabled()) {
                         Iterator iterUsers =3D esiUsersToInvalidate.iterat=
or();
-                        while(iterUsers.hasNext()) {
+                        while (iterUsers.hasNext()) {
                             JahiaUser jahiaUser =3D (JahiaUser) iterUsers.=
next();
-                            logger.debug("ACL ["+acl+"] was altered so tri=
ggering invalidation of user : " + jahiaUser.getUsername());
+                            logger.debug("ACL [" +
+                                         acl +
+                                         "] was altered so triggering inva=
lidation of user : " +
+                                         jahiaUser.getUsername());
                         }
                     }
                     //TODO: with aclGroup-template need to invalidate user=
's session on ESI and reset RequestInfo with Jahia servlet
-                    if (esiUsersToInvalidate.size()<50) {
+                    if (esiUsersToInvalidate.size() < 50) {
                         ServicesRegistry.getInstance().getEsiSOAPInvalidat=
orService()
-                                .SOAPInvalidatePagesAndAllFragsAndAllUserE=
ntries( Jahia.getThreadParamBean() ,
-                                        esiPagesToInvalidate,
-                                        esiUsersToInvalidate,
-                                        true,
-                                        true);
-                    } else {
-                        if (logger.isDebugEnabled())
-                            logger.info(esiUsersToInvalidate.size()+" user=
s affected by ACL ["+acl+"] alteration (which is over >50 threshold limit) =
so triggering ESI cache flush.");
+                                .SOAPInvalidateUsersTemplateEntries(proces=
singContext, esiUsersToInvalidate);
+                    }
+                    else {
+                        if (logger.isDebugEnabled()) logger.info(esiUsersT=
oInvalidate.size() +
+                                                                 " users a=
ffected by ACL [" +
+                                                                 acl +
+                                                                 "] altera=
tion (which is over >50 threshold limit) so triggering ESI cache flush.");
                         JahiaEvent flushEsiEvent =3D new JahiaEvent(this, =
processingContext, acl);
                         try {
                             ServicesRegistry.getInstance().getJahiaEventSe=
rvice().fireFlushEsiCacheEvent(flushEsiEvent);
-                        }
-                        catch (JahiaException ex) {
+                        } catch (JahiaException ex) {
                             throw new ServletException("[esi] : Error trig=
gering flush event", ex);
                         }
                     }

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/esi=
/EsiInvalidationEventListener.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/esi/EsiInvalidationEventListener.j=
ava&rev=3D18317&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=
validationEventListener.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/esi/EsiIn=
validationEventListener.java Thu Aug 30 17:54:18 2007
@@ -453,8 +453,8 @@
                     else {
                         if (logger.isDebugEnabled()) logger.debug("Inside =
ContentContainer - Updated");
                         //the container has simply been updated so we just=
 need to invalidate all Fragments/Templates referencing it
-                        esiService.ctnRequiresInvalidation(objID,
-                                                           new ContentInfo=
(EsiService.CONTAINER, objID, EventType));
+                        esiService.ctnRequiresInvalidation(objID+1000,
+                                                           new ContentInfo=
(EsiService.CONTAINER, objID+1000, EventType));
                         if (logger.isDebugEnabled()) logger.debug("[esi] :=
   Event " +
                                                                   EventTyp=
e +
                                                                   " trigge=
ring invalidation of  ContentContainer ID[" +

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=3D18317&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 Thu Aug 30 17:54:18 2007
@@ -730,6 +730,47 @@
         return str.toString();
     }
 =

+    public String getHeaderBasedUserTemplateInvalidationString (Set users)=
 {
+
+        //TODO: will invalidate entries shared with others,
+        //TODO: but also might not invalidate entries generated by other b=
ut used by the current user
+
+        StringBuffer str =3D new StringBuffer("");
+
+        Iterator iterUsers =3D users.iterator();
+        while(iterUsers.hasNext()) {
+
+            StringBuffer inv =3D new StringBuffer("");
+
+            JahiaUser jahiaUser =3D (JahiaUser) iterUsers.next();
+
+            inv.append("<HEADER NAME=3D\"").append(JesiConst.ESI_USER_HEAD=
ER).append("\" TYPE=3D\"REGEX\" VALUE=3D\"")
+                    .append("^").append(quote(jahiaUser.getUsername())).ap=
pend("$")
+                    .append("\"/> \n");
+            inv.append("<HEADER NAME=3D\"").append(JesiConst.ESI_TEMPLATE_=
HEADER).append("\" TYPE=3D\"REGEX\" VALUE=3D\"")
+                    .append("^yes$")
+                    .append("\"/> \n");
+            //cycle through each ESI IP/Port combination declared
+            //and create an invalidation entry for each combo:
+            for (int  i =3D 0; i < EsiServerIPs.length; i++) {
+                str.append("<OBJECT> \n");
+                str.append("<ADVANCEDSELECTOR URIPREFIX=3D\"/\" HOST=3D\"")
+                        .append( EsiServerIPs[i]).append(":").append(EsiSe=
rverPorts[i]).append("\"");
+                //TODO not yet supported
+                // str.append(" SEARCHKEY=3D\"").append("_user-").append(j=
ahiaUser.getUsername()).append("\""); //used by Esi server to speed up sear=
ch for objects to invalidate
+                str.append(" > \n");
+
+                str.append(inv.toString());
+                str.append("</ADVANCEDSELECTOR> \n");
+                str.append("<ACTION REMOVALTTL=3D\"").append("0").append("=
\" /> \n");
+                str.append("<INFO VALUE=3D\"remove-User-entries-for-").app=
end(jahiaUser.getUsername()).append("\"/> \n");
+                str.append("</OBJECT> \n");
+            }
+        }
+
+        return str.toString();
+    }
+
     /**
      * generates invalidation string to invalidate all fragments (shouldn'=
t be any templates) which were tagged
      * with the ESI_ALWAYS_INVALIDATE_HEADER header for the current pid.

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/esi=
/EsiSOAPInvalidatorService.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/esi/EsiSOAPInvalidatorService.java=
&rev=3D18317&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/EsiSO=
APInvalidatorService.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/esi/EsiSO=
APInvalidatorService.java Thu Aug 30 17:54:18 2007
@@ -114,7 +114,7 @@
      * @return true if successfully added, false otherwise
      */
     private boolean Transmit(String soapRequest) {
-
+        logger.debug(soapRequest);
         SettingsBean settings =3D Jahia.getSettings();
         EsiInvalidationWriterService esiInvalidationWriterService =3D Serv=
icesRegistry.getInstance().getEsiInvalidationWriterService();
 =

@@ -480,6 +480,28 @@
     }
 =

     /**
+     * invalidate all templates generated for a given set of users.
+     *
+     * (for more details : @see #SOAPInvalidateAllUserEntries)
+     *
+     * @param pc Current ProcessingContext object (i.e. ParamBean)
+     * @param users Set of JahiaUser objects where each JahiaUser holds th=
e user for which the entries are to be invalidated
+     * @return true if successful SOAP invalidation
+     */
+    public boolean SOAPInvalidateUsersTemplateEntries(ProcessingContext pc=
, Set users) {
+        //TODO: need to support invalidation of user Session on ESI server=
, when using aclGrouped shared templates
+        String invMessage =3D ServicesRegistry.getInstance().getEsiInvalid=
ationWriterService()
+                .getHeaderBasedUserTemplateInvalidationString (users);
+        if (invMessage!=3Dnull) {
+            String soapRequest =3D ServicesRegistry.getInstance().getEsiIn=
validationWriterService().addSOAPXMLWrapper(invMessage);
+            if (logger.isDebugEnabled())
+                logger.debug("[esi]:  SOAP Invalidation Message SOAPInvali=
dateAllUserEntries : \n" + soapRequest );
+            return Transmit(soapRequest);
+        }
+        return false; //nothing to invalidate
+    }
+
+    /**
      * invalidate all templates/fragments generated for a given user.
      *
      *

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/esi=
/EsiService.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/esi/EsiService.java&rev=3D18317&re=
pname=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/EsiSe=
rvice.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/esi/EsiSe=
rvice.java Thu Aug 30 17:54:18 2007
@@ -1519,16 +1519,17 @@
                 DataNode pidNode =3D cache.get(s);
                 if(pidNode!=3D null) {
                     Fragment fragment =3D (Fragment) pidNode.get(JesiObjec=
t.FRAGMENT_OBJ_MAPKEY);
-
-                    ContentInfo contentInfo =3D (ContentInfo) entry.getVal=
ue();
-                    boolean currentNodeRequiresLiveInvalidation =3D
-                                        EsiInvalidationEventListener.ACTIV=
ATION_EVENT.equals(contentInfo.getTriggeringEventType())
-                                        | EsiInvalidationEventListener.TIM=
E_PUBLISHING_EVENT.equals(contentInfo.getTriggeringEventType())
-                                        | EsiInvalidationEventListener.ACL=
_CHANGE_EVENT.equals(contentInfo.getTriggeringEventType())
-                                        ;
-                    if (currentNodeRequiresLiveInvalidation)
-                            fragment.setRequiresLiveInvalidation(true);
-                fragmentsToInvalidate.put(fragment.getNodeKey(),fragment);
+                    if(fragment!=3Dnull) {
+                        ContentInfo contentInfo =3D (ContentInfo) entry.ge=
tValue();
+                        boolean currentNodeRequiresLiveInvalidation =3D
+                                            EsiInvalidationEventListener.A=
CTIVATION_EVENT.equals(contentInfo.getTriggeringEventType())
+                                            | EsiInvalidationEventListener=
.TIME_PUBLISHING_EVENT.equals(contentInfo.getTriggeringEventType())
+                                            | EsiInvalidationEventListener=
.ACL_CHANGE_EVENT.equals(contentInfo.getTriggeringEventType())
+                                            ;
+                        if (currentNodeRequiresLiveInvalidation)
+                                fragment.setRequiresLiveInvalidation(true);
+                        fragmentsToInvalidate.put(fragment.getNodeKey(),fr=
agment);
+                    }
                     tempList.add(entry.getKey());
                 }
             } catch (CacheException e) {
@@ -2064,14 +2065,31 @@
      * @param ctn
      */
     public void ctnRequiresInvalidation (final JahiaContainer ctn, Content=
Info contentInfo) {//don't really need to put whole JahiaContainer object, =
could cut it down to a couple of ints
-        ctnsToInvalidate.put( Integer.toString(ctn.getID()), contentInfo )=
; //Boolean is toggled once entry has been invalidated
-        //new Integer[] {new Integer(ctn.getPageID()), new Integer(ctn.get=
ID())} );
+        ctnRequiresInvalidation(ctn.getID(),contentInfo);
     }
     public void ctnRequiresInvalidation (final int ctnID, ContentInfo cont=
entInfo) {
-        ctnsToInvalidate.put( Integer.toString(ctnID), contentInfo ); //Bo=
olean is toggled once entry has been invalidated
+        String key =3D Integer.toString(ctnID);
+        if(!ctnsToInvalidate.containsKey(key))
+        ctnsToInvalidate.put(key, contentInfo ); //Boolean is toggled once=
 entry has been invalidated
 =

     }
+    public void templateReferencingContainerRequiresInvalidation (final in=
t siteID, final int ctnID, ContentInfo contentInfo) {
+        try {
+            String s =3D JesiObject
+                    .OVERALL_NODEKEY + "/siteid_" + siteID + "/pid_" + 0 +=
 "/fragid_" + ctnID;
+            Set templates =3D cache.get(s+JesiObject.PAGES_NODEKEY).getDat=
aKeys();
+            if (templates !=3D null) {
+                Iterator iterator =3D templates.iterator();
+                while (iterator.hasNext()) {
+                    String template =3D (String) iterator.next();
+                    pagesToInvalidate.put(template, new ContentInfo(EsiSer=
vice.PAGE,Integer.parseInt(template),contentInfo.getTriggeringEventType()));
+                }
 =

+            }
+        } catch (CacheException e) {
+            e.printStackTrace();//To change body of catch statement use Fi=
le | Settings | File Templates.
+        }
+    }
     /**
      * add a ContainerList to the list of content to be invalidated, typic=
ally because the EsiInvalidationEventListener
      * detected an update/create/delete event on this content object.  All=
 ESI Fragments/Templates that point to
@@ -2079,12 +2097,13 @@
      * @param ctnList
      */
     public void ctnListRequiresInvalidation (final JahiaContainerList ctnL=
ist, ContentInfo contentInfo) {
-        ctnListsToInvalidate.put(Integer.toString(ctnList.getID()), conten=
tInfo );
-        //new Integer[] {new Integer(ctnList.getPageID()),new Integer(ctnL=
ist.getID()) } );
+        ctnListRequiresInvalidation(ctnList.getID(), contentInfo);
     }
     public void ctnListRequiresInvalidation (final int ctnListID, ContentI=
nfo contentInfo) {
-        ctnListsToInvalidate.put( Integer.toString(ctnListID), contentInfo=
 ); //Boolean is toggled once entry has been invalidated
-
+        String key =3D Integer.toString(ctnListID);
+        if(!ctnListsToInvalidate.containsKey(key)) {
+            ctnListsToInvalidate.put(key, contentInfo ); //Boolean is togg=
led once entry has been invalidated
+        }
     }
     /**
      * add a Page to the list of content to be invalidated, typically beca=
use the EsiInvalidationEventListener
@@ -2093,11 +2112,12 @@
      * @param page
      */
     public void pageRequiresInvalidation (final JahiaPage page, ContentInf=
o contentInfo) {
-        pagesToInvalidate.put(Integer.toString(page.getID()), contentInfo =
);
-        //new Integer(page.getID()));
+        pageRequiresInvalidation(page.getID(), contentInfo);
     }
     public void pageRequiresInvalidation (int pageID, ContentInfo contentI=
nfo) {
-        pagesToInvalidate.put( Integer.toString(pageID), contentInfo ); //=
Boolean is toggled once entry has been invalidated
+        String key =3D Integer.toString(pageID);
+        if(!pagesToInvalidate.containsKey(key))
+        pagesToInvalidate.put(key, contentInfo ); //Boolean is toggled onc=
e entry has been invalidated
     }
 =

     /**

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/esi=
/tagstack/JesiObject.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/esi/tagstack/JesiObject.java&rev=
=3D18317&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/tagst=
ack/JesiObject.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/esi/tagst=
ack/JesiObject.java Thu Aug 30 17:54:18 2007
@@ -430,15 +430,15 @@
             }
             //otherwise just put a simplified version:
             else {
-                objectInfo =3DDUMMY_VAL;//"pageID_"+pageID+"  Added on "+n=
ew Date();
+                objectInfo =3D DUMMY_VAL;//"pageID_"+pageID+"  Added on "+=
new Date();
             }
 =

             //sanity check
-            if (logger.isDebugEnabled() && getCache().exists(trackbackKey,=
nodeKey)) {
-                logger.debug("Should not be able to find matching ["+nodeK=
ey+"] contentID in trackback node ["+trackbackKey+"] for "+ getObjType() + =
".addPage(): defName:"+ pageID);
-            }
+//            if (logger.isDebugEnabled() && getCache().exists(trackbackKe=
y,nodeKey)) {
+//                logger.debug("Should not be able to find matching ["+nod=
eKey+"] contentID in trackback node ["+trackbackKey+"] for "+ getObjType() =
+ ".addPage(): defName:"+ pageID);
+//            }
 =

-            getCache().put(trackbackKey,nodeKey, objectInfo);
+//            getCache().put(trackbackKey,nodeKey, objectInfo);
 =

             RefInfo refInfo =3D new RefInfo(new Date(), objectInfo);
             getCache().put(contentTypeNodeKey, key, refInfo);
@@ -459,13 +459,13 @@
             }
 =

             //sanity check
-            if (!getCache().exists(trackbackKey,nodeKey)) {
-                logger.warn("Could not find matching ["+nodeKey+"] content=
ID in trackback node ["+trackbackKey+"] for "+ getObjType() + ".addPage(): =
defName:"+ pageID);
-                getCache().put(trackbackKey,nodeKey, "added after ERROR");
-            }
-
-            if (logger.isDebugEnabled())
-                logger.debug("[esi]:  Fragment.addPage(): pageID:" + pageI=
D + " to "+contentTypeNodeKey+" =3D=3D=3D>> Already added ");
+//            if (!getCache().exists(trackbackKey,nodeKey)) {
+//                logger.warn("Could not find matching ["+nodeKey+"] conte=
ntID in trackback node ["+trackbackKey+"] for "+ getObjType() + ".addPage()=
: defName:"+ pageID);
+//                getCache().put(trackbackKey,nodeKey, "added after ERROR"=
);
+//            }
+//
+//            if (logger.isDebugEnabled())
+//                logger.debug("[esi]:  Fragment.addPage(): pageID:" + pag=
eID + " to "+contentTypeNodeKey+" =3D=3D=3D>> Already added ");
             return false;
         }
     }

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/taglibs/cont=
ainer/ContainerCacheTag.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/taglibs/container/ContainerCacheTag.java&re=
v=3D18317&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/taglibs/container/=
ContainerCacheTag.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/taglibs/container/=
ContainerCacheTag.java Thu Aug 30 17:54:18 2007
@@ -148,10 +148,10 @@
                 if (content !=3D null && content.length() > 0) {
                     if ("true".equals(cache)) {
                         writeToContainerCache(container, jData, content);
-                        if (jData.getProcessingContext().settings().isEsiC=
acheActivated() &&
+                        if (parentTemplate !=3D null && (jData.getProcessi=
ngContext().settings().isEsiCacheActivated() &&
                             (parentTemplate.getRequestedFragmentBody()=3D=
=3Dnull &&
                              requestedFragment =3D=3D container.getID() + =
1000 &&
-                             (cacheKey=3D=3Dnull || cacheKey.equals(((Http=
ServletRequest)pageContext.getRequest()).getParameter("cachekey")))))
+                             (cacheKey=3D=3Dnull || cacheKey.equals(((Http=
ServletRequest)pageContext.getRequest()).getParameter("cachekey"))))))
                             parentTemplate.setRequestedFragmentBody(conten=
t);
                     }
                     getBodyContent().writeOut(getPreviousOut());
@@ -324,6 +324,11 @@
                                            user,
                                            !JesiConst.UNSET.equals(absolut=
e),
                                            !JesiConst.UNSET.equals(alwaysI=
nvalidate));
+            try {
+                fragment.addPage(processingContext.getPageID());
+            } catch (CacheException e) {
+                e.printStackTrace();//To change body of catch statement us=
e File | Settings | File Templates.
+            }
         }
         return b;
     }

Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/taglibs/cont=
ainer/ContainerTag.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/taglibs/container/ContainerTag.java&rev=3D1=
8317&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/taglibs/container/=
ContainerTag.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/taglibs/container/=
ContainerTag.java Thu Aug 30 17:54:18 2007
@@ -281,6 +281,11 @@
                                            user,
                                            !JesiConst.UNSET.equals(absolut=
e),
                                            !JesiConst.UNSET.equals(alwaysI=
nvalidate));
+            try {
+                fragment.addPage(processingContext.getPageID());
+            } catch (CacheException e) {
+                e.printStackTrace();//To change body of catch statement us=
e File | Settings | File Templates.
+            }
         }
         return b;
     }
@@ -294,7 +299,7 @@
                 if (content !=3D null && content.length() > 0) {
                     if ("true".equals(cache)) {
                         writeToContainerCache(container, jData, content);
-                        if (jData.getProcessingContext().settings().isEsiC=
acheActivated() && (parentTemplate.getRequestedFragmentBody()=3D=3Dnull && =
requestedFragment =3D=3D container.getID() + 1000 && (cacheKey=3D=3Dnull ||=
 cacheKey.equals(((HttpServletRequest)pageContext.getRequest()).getParamete=
r("cachekey")))))
+                        if (parentTemplate!=3Dnull && (jData.getProcessing=
Context().settings().isEsiCacheActivated() && (parentTemplate.getRequestedF=
ragmentBody()=3D=3Dnull && requestedFragment =3D=3D container.getID() + 100=
0 && (cacheKey=3D=3Dnull || cacheKey.equals(((HttpServletRequest)pageContex=
t.getRequest()).getParameter("cachekey"))))))
                             parentTemplate.setRequestedFragmentBody(conten=
t);
                     }
                     getBodyContent().writeOut(getPreviousOut());

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

Reply via email to