mcardle     2005/12/07 17:56:20 CET

  Modified files:
    core/src/java/org/jahia/services/esi 
                                         EsiInvalidationEventListener.java 
  Log:
  * rewrote ContentContainerList listener 

  * more error handling

  * deleted commented code
  
  Revision  Changes    Path
  1.10      +55 -59    
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.9&r2=1.10&f=h
  
  
  
  Index: EsiInvalidationEventListener.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/java/org/jahia/services/esi/EsiInvalidationEventListener.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- EsiInvalidationEventListener.java 28 Nov 2005 14:19:30 -0000      1.9
  +++ EsiInvalidationEventListener.java 7 Dec 2005 16:56:20 -0000       1.10
  @@ -181,7 +181,7 @@
                   } catch (JahiaException e) {
                       logger.error("[esi] :  could not load PARENT 
ContentContainerList [" + jahiaContainer.getListID() + "] . ex:"+e);
                   }
  -
  +                //TODO: extract a method out of following section since it 
is reused (wait till debugging is finished)
                   //initialized parentCtnList
                   if (jahiaContainer.getListID() != 0)  {
                       if 
(!esiService.isCtnListAlreadyReferenced(jahiaContainer.getListID())) {
  @@ -308,7 +308,7 @@
                   }
               }
               int objID = curContentObject.getID();
  -
  +            //*********************  ContentPage  *********************
               if (curContentObject instanceof ContentField) {
                   if (!EventType.equals("ObjectCreated")) {
                       esiService.fieldUpdateInvalidation(objID);
  @@ -318,11 +318,13 @@
                   else if (logger.isDebugEnabled())
                       logger.debug("[esi] :  (from contentObjectCreated()) 
fieldAdded DO NOTHING! Should be Covered by ASSOCIATED CONTAINER EVENT: " + 
jahiaEvent.getObject() + " (its parent JahiaContainer ID is "+ 
((ContentField)(jahiaEvent.getObject())).getContainerID()+ ")");
               }
  +            //*********************  ContentPage  *********************
               else if (curContentObject instanceof ContentPage) {
                   esiService.pageRequiresInvalidation(objID);
                   if (logger.isDebugEnabled())
                       logger.debug("[esi] :   Event " + EventType + " 
triggering invalidation of  ContentPage ID[" + objID + "]");
               }
  +            //*********************  ContentContainer  *********************
               else if (curContentObject instanceof ContentContainer) {
                   //A container was added so we simply need to invalidate its 
parent ContainerList
                   //since no one else should be referencing it yet
  @@ -335,7 +337,7 @@
                                   (ContentContainerList) (((ContentContainer) 
curContentObject)
                                           
.getParent(processingContext.getEntryLoadRequest()));
                           if (parentContainerList != null) {
  -
  +                         //TODO: extract a method out of following section 
since it is reused (wait till debugging is finished)
                               logger.debug("[esi] :  info: PARENT 
ContentContainerList [" + parentContainerList.getID() + "] for ContentContainer 
ID[" + objID + "].");
                               logger.debug("[esi] :  info: PARENT 
ContentContainerList [" + parentContainerList.getID() + "] has Parent Container 
ID[" + parentContainerList.getParentContainerID() + "]");
   
  @@ -349,7 +351,12 @@
                                   }
                                   else { //this is a uninitialized standalone 
(top level) ctnList
                                       if 
(!esiService.isCtnListAlreadyReferenced(parentContainerList.getID())) { //TODO: 
get rid of this if message below is never outputted
  -                                        
invalidateCtnListID0(parentContainerList);
  +                                        try {
  +                                            
invalidateCtnListID0(parentContainerList);
  +                                        } catch (JahiaException ex) {
  +                                            logger.error("Error invalidating 
parentContainerList ["+parentContainerList.getID()+"] during 
invalidateCtnListID0 "+ex);
  +                                        }
  +
                                       }
                                       else
                                           logger.error("[esi] :  PARENT 
ContentContainerList [" + parentContainerList.getID() + "] IS referenced but 
SHOUDLN'T.");
  @@ -358,7 +365,11 @@
                               else { //initialized ctnList
                                   if 
(!esiService.isCtnListAlreadyReferenced(parentContainerList.getID())) {
                                       //this is actually a new initialized 
ctnList which hasn't yet been referenced
  -                                    
invalidateCtnListID0(parentContainerList);
  +                                    try{
  +                                        
invalidateCtnListID0(parentContainerList);
  +                                    } catch (JahiaException ex) {
  +                                            logger.error("Error invalidating 
parentContainerList ["+parentContainerList.getID()+"] during 
invalidateCtnListID0 "+ex);
  +                                    }
                                   }
                                   else {
                                       
esiService.ctnListRequiresInvalidation(parentContainerList.getID());
  @@ -383,30 +394,52 @@
                           logger.debug("[esi] :   Event " + EventType + " 
triggering invalidation of  ContentContainer ID[" + objID + "]");
                   }
               }
  +            //*********************  ContentContainerList  
*********************
               else if (curContentObject instanceof ContentContainerList) {
   
                   //A containerList was added so we simply need to invalidate 
its parent Container
                   // (in the case when a CTNLIST contains CTNs which 
themselves contain CTNLISTs) -if it exists-
                   //since no one else should be referencing it yet
                   if (EventType.equals("ObjectCreated")) {
  -                    try {
  -                        //logger.debug("[esi] :  debug before getParent : " 
+(((ContentContainerList) curContentObject)
  -                        //        
.getParent(processingContext.getEntryLoadRequest())) );
  +                    ContentContainerList contentCtnList = 
(ContentContainerList) curContentObject;
  +                    //TODO: extract a method out of following section since 
it is reused (wait till debugging is finished)
  +                    logger.debug("[esi] :  info: ContentContainerList [" + 
contentCtnList.getID() + "]");
  +                    logger.debug("[esi] :  info: ContentContainerList [" + 
contentCtnList.getID() + "] has Parent Container ID[" + 
contentCtnList.getParentContainerID() + "]");
   
  -                        ContentContainer parentContainer =
  -                                (ContentContainer) (((ContentContainerList) 
curContentObject)
  -                                        
.getParent(processingContext.getEntryLoadRequest()));
  -                        if (parentContainer != null) {
  -                            
esiService.ctnRequiresInvalidation(parentContainer.getID());
  -                            if (logger.isDebugEnabled())
  -                                logger.debug("[esi] :  Successfully detected 
and invalidating PARENT ContentContainer [" + parentContainer.getID() + "] for 
ContentContainerList ID[" + objID + "]");
  -                        } else
  -                        if (logger.isDebugEnabled())
  -                            logger.debug("[esi] :   Could not get Parent 
ContentContainer for ContentContainerList ID[" + objID + "]");
  +                            if ( contentCtnList.getID()==0 ) { 
//uninitialized ctnList?
   
  -                    } catch (Exception ex5){
  -                        if (logger.isDebugEnabled())
  -                            logger.debug("[esi] :   Could not get Parent 
ContentContainer for ContentContainerList ID[" + objID + "], ContainerList 
might therefore not have a parent (i.e. parent is the page) "+ex5);
  +                                if 
(contentCtnList.getParentContainerID()!=0) { //ctnList is enclosed inside a 
valid ctn
  +                                    //invalidate ctn containing 
uninitialized ctnList containing created ctn (!?)
  +                                    
esiService.ctnRequiresInvalidation(contentCtnList.getParentContainerID());
  +                                    if (logger.isDebugEnabled())
  +                                            logger.debug("[esi] :  
Triggering invalidation of the PARENT Container [" + 
contentCtnList.getParentContainerID() + "] of ContainerList 
["+contentCtnList.getID()+"]");
  +                                }
  +                                else { //this is a uninitialized standalone 
(top level) ctnList
  +                                    if 
(!esiService.isCtnListAlreadyReferenced(contentCtnList.getID())) { //TODO: get 
rid of this if message below is never outputted
  +                                        try{
  +                                            
invalidateCtnListID0(contentCtnList);
  +                                        } catch (JahiaException ex) {
  +                                            logger.error("Error invalidating 
contentCtnList ["+contentCtnList.getID()+"] during invalidateCtnListID0 "+ex);
  +                                        }
  +                                    }
  +                                    else
  +                                        logger.error("[esi] : 
ContentContainerList [" + contentCtnList.getID() + "] IS referenced but 
SHOUDLN'T.");
  +                                }
  +                            }
  +                            else { //initialized ctnList
  +                                if 
(!esiService.isCtnListAlreadyReferenced(contentCtnList.getID())) {
  +                                    //this is actually a new initialized 
ctnList which hasn't yet been referenced
  +                                    try{
  +                                        invalidateCtnListID0(contentCtnList);
  +                                    } catch (JahiaException ex) {
  +                                            logger.error("Error invalidating 
contentCtnList ["+contentCtnList.getID()+"] during invalidateCtnListID0 "+ex);
  +                                    }
  +                                }
  +                                else {
  +                                    
esiService.ctnListRequiresInvalidation(contentCtnList.getID());
  +                                    if (logger.isDebugEnabled())
  +                                        logger.debug("[esi] :  Invalidating 
ContentContainerList [" + contentCtnList.getID() + "] ");
  +                                }
                       }
                   }
                   else  {
  @@ -435,7 +468,7 @@
           //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!!");
  +            logger.warn("[esi] :  Could not find reference to CntListID0 [" 
+ ctnListPageID +"_"+ ctnListName + "] when it should!!");
           }
   
       }
  @@ -457,40 +490,3 @@
   //TODO: Add support for the following events:
   // public void objectChanged( WorkflowEvent je ) { return; }
   
  -
  -
  -/*
  -        if (logger.isDebugEnabled()) {
  -            logger.debug("[esi] :  Successfully detected PARENT 
ContentContainerList [" + parentContainerList.getID() + "] for ContentContainer 
ID[" + objID + "].");
  -            logger.debug("[esi] :  info: PARENT ContentContainerList [" + 
parentContainerList.getID() + "] has Parent Container ID[" + 
parentContainerList.getParentContainerID() + "]");
  -        }
  -        boolean isCtnListAlreadyReferenced = 
esiService.isCtnListAlreadyReferenced(
  -                                                                             
       parentContainerList.getID());
  -        if (    parentContainerList.getParentContainerID()==0 && //i.e. is 
this a standalone (top level) ctnList?
  -                parentContainerList.getID()==0 && //i.e. is this an 
uninitialized ctnList?
  -                !isCtnListAlreadyReferenced
  -                ) {
  -            if (parentContainerList.getID()==0)
  -                logger.error("ERROR: Detected ctnList with ID=0 but with 
parent ID==0. Do what??. 
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
  -
  -                invalidateCtnListID0(parentContainerList);
  -
  -        }
  -        if ( parentContainerList.getID()==0 //i.e. is this an uninitialized 
ctnList?
  -                && parentContainerList.getParentContainerID()==0 //i.e. is 
this a standalone ctnList?
  -                ) {
  -            //we have detected a uninitialized standalone ctnList
  -            invalidateCtnListID0(parentContainerList);
  -        }
  -        else if (parentContainerList.getID()==0) {
  -             logger.error("ERROR: Detected ctnList with ID=0 but with parent 
ID!=0. This shouldn't occur.");
  -        }
  -        else {
  -            if (logger.isDebugEnabled())
  -                logger.debug("[esi] :  Invalidating PARENT 
ContentContainerList [" + parentContainerList.getID() + "] ");
  -            
esiService.ctnListRequiresInvalidation(parentContainerList.getID());
  -        }
  -    }
  -    else
  -        logger.warn("[esi] :   Could not get Parent ContentContainerList for 
ContentContainer ID[" + objID + "]. The ID of the parent ContentContainerList 
was ["+((ContentContainer) curContentObject).getParentContainerListID()+"]");
  -*/
  \ No newline at end of file
  

Reply via email to