use of com.sun.syndication.io.SyndFeedInput in project jersey by jersey.
the class FeedEntriesAtomBodyWriterTest method testWriteTo.
@Test
public void testWriteTo() throws Exception {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
testedClass.writeTo(feedEntries(), null, null, null, null, null, outputStream);
SyndFeedInput input = new SyndFeedInput();
InputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
SyndFeed feed = input.build(new InputSource(inputStream));
feed.setFeedType("atom_1.0");
feed.setTitle("Combined Feed");
feed.setDescription("Combined Feed created by a feed-combiner application");
assertEquals("atom_1.0", feed.getFeedType());
assertEquals("Combined Feed", feed.getTitle());
assertEquals("Combined Feed created by a feed-combiner application", feed.getDescription());
@SuppressWarnings("unchecked") List<SyndEntry> entries = feed.getEntries();
assertEquals(2, entries.size());
for (SyndEntry entry : entries) {
if (TITLES[0].equals(entry.getTitle())) {
assertEquals(entry.getLink(), LINKS[0]);
assertEquals(entry.getTitle(), TITLES[0]);
assertEquals(entry.getDescription().getValue(), DESCS[0]);
assertEquals(entry.getPublishedDate().toString(), DATE.toString());
} else {
assertEquals(entry.getLink(), LINKS[1]);
assertEquals(entry.getTitle(), TITLES[1]);
assertEquals(entry.getDescription().getValue(), DESCS[1]);
assertEquals(entry.getPublishedDate().toString(), DATE.toString());
}
}
}
use of com.sun.syndication.io.SyndFeedInput in project cubrid-manager by CUBRID.
the class NoticeDashboardEntity method readFeedFromLocalCache.
@SuppressWarnings("unused")
private void readFeedFromLocalCache() throws IllegalArgumentException, FeedException, IOException {
// TODO
String file = "";
SyndFeedInput input = new SyndFeedInput();
File feedUrl = new File(file);
rssData = input.build(new XmlReader(feedUrl));
}
use of com.sun.syndication.io.SyndFeedInput in project tutorials by eugenp.
the class RSSRomeExample method readFeed.
private static SyndFeed readFeed() throws IOException, FeedException {
URL feedSource = new URL("http://rssblog.whatisrss.com/feed/");
SyndFeedInput input = new SyndFeedInput();
return input.build(new XmlReader(feedSource));
}
use of com.sun.syndication.io.SyndFeedInput in project eol-globi-data by jhpoelen.
the class StudyImporterForArthopodEasyCapture method getStudyImportersForRSSFeed.
public static List<StudyImporter> getStudyImportersForRSSFeed(Dataset datasetOrig, ParserFactory parserFactory, NodeFactory nodeFactory) throws StudyImporterException {
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed;
String rss = getRss(datasetOrig);
try {
feed = input.build(new XmlReader(new URL(rss)));
} catch (FeedException | IOException e) {
throw new StudyImporterException("failed to read rss feed [" + rss + "]", e);
}
List<StudyImporter> importers = new ArrayList<StudyImporter>();
final List entries = feed.getEntries();
for (Object entry : entries) {
if (entry instanceof SyndEntry) {
SyndEntry syndEntry = (SyndEntry) entry;
Dataset dataset = embeddedDatasetFor(datasetOrig, StringUtils.trim(syndEntry.getDescription().getValue()), URI.create(StringUtils.trim(syndEntry.getLink())));
final StudyImporterForSeltmann studyImporter = new StudyImporterForSeltmann(parserFactory, nodeFactory);
studyImporter.setDataset(dataset);
importers.add(studyImporter);
}
}
return importers;
}
use of com.sun.syndication.io.SyndFeedInput in project apex-malhar by apache.
the class RomeSyndicationOperator method run.
/**
* Thread processing of the syndication feeds
*/
@Override
public void run() {
try {
while (true) {
InputStreamReader isr = null;
try {
isr = new InputStreamReader(getFeedInputStream());
SyndFeedInput feedInput = new SyndFeedInput();
SyndFeed feed = feedInput.build(isr);
List entries = feed.getEntries();
List<RomeFeedEntry> nfeedItems = new ArrayList<RomeFeedEntry>();
boolean oldEntries = false;
for (int i = 0; i < entries.size(); ++i) {
SyndEntry syndEntry = (SyndEntry) entries.get(i);
RomeFeedEntry romeFeedEntry = getSerializableEntry(syndEntry);
if (!oldEntries) {
if (!feedItems.contains(romeFeedEntry)) {
outputPort.emit(romeFeedEntry);
} else if (orderedUpdate) {
oldEntries = true;
}
}
nfeedItems.add(romeFeedEntry);
}
feedItems = nfeedItems;
} catch (Exception e) {
logger.error(e.getMessage());
} finally {
if (isr != null) {
try {
isr.close();
} catch (Exception ce) {
logger.error(ce.getMessage());
}
}
}
Thread.sleep(interval);
}
} catch (InterruptedException ie) {
logger.error("Interrupted: " + ie.getMessage());
}
}
Aggregations