shuber      2005/03/07 15:09:22 CET

  Modified files:        (Branch: JAHIA-4-1-BRANCH)
    src/java/org/jahia/operations OperationManager.java 
  Log:
  Fix for JAHIA-268 : jParams.setCacheExpirationDate & Delay cannot really 
deactivate page cache
  - Setting a past date in the jParams.setCacheExpirationDate or using 
setCacheExpirationDelay(0) will now prevent the page from being cached.
  
  Revision      Changes    Path
  1.34.2.2.2.3  +17 -12    
jahia/src/java/org/jahia/operations/OperationManager.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/src/java/org/jahia/operations/OperationManager.java.diff?r1=1.34.2.2.2.2&r2=1.34.2.2.2.3&f=h
  
  
  
  Index: OperationManager.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/src/java/org/jahia/operations/Attic/OperationManager.java,v
  retrieving revision 1.34.2.2.2.2
  retrieving revision 1.34.2.2.2.3
  diff -u -r1.34.2.2.2.2 -r1.34.2.2.2.3
  --- OperationManager.java     1 Mar 2005 16:56:50 -0000       1.34.2.2.2.2
  +++ OperationManager.java     7 Mar 2005 14:09:21 -0000       1.34.2.2.2.3
  @@ -406,7 +406,17 @@
               CacheEntry newEntry = new CacheEntry (htmlEntry);
               newEntry.setOperationMode (jParams.getOperationMode ());
   
  +            // Cannot proceed if the user information is not available
  +            if (jParams.getUser () == null)
  +                return;
   
  +            // Add the entry to the cache
  +            String entryKey = htmlCache.computeEntryKey (
  +                    Integer.toString (jParams.getPageID ()),
  +                    jParams.getUser ().getUsername (),
  +                    languageCode,
  +                    workflowState,
  +                    jParams.getUserAgent ());
   
               // compute the entry's expiration date
               if (jParams.settings ().getOutputCacheDefaultExpirationDelay () 
!= -1) {
  @@ -423,21 +433,16 @@
               // if a default expiration date has been set, us this instead.
               if (jParams.getCacheExpirationDate () != null) {
                   logger.debug ("Using default expiration date");
  +                Date nowDate = new Date();
  +                if (nowDate.compareTo(jParams.getCacheExpirationDate()) >= 
0) {
  +                    // cache will expire immediately -> we don't cache the
  +                    // page.
  +                    generatingPage.remove(entryKey);
  +                    return;
  +                }
                   newEntry.setExpirationDate (jParams.getCacheExpirationDate 
());
               }
   
  -            // Cannot proceed if the user information is not available
  -            if (jParams.getUser () == null)
  -                return;
  -
  -            // Add the entry to the cache
  -            String entryKey = htmlCache.computeEntryKey (
  -                    Integer.toString (jParams.getPageID ()),
  -                    jParams.getUser ().getUsername (),
  -                    languageCode,
  -                    workflowState,
  -                    jParams.getUserAgent ());
  -
               htmlCache.putCacheEntry (entryKey, newEntry, true);
               logger.debug("Added HTML page into the cache.");
               generatingPage.remove(entryKey);
  

Reply via email to