log.debug("task started");
try {
WeblogManager wMgr = WebloggerFactory.getWeblogger().getWeblogManager();
IndexManager searchMgr = WebloggerFactory.getWeblogger().getIndexManager();
Date now = new Date();
log.debug("looking up scheduled entries older than "+now);
// get all published entries older than current time
List scheduledEntries = wMgr.getWeblogEntries(
null, // website
null, // user
null, // startDate
now, // endDate
null, // catName
null,WeblogEntry.SCHEDULED, // status
null, // text
null, // sortBy
null, // sortOrder
null, // locale
0, -1); // offset, length
log.debug("promoting "+scheduledEntries.size()+" entries to PUBLISHED state");
WeblogEntry entry = null;
Iterator it = scheduledEntries.iterator();
while(it.hasNext()) {
entry = (WeblogEntry) it.next();
// update status to PUBLISHED and save
entry.setStatus(WeblogEntry.PUBLISHED);
wMgr.saveWeblogEntry(entry);
}
// commit the changes
WebloggerFactory.getWeblogger().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 = (WeblogEntry) it.next();
// trigger a cache invalidation
CacheManager.invalidate(entry);
// trigger search index on entry
searchMgr.addEntryReIndexOperation(entry);
}
} catch (WebloggerException e) {
log.error("Error getting scheduled entries", e);
} catch(Exception e) {