You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ag...@apache.org on 2007/01/11 20:33:13 UTC

svn commit: r495347 - in /incubator/roller/trunk: metadata/database/ src/org/apache/roller/business/search/operations/ src/org/apache/roller/planet/business/hibernate/ src/org/apache/roller/pojos/ src/org/apache/roller/ui/authoring/struts/actions/ src/...

Author: agilliland
Date: Thu Jan 11 11:33:11 2007
New Revision: 495347

URL: http://svn.apache.org/viewvc?view=rev&rev=495347
Log:
Improving handling of future scheduled entry postings as noted in Jira issue ROL-1284.

This adds a new SCHEDULED status option for weblog entries and assigns this status to entries published with a pubTime in the future.  This allows for easier tracking of scheduled entries, rather than always just doing date comparisons, and will improve query performance now that entry queries don't always need an end
date.


Modified:
    incubator/roller/trunk/metadata/database/310-to-320-migration.vm
    incubator/roller/trunk/src/org/apache/roller/business/search/operations/RebuildWebsiteIndexOperation.java
    incubator/roller/trunk/src/org/apache/roller/planet/business/hibernate/HibernateRollerPlanetManagerImpl.java
    incubator/roller/trunk/src/org/apache/roller/pojos/WeblogEntryData.java
    incubator/roller/trunk/src/org/apache/roller/pojos/WebsiteData.java
    incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryFormAction.java
    incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryPageModel.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/FeedModel.java
    incubator/roller/trunk/src/org/apache/roller/ui/rendering/pagers/WeblogEntriesListPager.java
    incubator/roller/trunk/src/org/apache/roller/util/cache/FuturePostingsInvalidationJob.java
    incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties
    incubator/roller/trunk/web/WEB-INF/jsps/authoring/WeblogEditSidebar.jsp
    incubator/roller/trunk/web/WEB-INF/jsps/authoring/WeblogEntryManagementSidebar.jsp

Modified: incubator/roller/trunk/metadata/database/310-to-320-migration.vm
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/metadata/database/310-to-320-migration.vm?view=diff&rev=495347&r1=495346&r2=495347
==============================================================================
--- incubator/roller/trunk/metadata/database/310-to-320-migration.vm (original)
+++ incubator/roller/trunk/metadata/database/310-to-320-migration.vm Thu Jan 11 11:33:11 2007
@@ -30,6 +30,9 @@
 update roller_comment set status = 'SPAM' where spam=1;
 update roller_comment set status = 'DISAPPROVED' where approved=0 and spam=0 and pending=0;
 
+-- add new status option 'SCHEDULED' for future published entries
+update weblogentry set status = 'SCHEDULED' where pubtime > now();
+
 -- some various indexes to improve performance
 create index rhc_dailyhits_idx on roller_hitcounts( dailyhits );
 create index we_combo1_idx on weblogentry(status, pubtime, websiteid);

Modified: incubator/roller/trunk/src/org/apache/roller/business/search/operations/RebuildWebsiteIndexOperation.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/business/search/operations/RebuildWebsiteIndexOperation.java?view=diff&rev=495347&r1=495346&r2=495347
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/business/search/operations/RebuildWebsiteIndexOperation.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/business/search/operations/RebuildWebsiteIndexOperation.java Thu Jan 11 11:33:11 2007
@@ -106,7 +106,7 @@
                         website,                   // website            
                         null,
                         null,                      // startDate
-                        new Date(),                // endDate (don't index 'future' entries)
+                        null,                      // endDate
                         null,                      // catName
                         null,
                         WeblogEntryData.PUBLISHED, // status

Modified: incubator/roller/trunk/src/org/apache/roller/planet/business/hibernate/HibernateRollerPlanetManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/planet/business/hibernate/HibernateRollerPlanetManagerImpl.java?view=diff&rev=495347&r1=495346&r2=495347
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/planet/business/hibernate/HibernateRollerPlanetManagerImpl.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/planet/business/hibernate/HibernateRollerPlanetManagerImpl.java Thu Jan 11 11:33:11 2007
@@ -115,7 +115,7 @@
                             website,
                             null,
                             null,                        // startDate
-                            new Date(),                  // endDate
+                            null,                        // endDate
                             null,                        // catName
                             null,                        // tags
                             WeblogEntryData.PUBLISHED,   // status

Modified: incubator/roller/trunk/src/org/apache/roller/pojos/WeblogEntryData.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/pojos/WeblogEntryData.java?view=diff&rev=495347&r1=495346&r2=495347
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/pojos/WeblogEntryData.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/pojos/WeblogEntryData.java Thu Jan 11 11:33:11 2007
@@ -71,6 +71,7 @@
     public static final String DRAFT     = "DRAFT";
     public static final String PUBLISHED = "PUBLISHED";
     public static final String PENDING   = "PENDING";
+    public static final String SCHEDULED = "SCHEDULED";
     
     // Simple properies
     private String    id            = null;

Modified: incubator/roller/trunk/src/org/apache/roller/pojos/WebsiteData.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/pojos/WebsiteData.java?view=diff&rev=495347&r1=495346&r2=495347
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/pojos/WebsiteData.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/pojos/WebsiteData.java Thu Jan 11 11:33:11 2007
@@ -1222,7 +1222,7 @@
                     this, 
                     null,       // user
                     null,       // startDate
-                    new Date(), // endDate
+                    null,       // endDate
                     cat,        // cat or null
                     null, 
                     WeblogEntryData.PUBLISHED, 

Modified: incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryFormAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryFormAction.java?view=diff&rev=495347&r1=495346&r2=495347
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryFormAction.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryFormAction.java Thu Jan 11 11:33:11 2007
@@ -315,7 +315,15 @@
                 if(entry.getAnchor() == null || entry.getAnchor().trim().equals("")) {
                     entry.setAnchor(weblogMgr.createAnchor(entry));
                 }
-
+                
+                // if the entry was published to future, set status as SCHEDULED
+                // we only consider an entry future published if it is scheduled
+                // more than 1 minute into the future
+                if ("PUBLISHED".equals(entry.getStatus()) && 
+                        entry.getPubTime().after(new Date(System.currentTimeMillis() + 60000))) {
+                    entry.setStatus(WeblogEntryData.SCHEDULED);
+                }
+                
                 mLogger.debug("Saving entry");
                 weblogMgr.saveWeblogEntry(entry);
                 RollerFactory.getRoller().flush();

Modified: incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryPageModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryPageModel.java?view=diff&rev=495347&r1=495346&r2=495347
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryPageModel.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryPageModel.java Thu Jan 11 11:33:11 2007
@@ -147,6 +147,30 @@
                 null,
                 0, 20);   
     }
+    
+    /**
+     * Get recent weblog entries using request parameters to determine
+     * username, date, and category name parameters.
+     * @return List of WeblogEntryData objects.
+     * @throws RollerException
+     */
+    public List getRecentScheduledEntries() throws RollerException
+    {
+        RollerSession rollerSession = RollerSession.getRollerSession(getRequest());
+        return RollerFactory.getRoller().getWeblogManager()
+            .getWeblogEntries(
+                getWeblogEntry().getWebsite(), // userName
+                null,
+                null,              // startDate
+                null,              // endDate
+                null,              // catName
+                null,              // tags
+                WeblogEntryData.SCHEDULED, // status
+                null,              // sortby (null for pubTime)
+                null, 
+                null,
+                0, 20);   
+    }
 
     /**
      * Get recent weblog entries using request parameters to determine

Modified: incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/FeedModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/FeedModel.java?view=diff&rev=495347&r1=495346&r2=495347
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/FeedModel.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/FeedModel.java Thu Jan 11 11:33:11 2007
@@ -129,7 +129,7 @@
                     weblog,
                     null, 
                     null, 
-                    new Date(), 
+                    null, 
                     feedRequest.getWeblogCategoryName(), 
                     feedRequest.getTags(), 
                     WeblogEntryData.PUBLISHED, 

Modified: incubator/roller/trunk/src/org/apache/roller/ui/rendering/pagers/WeblogEntriesListPager.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/pagers/WeblogEntriesListPager.java?view=diff&rev=495347&r1=495346&r2=495347
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/pagers/WeblogEntriesListPager.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/pagers/WeblogEntriesListPager.java Thu Jan 11 11:33:11 2007
@@ -110,7 +110,7 @@
                         queryWeblog,
                         queryUser,
                         startDate,
-                        new Date(),
+                        null,
                         queryCat,
                         queryTags,
                         WeblogEntryData.PUBLISHED,

Modified: incubator/roller/trunk/src/org/apache/roller/util/cache/FuturePostingsInvalidationJob.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/util/cache/FuturePostingsInvalidationJob.java?view=diff&rev=495347&r1=495346&r2=495347
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/util/cache/FuturePostingsInvalidationJob.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/util/cache/FuturePostingsInvalidationJob.java Thu Jan 11 11:33:11 2007
@@ -18,53 +18,31 @@
 
 package org.apache.roller.util.cache;
 
-import java.util.Calendar;
 import java.util.Date;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.roller.RollerException;
 import org.apache.roller.business.runnable.Job;
 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;
 
 
 /**
- * Trigger cache invalidations for entries published into the future.
+ * Trigger publication for entries scheduled for future release.
  *
- * This job is meant to be run at timed intervals, it will not do any
- * good to run this job only a single time.
+ * This job is meant to be run at timed intervals, such as once per minute.
  *
- * We do things in a somewhat counterintuitive manner, but it makes things
- * easier on us from an operational point of view.  We start by looking up
- * all entries published between now and some time XX mins in the future.  We
- * then save that list and when XX mins has passed we invalidate the list and
- * query for entries published in the next XX mins.
- *
- * Basically we are building a short term list of future published entries
- * and expiring them once our wait period is over.  This prevents us from
- * having to somehow determine which entries published in the last XX mins
- * had previously been published into the future.
+ * This job queries for all entries with the WeblogEntryData.SCHEDULED status
+ * which are older than the current time and promotes their status to PUBLISHED.
  */
 public class FuturePostingsInvalidationJob implements Job {
     
     private static Log log = LogFactory.getLog(FuturePostingsInvalidationJob.class);
     
-    // inputs from the user
-    private Map inputs = null;
-    
-    // the set of entries we expire at the start of the next run
-    private Set nextExpirations = null;
-    
-    // how far into the future we will look ahead, in minutes
-    int peerTime = 5;
     
     public void execute() {
         
@@ -72,59 +50,42 @@
         
         try {
             WeblogManager wMgr = RollerFactory.getRoller().getWeblogManager();
-            UserManager uMgr = RollerFactory.getRoller().getUserManager();
+            IndexManager searchMgr = RollerFactory.getRoller().getIndexManager();
             
             Date now = new Date();
             
-            if(nextExpirations != null) {
-                String websiteid = null;
-                WebsiteData weblog = null;
-                
-                Iterator weblogs = nextExpirations.iterator();
-                while(weblogs.hasNext()) {
-                    websiteid = (String) weblogs.next();
-                    
-                    try {
-                        // lookup the actual entry
-                        weblog = uMgr.getWebsite(websiteid);
-                        
-                        log.debug("expiring"+weblog.getHandle());
-                        
-                        // to expire weblog content we have to update the
-                        // last modified time of the weblog and save it
-                        weblog.setLastModified(now);
-                        uMgr.saveWebsite(weblog);
-                        
-                    } catch (RollerException ex) {
-                        log.warn("couldn't lookup entry "+websiteid);
-                    }
-                }
-                
-                // commit the changes
-                RollerFactory.getRoller().flush();
-            }
+            log.debug("looking up scheduled entries older than "+now);
             
-            // XX mins in the future
-            Calendar cal = Calendar.getInstance();
-            cal.setTime(now);
-            cal.add(Calendar.MINUTE, this.peerTime);
-            Date end = cal.getTime();
-            
-            log.debug("looking up entries between "+now+" and "+end);
-            
-            // get all published entries between start and end date
-            List expiringEntries = wMgr.getWeblogEntries(null, null, now, end, null, 
-                    null, null, WeblogEntryData.PUBLISHED, null, null, 0, -1);
-            
-            // we only really want the weblog ids
-            Set expiringWeblogs = new HashSet();
-            Iterator it = expiringEntries.iterator();
+            // get all published entries older than current time
+            List scheduledEntries = wMgr.getWeblogEntries(null, null, null, now, null, 
+                    null, null, WeblogEntryData.SCHEDULED, null, null, 0, -1);
+            
+            WeblogEntryData entry = null;
+            Iterator it = scheduledEntries.iterator();
             while(it.hasNext()) {
-                expiringWeblogs.add(((WeblogEntryData) it.next()).getWebsite().getId());
+                entry = (WeblogEntryData) it.next();
+                
+                // update status to PUBLISHED and save
+                entry.setStatus(WeblogEntryData.PUBLISHED);
+                wMgr.saveWeblogEntry(entry);
             }
             
-            this.nextExpirations = expiringWeblogs;
+            // commit the changes
+            RollerFactory.getRoller().flush();
             
+            // take a second pass to trigger reindexing and cache invalidations
+            // this is because we need the updated entries flushed first
+            it = scheduledEntries.iterator();
+            while(it.hasNext()) {
+                entry = (WeblogEntryData) it.next();
+                
+                // trigger a cache invalidation
+                CacheManager.invalidate(entry);
+                
+                // trigger search index on entry
+                searchMgr.addEntryReIndexOperation(entry);
+            }
+
         } catch(Exception e) {
             log.error(e);
         }
@@ -139,15 +100,7 @@
     
     
     public void input(Map input) {
-        this.inputs = input;
-        
-        // extract peer time if possible
-        Integer pTime = (Integer) this.inputs.get("peerTime");
-        if(pTime != null) {
-            this.peerTime = pTime.intValue();
-        }
-        
-        log.info("Peeking "+this.peerTime+" minutes into the future each pass");
+        // no-op
     }
     
 }

Modified: incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties?view=diff&rev=495347&r1=495346&r2=495347
==============================================================================
--- incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties (original)
+++ incubator/roller/trunk/web/WEB-INF/classes/ApplicationResources.properties Thu Jan 11 11:33:11 2007
@@ -1463,6 +1463,7 @@
 weblogEdit.recentEntries=Recent Weblog Entries
 weblogEdit.remove=Remove
 weblogEdit.save=Save as Draft
+weblogEdit.scheduledEntries=Scheduled Entries
 weblogEdit.seconds=Seconds
 weblogEdit.status=Status
 weblogEdit.spellMode=Spellcheck
@@ -1599,6 +1600,7 @@
 weblogEntryQuery.label.draftOnly=Draft Only
 weblogEntryQuery.label.publishedOnly=Published Only
 weblogEntryQuery.label.pendingOnly=Pending Only
+weblogEntryQuery.label.scheduledOnly=Scheduled Only
 
 weblogEntryQuery.weblogEntries=Weblog Entries
 weblogEntryQuery.edit=Edit

Modified: incubator/roller/trunk/web/WEB-INF/jsps/authoring/WeblogEditSidebar.jsp
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/web/WEB-INF/jsps/authoring/WeblogEditSidebar.jsp?view=diff&rev=495347&r1=495346&r2=495347
==============================================================================
--- incubator/roller/trunk/web/WEB-INF/jsps/authoring/WeblogEditSidebar.jsp (original)
+++ incubator/roller/trunk/web/WEB-INF/jsps/authoring/WeblogEditSidebar.jsp Thu Jan 11 11:33:11 2007
@@ -118,6 +118,27 @@
     <br />
 </c:forEach>
 
+<hr size="1" noshade="noshade" />            
+<h3><fmt:message key="weblogEdit.scheduledEntries" /></h3>
+
+<c:if test="${empty model.recentScheduledEntries}">
+   <span><fmt:message key="application.none" /></span>
+</c:if>
+<c:forEach var="post" items="${model.recentScheduledEntries}">
+    <span class="entryEditSidebarLink"><roller:link page="/roller-ui/authoring/weblog.do">
+       <roller:linkparam
+           id="<%= RequestConstants.WEBLOGENTRY_ID %>"
+           name="post" property="id" />
+           <roller:linkparam id="method" value="edit" />
+           <img src='<c:url value="/images/table_edit.png"/>' 
+                align="absmiddle" border="0" alt="icon" title="Edit" />
+           <str:truncateNicely lower="50">
+              <c:out value="${post.title}" />
+           </str:truncateNicely>
+    </roller:link></span>
+    <br />
+</c:forEach>
+
 <br />
 <br />
 </div>

Modified: incubator/roller/trunk/web/WEB-INF/jsps/authoring/WeblogEntryManagementSidebar.jsp
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/web/WEB-INF/jsps/authoring/WeblogEntryManagementSidebar.jsp?view=diff&rev=495347&r1=495346&r2=495347
==============================================================================
--- incubator/roller/trunk/web/WEB-INF/jsps/authoring/WeblogEntryManagementSidebar.jsp (original)
+++ incubator/roller/trunk/web/WEB-INF/jsps/authoring/WeblogEntryManagementSidebar.jsp Thu Jan 11 11:33:11 2007
@@ -109,6 +109,9 @@
         <br />
         <html:radio property="status" value="PENDING" >
             <fmt:message key="weblogEntryQuery.label.pendingOnly" /></html:radio>
+        <br />
+        <html:radio property="status" value="SCHEDULED" >
+            <fmt:message key="weblogEntryQuery.label.scheduledOnly" /></html:radio>
         </div>
     </div>