Search in sources :

Example 1 with SyndFeedInput

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());
        }
    }
}
Also used : SyndFeed(com.sun.syndication.feed.synd.SyndFeed) InputSource(org.xml.sax.InputSource) ByteArrayInputStream(java.io.ByteArrayInputStream) SyndFeedInput(com.sun.syndication.io.SyndFeedInput) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) SyndEntry(com.sun.syndication.feed.synd.SyndEntry) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 2 with SyndFeedInput

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));
}
Also used : SyndFeedInput(com.sun.syndication.io.SyndFeedInput) XmlReader(com.sun.syndication.io.XmlReader) File(java.io.File)

Example 3 with SyndFeedInput

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));
}
Also used : SyndFeedInput(com.sun.syndication.io.SyndFeedInput) XmlReader(com.sun.syndication.io.XmlReader) URL(java.net.URL)

Example 4 with SyndFeedInput

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;
}
Also used : SyndEntry(com.sun.syndication.feed.synd.SyndEntry) Dataset(org.eol.globi.service.Dataset) FeedException(com.sun.syndication.io.FeedException) ArrayList(java.util.ArrayList) XmlReader(com.sun.syndication.io.XmlReader) IOException(java.io.IOException) URL(java.net.URL) SyndFeed(com.sun.syndication.feed.synd.SyndFeed) SyndFeedInput(com.sun.syndication.io.SyndFeedInput) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with SyndFeedInput

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());
    }
}
Also used : SyndFeed(com.sun.syndication.feed.synd.SyndFeed) InputStreamReader(java.io.InputStreamReader) SyndFeedInput(com.sun.syndication.io.SyndFeedInput) SyndEntry(com.sun.syndication.feed.synd.SyndEntry) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IOException(java.io.IOException)

Aggregations

SyndFeedInput (com.sun.syndication.io.SyndFeedInput)18 XmlReader (com.sun.syndication.io.XmlReader)13 SyndFeed (com.sun.syndication.feed.synd.SyndFeed)9 URL (java.net.URL)7 SyndEntry (com.sun.syndication.feed.synd.SyndEntry)6 ArrayList (java.util.ArrayList)5 InputStream (java.io.InputStream)4 URLConnection (java.net.URLConnection)4 FeedException (com.sun.syndication.io.FeedException)3 IOException (java.io.IOException)3 SyndCategory (com.sun.syndication.feed.synd.SyndCategory)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 File (java.io.File)2 List (java.util.List)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 InputSource (org.xml.sax.InputSource)2 GitBlitException (com.gitblit.GitBlitException)1 FeedEntryModel (com.gitblit.models.FeedEntryModel)1 SyndEnclosure (com.sun.syndication.feed.synd.SyndEnclosure)1