/* Return early on cancellation */
if (monitor.isCanceled() || Owl.isShuttingDown())
return;
/* Update state of added news if equivalent news already exists */
SafeRunner.run(new LoggingSafeRunnable() {
public void run() throws Exception { //See Bug 1216 (NPE in ModelSearchImpl.getCurrentSearcher)
updateStateOfUnsavedNewNews(newNewsAdded, monitor);
}
});
/* Return early on cancellation */
if (monitor.isCanceled() || Owl.isShuttingDown())
return;
/* Retention Policy */
final List<INews> deletedNews = RetentionStrategy.process(bookMark, feed);
for (INews news : deletedNews)
mergeResult.addUpdatedObject(news);
/* Return early on cancellation */
if (monitor.isCanceled() || Owl.isShuttingDown())
return;
/* Set ID to News and handle Description entity */
IDGenerator generator = Owl.getPersistenceService().getIDGenerator();
for (INews news : newNewsAdded) {
/* Return early on cancellation */
if (monitor.isCanceled() || Owl.isShuttingDown())
return;
long id;
if (generator instanceof DB4OIDGenerator)
id = ((DB4OIDGenerator) generator).getNext(false);
else
id = generator.getNext();
news.setId(id);
String description = ((News) news).getTransientDescription();
if (description != null) {
mergeResult.addUpdatedObject(new Description(news, description));
}
}
/* Return early on cancellation */
if (monitor.isCanceled() || Owl.isShuttingDown())
return;
/* Run News Filters */
final AtomicBoolean someNewsFiltered = new AtomicBoolean(false);
SafeRunner.run(new LoggingSafeRunnable() {
public void run() throws Exception {
newNewsAdded.removeAll(deletedNews);
boolean result = runNewsFilters(newNewsAdded, monitor);
someNewsFiltered.set(result);
}