Search in sources :

Example 46 with SyndFeed

use of com.sun.syndication.feed.synd.SyndFeed in project play-cookbook by spinscale.

the class FeedTest method testThatAtomWorks.

@Test
public void testThatAtomWorks() throws Exception {
    Response response = GET("/feed/posts.atom");
    assertIsOk(response);
    assertContentType("application/atom+xml", response);
    assertCharset("utf-8", response);
    SyndFeed feed = getFeed(response);
    assertEquals("atom_0.3", feed.getFeedType());
}
Also used : Response(play.mvc.Http.Response) SyndFeed(com.sun.syndication.feed.synd.SyndFeed) FunctionalTest(play.test.FunctionalTest) Test(org.junit.Test)

Example 47 with SyndFeed

use of com.sun.syndication.feed.synd.SyndFeed in project play-cookbook by spinscale.

the class FeedTest method testThatRss20Works.

@Test
public void testThatRss20Works() throws Exception {
    Response response = GET("/feed/posts.rss2");
    assertIsOk(response);
    assertContentType("application/rss+xml", response);
    assertCharset("utf-8", response);
    SyndFeed feed = getFeed(response);
    assertEquals("rss_2.0", feed.getFeedType());
}
Also used : Response(play.mvc.Http.Response) SyndFeed(com.sun.syndication.feed.synd.SyndFeed) FunctionalTest(play.test.FunctionalTest) Test(org.junit.Test)

Example 48 with SyndFeed

use of com.sun.syndication.feed.synd.SyndFeed in project scoold by Erudika.

the class SearchController method getFeed.

private SyndFeed getFeed() throws IOException, FeedException {
    List<Post> questions = pc.findQuery(Utils.type(Question.class), "*");
    List<SyndEntry> entries = new ArrayList<SyndEntry>();
    String baseurl = ScooldServer.getServerURL();
    baseurl = baseurl.endsWith("/") ? baseurl : baseurl + "/";
    SyndFeed feed = new SyndFeedImpl();
    feed.setFeedType("atom_1.0");
    feed.setTitle(Config.APP_NAME + " - Recent questions");
    feed.setLink(baseurl);
    feed.setDescription("A summary of the most recent questions on " + Config.APP_NAME);
    for (Post post : questions) {
        SyndEntry entry;
        SyndContent description;
        String baselink = baseurl.concat("question/").concat(post.getId());
        entry = new SyndEntryImpl();
        entry.setTitle(post.getTitle());
        entry.setLink(baselink);
        entry.setPublishedDate(new Date(post.getTimestamp()));
        entry.setAuthor(baseurl.concat("profile/").concat(post.getCreatorid()));
        entry.setUri(baselink.concat("/").concat(Utils.stripAndTrim(post.getTitle()).replaceAll("\\p{Z}+", "-").toLowerCase()));
        description = new SyndContentImpl();
        description.setType("text/html");
        description.setValue(Utils.markdownToHtml(post.getBody()));
        entry.setDescription(description);
        entries.add(entry);
    }
    feed.setEntries(entries);
    return feed;
}
Also used : Post(com.erudika.scoold.core.Post) SyndEntry(com.sun.syndication.feed.synd.SyndEntry) SyndContentImpl(com.sun.syndication.feed.synd.SyndContentImpl) ArrayList(java.util.ArrayList) Date(java.util.Date) SyndFeed(com.sun.syndication.feed.synd.SyndFeed) SyndContent(com.sun.syndication.feed.synd.SyndContent) SyndEntryImpl(com.sun.syndication.feed.synd.SyndEntryImpl) Question(com.erudika.scoold.core.Question) SyndFeedImpl(com.sun.syndication.feed.synd.SyndFeedImpl)

Example 49 with SyndFeed

use of com.sun.syndication.feed.synd.SyndFeed 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)

Example 50 with SyndFeed

use of com.sun.syndication.feed.synd.SyndFeed in project jersey by jersey.

the class FeedDownloader method apply.

@Override
@SuppressWarnings("unchecked")
public List<SyndEntry> apply(URL url) {
    try (XmlReader xmlReader = new XmlReader(url)) {
        SyndFeedInput input = new SyndFeedInput();
        SyndFeed feed = input.build(xmlReader);
        return feed.getEntries();
    } catch (Exception e) {
        LOG.warn("An error during downloading and parsing a given feed: " + url, e);
    }
    return Collections.emptyList();
}
Also used : SyndFeed(com.sun.syndication.feed.synd.SyndFeed) SyndFeedInput(com.sun.syndication.io.SyndFeedInput) XmlReader(com.sun.syndication.io.XmlReader)

Aggregations

SyndFeed (com.sun.syndication.feed.synd.SyndFeed)89 ArrayList (java.util.ArrayList)28 SyndEntry (com.sun.syndication.feed.synd.SyndEntry)25 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)16 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)16 SyndEntryImpl (com.sun.syndication.feed.synd.SyndEntryImpl)16 Test (org.testng.annotations.Test)16 Test (org.junit.Test)11 SkipException (org.testng.SkipException)11 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)10 SyndFeedImpl (com.sun.syndication.feed.synd.SyndFeedImpl)10 URL (java.net.URL)10 FeedException (com.sun.syndication.io.FeedException)9 SyndFeedInput (com.sun.syndication.io.SyndFeedInput)9 IOException (java.io.IOException)9 Date (java.util.Date)9 HashMap (java.util.HashMap)8 ConsumerCert (rhsm.data.ConsumerCert)8 XmlReader (com.sun.syndication.io.XmlReader)7 SyndFeedOutput (com.sun.syndication.io.SyndFeedOutput)6