roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r575092 - in /roller/branches/roller_3.1/src/org/apache/roller: ui/authoring/struts/actions/WeblogEntryFormAction.java util/cache/FuturePostingsInvalidationJob.java
Date Wed, 12 Sep 2007 21:50:13 GMT
Author: snoopdave
Date: Wed Sep 12 14:50:13 2007
New Revision: 575092

URL: http://svn.apache.org/viewvc?rev=575092&view=rev
Log:
Fix for http://opensource.atlassian.com/projects/roller/browse/ROL-1558

Added logic to weblog editor to prevent indexing of future postings and added logic to future-postings
task to index future posts.

Modified:
    roller/branches/roller_3.1/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryFormAction.java
    roller/branches/roller_3.1/src/org/apache/roller/util/cache/FuturePostingsInvalidationJob.java

Modified: roller/branches/roller_3.1/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryFormAction.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_3.1/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryFormAction.java?rev=575092&r1=575091&r2=575092&view=diff
==============================================================================
--- roller/branches/roller_3.1/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryFormAction.java
(original)
+++ roller/branches/roller_3.1/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryFormAction.java
Wed Sep 12 14:50:13 2007
@@ -325,18 +325,16 @@
                 
                 request.setAttribute(
                         RequestConstants.WEBLOGENTRY_ID, entry.getId());
+
                 
-                // Reindex entry, flush caches, etc.
-                reindexEntry(RollerFactory.getRoller(), entry);
-                mLogger.debug("Removing from cache");
-                RollerRequest rreq = RollerRequest.getRollerRequest(request);
-                //PageCacheFilter.removeFromCache(request, entry.getWebsite());
-                CacheManager.invalidate(entry);
-                
-                // Queue applicable pings for this update.
-                if(entry.isPublished()) {
+                // If entry now published then index, flush and ping
+                Date now = new Date();
+                if (!entry.getPubTime().after(now) && entry.isPublished()) {    
               
+                    reindexEntry(RollerFactory.getRoller(), entry);
+                    CacheManager.invalidate(entry);
                     RollerFactory.getRoller().getAutopingManager().queueApplicableAutoPings(entry);
                 }
+                
                 
                 // Clean up session objects we used
                 HttpSession session = request.getSession(true);

Modified: roller/branches/roller_3.1/src/org/apache/roller/util/cache/FuturePostingsInvalidationJob.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_3.1/src/org/apache/roller/util/cache/FuturePostingsInvalidationJob.java?rev=575092&r1=575091&r2=575092&view=diff
==============================================================================
--- roller/branches/roller_3.1/src/org/apache/roller/util/cache/FuturePostingsInvalidationJob.java
(original)
+++ roller/branches/roller_3.1/src/org/apache/roller/util/cache/FuturePostingsInvalidationJob.java
Wed Sep 12 14:50:13 2007
@@ -19,6 +19,7 @@
 package org.apache.roller.util.cache;
 
 import java.util.Calendar;
+import java.util.Collection;
 import java.util.Date;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -32,6 +33,7 @@
 import org.apache.roller.business.RollerFactory;
 import org.apache.roller.business.UserManager;
 import org.apache.roller.business.WeblogManager;
+import org.apache.roller.business.search.IndexManager;
 import org.apache.roller.pojos.WeblogEntryData;
 import org.apache.roller.pojos.WebsiteData;
 
@@ -61,7 +63,8 @@
     private Map inputs = null;
     
     // the set of entries we expire at the start of the next run
-    private Set nextExpirations = null;
+    private Collection nextWeblogExpirations = null;
+    private Collection nextEntryExpirations = null;
     
     // how far into the future we will look ahead, in minutes
     int peerTime = 5;
@@ -73,14 +76,15 @@
         try {
             WeblogManager wMgr = RollerFactory.getRoller().getWeblogManager();
             UserManager uMgr = RollerFactory.getRoller().getUserManager();
-            
+            IndexManager searchMgr = RollerFactory.getRoller().getIndexManager();
+
             Date now = new Date();
             
-            if(nextExpirations != null) {
+            if(nextWeblogExpirations != null) {
                 String websiteid = null;
                 WebsiteData weblog = null;
                 
-                Iterator weblogs = nextExpirations.iterator();
+                Iterator weblogs = nextWeblogExpirations.iterator();
                 while(weblogs.hasNext()) {
                     websiteid = (String) weblogs.next();
                     
@@ -96,12 +100,20 @@
                         uMgr.saveWebsite(weblog);
                         
                     } catch (RollerException ex) {
-                        log.warn("couldn't lookup entry "+websiteid);
+                        log.warn("couldn't lookup website " + websiteid);
                     }
                 }
                 
+                Iterator entries = nextEntryExpirations.iterator();
+                while(entries.hasNext()) {
+                    WeblogEntryData entry = (WeblogEntryData)entries.next();
+                    // trigger search index on entry
+                    searchMgr.addEntryReIndexOperation(entry);
+                }
+
                 // commit the changes
                 RollerFactory.getRoller().flush();
+
             }
             
             // XX mins in the future
@@ -120,13 +132,15 @@
             Set expiringWeblogs = new HashSet();
             Iterator it = expiringEntries.iterator();
             while(it.hasNext()) {
-                expiringWeblogs.add(((WeblogEntryData) it.next()).getWebsite().getId());
+                WeblogEntryData entry = (WeblogEntryData)it.next();
+                expiringWeblogs.add(entry.getWebsite().getId());
             }
             
-            this.nextExpirations = expiringWeblogs;
+            this.nextWeblogExpirations = expiringWeblogs;
+            this.nextEntryExpirations = expiringEntries;
             
         } catch(Exception e) {
-            log.error(e);
+            log.error("ERROR processing invalidations", e);
         }
         
         log.debug("finished");



Mime
View raw message