mcardle     2005/11/28 15:19:31 CET

  Modified files:
    core/src/java/org/jahia/services/esi 
                                         EsiInvalidationEventListener.java 
                                         EsiService.java 
    core/src/java/org/jahia/taglibs/esi JesiFragmentTag.java 
                                        JesiTemplateTag.java 
  Log:
  * reviewed Fragment's contentID reference re-initialisation mechanism
  
  Revision  Changes    Path
  1.9       +6 -0      
jahia/core/src/java/org/jahia/services/esi/EsiInvalidationEventListener.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/esi/EsiInvalidationEventListener.java.diff?r1=1.8&r2=1.9&f=h
  1.14      +100 -21   
jahia/core/src/java/org/jahia/services/esi/EsiService.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/esi/EsiService.java.diff?r1=1.13&r2=1.14&f=h
  1.12      +4 -0      
jahia/core/src/java/org/jahia/taglibs/esi/JesiFragmentTag.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/taglibs/esi/JesiFragmentTag.java.diff?r1=1.11&r2=1.12&f=h
  1.8       +3 -0      
jahia/core/src/java/org/jahia/taglibs/esi/JesiTemplateTag.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/taglibs/esi/JesiTemplateTag.java.diff?r1=1.7&r2=1.8&f=h
  
  
  
  Index: EsiInvalidationEventListener.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/java/org/jahia/services/esi/EsiInvalidationEventListener.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- EsiInvalidationEventListener.java 24 Nov 2005 14:39:36 -0000      1.8
  +++ EsiInvalidationEventListener.java 28 Nov 2005 14:19:30 -0000      1.9
  @@ -432,6 +432,12 @@
           
ServicesRegistry.getInstance().getEsiService().ctnListID0RequiresInvalidation(ctnListName,
 ctnListPageID);
           logger.debug("[esi] :  Triggering invalidation of CntListID0 [" + 
ctnListPageID +"_"+ ctnListName + "] which is a standalone ctnList");
   
  +        //TODO: for DEBUG purposes only so delete
  +        boolean refed = 
ServicesRegistry.getInstance().getEsiService().isCtnListID0AlreadyReferenced(ctnListPageID
 +"_"+ ctnListName);
  +        if (refed==false) {
  +            logger.debug("[esi] :  Could not find reference to CntListID0 [" 
+ ctnListPageID +"_"+ ctnListName + "] when it should!!");
  +        }
  +
       }
   
       private void invalidateCtnListID0(JahiaContainerList 
parentContainerList) throws JahiaException {
  
  
  
  Index: EsiService.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/java/org/jahia/services/esi/EsiService.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- EsiService.java   15 Nov 2005 12:50:37 -0000      1.13
  +++ EsiService.java   28 Nov 2005 14:19:30 -0000      1.14
  @@ -66,6 +66,7 @@
   
   
       public EsiService () {
  +
       }
   
       /**
  @@ -212,7 +213,7 @@
           }
           return result.toString();
       }
  -   /*  --------------------------------  END : ESI TAG STACK 
--------------------------------------- */
  +    /*  --------------------------------  END : ESI TAG STACK 
--------------------------------------- */
       /*  
-----------------------------------------------------------------------------------------------
 */
   
   
  @@ -254,10 +255,7 @@
               frg = (Fragment) Fragments.get(key);
               if ( frg.fragID !=  frg_fragcount)
                   logger.error("[esi]:  Number of tracked Fragments is 
inconsistant.");
  -            if (logger.isDebugEnabled()) logger.debug("[esi]:  Stack: adding 
ALREADY declared Fragment " +frg_fragcount );//+ ": " + frg.toString());
  -            frg.emptyContent();
  -            if (logger.isDebugEnabled())  logger.debug("[esi]:  Cleared all 
ContentIDs in Fragment [" +key+ "]");
  -
  +            //if (logger.isDebugEnabled()) logger.debug("[esi]:  Stack: 
inside ALREADY declared Fragment " +frg_fragcount );//+ ": " + frg.toString());
           }
   
           tagStackPush(frg);
  @@ -265,6 +263,30 @@
           return frg_fragcount;
       }
   
  +    /***
  +     * Clears the current Fragment of all references to any previously 
detected ContentIDs (via AOP) during the execution of
  +     * of the portion of the JSP page containing the fragment. We do this so 
that any content deleted from a
  +     * fragment by users will not continue being referenced by a Fragment 
object. A fresh AOP detection is
  +     * launched everytime to guarantee contentID integrity.
  +     *
  +     * @param frg_siteID
  +     * @param frg_pageID
  +     * @param frg_fragcount
  +     */
  +    public void emptyCurrentFragment (int frg_siteID, int frg_pageID, int 
frg_fragcount) {
  +        String key = frg_siteID + "_" + frg_pageID + "_" + frg_fragcount;
  +        Fragment frg = null;
  +        if (Fragments.containsKey(key)) {
  +            frg = (Fragment) Fragments.get(key);
  +            frg.emptyContent();
  +            if (logger.isDebugEnabled())  logger.debug("[esi]:  Cleared all 
ContentIDs in Fragment [" +key+ "]");
  +        }
  +        else {
  +            logger.error("[esi]: Trying to empty unknown Fragment 
["+key+"]");
  +        }
  +    }
  +
  +
       public Fragment getFragment (int siteID, int pageID, int frgCount) {
           return (Fragment) Fragments.get(siteID
                   + "_"
  @@ -319,7 +341,7 @@
           if ( Fragments.containsKey(frag_key) ) {
               Fragment frg = (Fragment) Fragments.remove(frag_key);
               if (frg!=null) {
  -                logger.info("[esi]:  Removed an old Fragment as the total 
number of Fragments in this page has increased (your template must have 
changed). Fragment details : " + frg);
  +                logger.debug("[esi]:  Removed an old Fragment as the total 
number of Fragments in this page has increased (your template must have 
changed). Fragment details : " + frg);
                   return true;
               }
           }
  @@ -349,14 +371,33 @@
           }
           else {
               tpl = (Template) Templates.get(key);
  -            if (logger.isDebugEnabled()) logger.debug("[esi]:  Stack: adding 
ALREADY declared Template on page:" + tpl.pageID );//+ tpl.toString());
  -            tpl.emptyContent();
  -            if (logger.isDebugEnabled())  logger.debug("[esi]:  Cleared all 
ContentIDs in Template on pageID [" +tpl.pageID+ "]");
  +            if (logger.isDebugEnabled()) logger.debug("[esi]:  Stack: inside 
ALREADY declared Template on page:" + tpl.pageID );//+ tpl.toString());
           }
   
           tagStackPush(tpl);
       }
   
  +    /***
  +     * Clears the current Template of all references to any previously 
detected ContentIDs (via AOP) during the execution of
  +     * of the portion of the JSP page containing the template. We do this so 
that any content deleted from a
  +     * template by users will not continue being referenced by a Template 
object. A fresh AOP detection is
  +     * launched everytime to guarantee contentID integrity.
  +     * @param siteID
  +     * @param pageID
  +     */
  +    public void emptyCurrentTemplate (int siteID, int pageID) {
  +        String key = siteID + "_" + pageID;
  +        Template tpl = null;
  +        if (Templates.containsKey(key)) {
  +            tpl = (Template) Templates.get(key);
  +            tpl.emptyContent();
  +            if (logger.isDebugEnabled())  logger.debug("[esi]:  Cleared all 
ContentIDs in Template on pageID [" +tpl.pageID+ "]");
  +        }
  +        else {
  +            logger.error("[esi]: Trying to empty unknown Template 
["+key+"]");
  +        }
  +    }
  +
       public Template getTemplate(int siteID, int pageID) {
           return (Template) Templates.get(siteID + "_" +  pageID);
       }
  @@ -404,12 +445,12 @@
               //TODO: get rid of this debug info
               if (logger.isDebugEnabled())
                   logger.debug(" checkForAnyContentToInvalidate: "
  -                 + "\nctnListsID0ToInvalidate: 
\t\t"+printContents(ctnListsID0ToInvalidate)
  -                 + "\nctnListsToInvalidate: 
\t\t"+printContents(ctnListsToInvalidate)
  -                 +"\nctnsToInvalidate: \t\t"+printContents(ctnsToInvalidate)
  -                 + "\npagesToInvalidate: 
\t\t"+printContents(pagesToInvalidate)
  -                 + "\nfieldsToInvalidate: 
\t\t"+printContents(fieldsToInvalidate)
  -                 + "\naclGroupTemplatesToInvalidate: 
\t\t"+printContents(aclGroupTemplatesToInvalidate) );
  +                        + "\nctnListsID0ToInvalidate: 
\t\t"+printContents(ctnListsID0ToInvalidate)
  +                        + "\nctnListsToInvalidate: 
\t\t"+printContents(ctnListsToInvalidate)
  +                        +"\nctnsToInvalidate: 
\t\t"+printContents(ctnsToInvalidate)
  +                        + "\npagesToInvalidate: 
\t\t"+printContents(pagesToInvalidate)
  +                        + "\nfieldsToInvalidate: 
\t\t"+printContents(fieldsToInvalidate)
  +                        + "\naclGroupTemplatesToInvalidate: 
\t\t"+printContents(aclGroupTemplatesToInvalidate) );
               notempty_count++;
               return true;
           }
  @@ -622,6 +663,42 @@
           return false;
       }
   
  +    //TODO: remove, for debug purposes only
  +    public boolean isCtnListID0AlreadyReferenced(final String 
ctnListIDOname) {
  +        //check all Templates
  +        Iterator pIter = Templates.keySet().iterator();
  +        while (pIter.hasNext()) {
  +            String tpl_key = (String) pIter.next();
  +            Template tpl = (Template) Templates.get(tpl_key);
  +            if (tpl.ctnListID0.containsKey(ctnListIDOname)) {
  +                if (logger.isDebugEnabled())
  +                    logger.debug("Found ctnListID0="+ctnListIDOname + " in 
Template "+tpl_key);
  +                return true;
  +            }
  +
  +        }
  +
  +        //check all Fragments
  +        pIter = Fragments.keySet().iterator();
  +        while (pIter.hasNext()) {
  +
  +            String frg_key = (String) pIter.next();
  +            Fragment frg = (Fragment) Fragments.get(frg_key);
  +            if (frg.ctnListID0.containsKey(ctnListIDOname))  {
  +                if (logger.isDebugEnabled() )
  +                    logger.debug("Found ctnListID0="+ctnListIDOname + " in 
Fragment "+frg_key);
  +                return true;
  +            }
  +
  +        }
  +        if (logger.isDebugEnabled() )
  +            logger.debug("Couldn't find ctnListID="+ctnListIDOname + " in 
Fragments/Templates");
  +        //nope, couldn't find it
  +        return false;
  +    }
  +
  +
  +
       /**
        *  clear the contentIDs contained in any Templates that were invalidated
        *           so that AOP will redetect all the contentIDs of these 
Templates
  @@ -629,6 +706,7 @@
        *           the JSP page
        * @param invalidatedTemplates list of invalidated templates
        */
  +    //TODO: remove since currently unused
       public void emptyInvalidatedTemplates (HashMap invalidatedTemplates) {
           if (!invalidatedTemplates.isEmpty()) {
               Iterator Itid = invalidatedTemplates.keySet().iterator();
  @@ -649,6 +727,7 @@
        *           the JSP page
        * @param invalidatedFragments list of invalidated fragments
        */
  +    //TODO: remove since currently unused
       public void emptyInvalidatedFragments (HashMap invalidatedFragments) {
           if (!invalidatedFragments.isEmpty()) {
               Iterator Itid = invalidatedFragments.keySet().iterator();
  @@ -696,7 +775,7 @@
                   pIter.remove();
               //fieldsToInvalidate.remove(tp_key);
               if (logger.isDebugEnabled())
  -                logger.debug("[esi]:  field " + tp_key + " was invalidated 
and removed from queue. (should be false 
["+fieldsToInvalidate.get(tp_key)+"])");
  +                logger.debug("[esi]:  field " + tp_key + " was invalidated 
and removed from queue. (should be null ["+fieldsToInvalidate.get(tp_key)+"])");
           }
   
           pIter = ctnsToInvalidate.keySet().iterator();
  @@ -707,7 +786,7 @@
                   pIter.remove();
               //ctnsToInvalidate.remove(tp_key);
               if (logger.isDebugEnabled())
  -                logger.debug("[esi]:  container " + tp_key + " was 
invalidated and removed from queue. (should be false 
["+ctnsToInvalidate.get(tp_key)+"])");
  +                logger.debug("[esi]:  container " + tp_key + " was 
invalidated and removed from queue. (should be null 
["+ctnsToInvalidate.get(tp_key)+"])");
           }
   
           pIter = ctnListsToInvalidate.keySet().iterator();
  @@ -718,7 +797,7 @@
                   pIter.remove();
               //ctnListsToInvalidate.remove(tp_key);
               if (logger.isDebugEnabled())
  -                logger.debug("[esi]:  containerList " + tp_key + " was 
invalidated and removed from queue. (should be false 
["+ctnListsToInvalidate.get(tp_key)+"])");
  +                logger.debug("[esi]:  containerList " + tp_key + " was 
invalidated and removed from queue. (should be null 
["+ctnListsToInvalidate.get(tp_key)+"])");
           }
   
           pIter = pagesToInvalidate.keySet().iterator();
  @@ -729,7 +808,7 @@
                   pIter.remove();
               //pagesToInvalidate.remove(tp_key);
               if (logger.isDebugEnabled())
  -                logger.debug("[esi]:  page " + tp_key + " was invalidated 
and removed from queue. (should be false ["+pagesToInvalidate.get(tp_key)+"])");
  +                logger.debug("[esi]:  page " + tp_key + " was invalidated 
and removed from queue. (should be null ["+pagesToInvalidate.get(tp_key)+"])");
           }
   
           pIter = ctnListsID0ToInvalidate.keySet().iterator();
  @@ -740,7 +819,7 @@
                   pIter.remove();
               //ctnListsToInvalidate.remove(tp_key);
               if (logger.isDebugEnabled())
  -                logger.debug("[esi]:  containerListID0 " + tp_key + " was 
invalidated and removed from queue. (should be false 
["+ctnListsID0ToInvalidate.get(tp_key)+"])");
  +                logger.debug("[esi]:  containerListID0 " + tp_key + " was 
invalidated and removed from queue. (should be null 
["+ctnListsID0ToInvalidate.get(tp_key)+"])");
           }
   
           //we can safely clear this:
  @@ -832,7 +911,7 @@
       }
   
       public void ctnListID0RequiresInvalidation (String ctnListName, int 
ctnListPageID) {
  -         ctnListsID0ToInvalidate.put( ctnListPageID+"_"+ctnListName, new 
Boolean(false) ); //Boolean is toggled once entry has been invalidated
  +        ctnListsID0ToInvalidate.put( ctnListPageID+"_"+ctnListName, new 
Boolean(false) ); //Boolean is toggled once entry has been invalidated
   
       }
   
  
  
  
  Index: JesiTemplateTag.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/java/org/jahia/taglibs/esi/JesiTemplateTag.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JesiTemplateTag.java      15 Nov 2005 12:47:40 -0000      1.7
  +++ JesiTemplateTag.java      28 Nov 2005 14:19:31 -0000      1.8
  @@ -102,6 +102,9 @@
               //No
               requestedFragment = JesiConst.NO_FRAGMENTS;//-1
   
  +            
ServicesRegistry.getInstance().getEsiService().emptyCurrentTemplate 
(Jahia.getThreadParamBean().getSiteID(),
  +                Jahia.getThreadParamBean().getPageID());
  +
               /*  //adding /tpl/ to URL so that invalidation protocol cannot 
just eliminate won't
                  int posgroup = String3.indexOf("/group/");
                 if (posgroup != -1) {
  
  
  
  Index: JesiFragmentTag.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/java/org/jahia/taglibs/esi/JesiFragmentTag.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- JesiFragmentTag.java      15 Nov 2005 12:47:40 -0000      1.11
  +++ JesiFragmentTag.java      28 Nov 2005 14:19:31 -0000      1.12
  @@ -99,6 +99,8 @@
                       //If requested Fragment is the current Fragment, Set ESI 
headers and buffer the body
                       if( requestedFragment == getCurrentFragCount() ) {
                           ((HttpServletResponse) 
pageContext.getResponse()).setHeader( JesiConst.SURROGATE_CONTROL_HEADER, 
makeSurrogateControl() );
  +                        
ServicesRegistry.getInstance().getEsiService().emptyCurrentFragment(Jahia.getThreadParamBean().getSiteID(),
  +                    Jahia.getThreadParamBean().getPageID(),fragCount);
                           return EVAL_BODY_BUFFERED;
                       }
                       //If no fragments are requested
  @@ -109,6 +111,8 @@
                           if(!JesiConst.UNSET.equals(aclGroup)) {
                               if (logger.isDebugEnabled())
                                   logger.debug("[esi]:  [esi]:  aclGroup 
fragment detected. Now evaluating body to get aclGroup param.");
  +                            
ServicesRegistry.getInstance().getEsiService().emptyCurrentFragment(Jahia.getThreadParamBean().getSiteID(),
  +                            
Jahia.getThreadParamBean().getPageID(),fragCount);
                               return EVAL_BODY_BUFFERED;
                           }
                           //skip the body and just include a ESI:include tag
  

Reply via email to