shuber      2005/03/07 15:07:25 CET

  Modified files:        (Branch: JAHIA-4-0-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.6  +18 -13    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.5&r2=1.34.2.6&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.5
  retrieving revision 1.34.2.6
  diff -u -r1.34.2.5 -r1.34.2.6
  --- OperationManager.java     1 Mar 2005 16:40:19 -0000       1.34.2.5
  +++ OperationManager.java     7 Mar 2005 14:07:24 -0000       1.34.2.6
  @@ -381,7 +381,7 @@
                                  int workflowState, String languageCode,
                                  String generatedOutput, String contentType) {
           logger.debug ("Storing generated content into the HTML Cache...");
  -        // Modified getOriginalCacheStatus to cacheStatus 
  +        // Modified getOriginalCacheStatus to cacheStatus
           if (("core".equals (jParams.getEngine ())) &&
                   ((ParamBean.CACHE_ON.equals 
(jParams.getOriginalCacheStatus() )) ||
                   (ParamBean.CACHE_ONLYUPDATE.equals 
(jParams.getOriginalCacheStatus() )) ||
  @@ -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