use of com.rometools.rome.feed.synd.SyndEntry in project opencast by opencast.
the class RomeRssFeed method init.
/**
* Converts the replay feed to a rome feed, that can then be written to the reponse.
*
* @param originalFeed
* the original feed
* @param feedInfo
* the feed info
*/
private void init(Feed originalFeed, FeedInfo feedInfo) {
if (originalFeed == null)
throw new IllegalArgumentException("Feed is null");
// Create SyndFeed
setEncoding(originalFeed.getEncoding());
setFeedType(feedInfo.toROMEVersion());
// Convert fields
setModules(toRomeModules(originalFeed.getModules()));
setAuthors(toRomePersons(originalFeed.getAuthors()));
setCategories(toRomeCategories(originalFeed.getCategories()));
setContributors(toRomePersons(originalFeed.getContributors()));
setDescriptionEx(toRomeContent(originalFeed.getDescription()));
setImage(toRomeImage(originalFeed.getImage()));
setLanguage(originalFeed.getLanguage());
setLinks(toRomeLinks(originalFeed.getLinks()));
setPublishedDate(originalFeed.getPublishedDate());
setTitleEx(toRomeContent(originalFeed.getTitle()));
setCopyright(originalFeed.getCopyright());
setUri(originalFeed.getUri());
setLink(originalFeed.getLink());
// Add SyndFeedEntries
if (originalFeed.getEntries() != null) {
List<SyndEntry> romeEntries = new ArrayList<SyndEntry>();
for (FeedEntry entry : originalFeed.getEntries()) {
SyndEntryImpl e = new SyndEntryImpl();
e.setModules(toRomeModules(entry.getModules()));
e.setAuthors(toRomePersons(entry.getAuthors()));
e.setCategories(toRomeCategories(entry.getCategories()));
e.setContents(toRomeContents(entry.getContents()));
e.setContributors(toRomePersons(entry.getContributors()));
e.setDescription(toRomeContent(entry.getDescription()));
e.setEnclosures(toRomeEnclosures(entry.getEnclosures()));
e.setPublishedDate(entry.getPublishedDate());
e.setTitleEx(toRomeContent(entry.getTitle()));
e.setUpdatedDate(entry.getUpdatedDate());
e.setUri(entry.getUri());
List<SyndLink> links = toRomeLinks(entry.getLinks());
e.setLinks(links);
// todo this strategy seems to work but is unproven
if (links.size() > 0)
e.setLink(links.get(0).getHref());
romeEntries.add(e);
}
setEntries(romeEntries);
}
}
use of com.rometools.rome.feed.synd.SyndEntry in project spring-integration by spring-projects.
the class FeedEntryMessageSource method populateEntryList.
private void populateEntryList() {
SyndFeed syndFeed = this.getFeed();
if (syndFeed != null) {
List<SyndEntry> retrievedEntries = syndFeed.getEntries();
if (!CollectionUtils.isEmpty(retrievedEntries)) {
boolean withinNewEntries = false;
Collections.sort(retrievedEntries, this.syndEntryComparator);
for (SyndEntry entry : retrievedEntries) {
Date entryDate = getLastModifiedDate(entry);
if ((entryDate != null && entryDate.getTime() > this.lastTime) || (entryDate == null && withinNewEntries)) {
this.entries.add(entry);
withinNewEntries = true;
}
}
}
}
}
use of com.rometools.rome.feed.synd.SyndEntry in project spring-integration by spring-projects.
the class FeedEntryMessageSource method receive.
@Override
public Message<SyndEntry> receive() {
Assert.isTrue(this.initialized, "'FeedEntryReaderMessageSource' must be initialized before it can produce Messages.");
SyndEntry entry = doReceive();
if (entry == null) {
return null;
}
return this.getMessageBuilderFactory().withPayload(entry).build();
}
use of com.rometools.rome.feed.synd.SyndEntry in project spring-integration by spring-projects.
the class FeedEntryMessageSource method doReceive.
private SyndEntry doReceive() {
SyndEntry nextEntry = null;
synchronized (this.monitor) {
nextEntry = getNextEntry();
if (nextEntry == null) {
// read feed and try again
this.populateEntryList();
nextEntry = getNextEntry();
}
}
return nextEntry;
}
use of com.rometools.rome.feed.synd.SyndEntry in project spring-integration by spring-projects.
the class FeedEntryMessageSource method getNextEntry.
private SyndEntry getNextEntry() {
SyndEntry next = this.entries.poll();
if (next == null) {
return null;
}
Date lastModifiedDate = FeedEntryMessageSource.getLastModifiedDate(next);
if (lastModifiedDate != null) {
this.lastTime = lastModifiedDate.getTime();
} else {
// NOSONAR - single poller thread
this.lastTime += 1;
}
this.metadataStore.put(this.metadataKey, this.lastTime + "");
return next;
}
Aggregations