Search in sources :

Example 81 with SyndFeed

use of com.sun.syndication.feed.synd.SyndFeed in project wildfly-camel by wildfly-extras.

the class SAPNetweaverIntegrationTest method testSAPNetweaverEndpoint.

@Test
public void testSAPNetweaverEndpoint() throws Exception {
    Assume.assumeTrue("[#1675] Enable SAP testing in Jenkins", SAP_USERNAME != null && SAP_PASSWORD != null);
    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:start").toF("sap-netweaver:%s?username=%s&password=%s", SAP_GATEWAY_URL, SAP_USERNAME, SAP_PASSWORD);
        }
    });
    camelctx.start();
    try {
        ProducerTemplate producer = camelctx.createProducerTemplate();
        ConsumerTemplate consumer = camelctx.createConsumerTemplate();
        // Flight data is constantly updated, so fetch a valid flight from the flight collection feed
        String sapRssFeedUri = String.format("rss:%s/%s?username=%s&password=%s", SAP_GATEWAY_URL.replace("https4", "https"), "FlightCollection", SAP_USERNAME, SAP_PASSWORD);
        SyndFeed feed = consumer.receiveBody(sapRssFeedUri, SyndFeed.class);
        Assert.assertNotNull(feed);
        Assert.assertTrue(feed.getEntries().size() > 0);
        SyndEntry entry = (SyndEntry) feed.getEntries().get(0);
        String sapCommand = entry.getTitle();
        String result = producer.requestBodyAndHeader("direct:start", null, NetWeaverConstants.COMMAND, sapCommand, String.class);
        Assert.assertFalse(result.isEmpty());
    } finally {
        camelctx.stop();
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) ConsumerTemplate(org.apache.camel.ConsumerTemplate) SyndFeed(com.sun.syndication.feed.synd.SyndFeed) RouteBuilder(org.apache.camel.builder.RouteBuilder) SyndEntry(com.sun.syndication.feed.synd.SyndEntry) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 82 with SyndFeed

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

the class Activator method createRemoteCallListener.

private IRemoteCallListener createRemoteCallListener() {
    return new IRemoteCallListener() {

        public void handleEvent(IRemoteCallEvent event) {
            if (event instanceof IRemoteCallCompleteEvent) {
                IRemoteCallCompleteEvent cce = (IRemoteCallCompleteEvent) event;
                if (!cce.hadException()) {
                    System.out.println("Remote call completed successfully!");
                    SyndFeed feed = (SyndFeed) cce.getResponse();
                    printFeedContent(feed);
                } else {
                    System.out.println("Remote call completed with exception: " + cce.getException());
                }
            }
        }
    };
}
Also used : SyndFeed(com.sun.syndication.feed.synd.SyndFeed) IRemoteCallEvent(org.eclipse.ecf.remoteservice.events.IRemoteCallEvent) IRemoteCallListener(org.eclipse.ecf.remoteservice.IRemoteCallListener) IRemoteCallCompleteEvent(org.eclipse.ecf.remoteservice.events.IRemoteCallCompleteEvent)

Example 83 with SyndFeed

use of com.sun.syndication.feed.synd.SyndFeed in project jbpm-work-items by kiegroup.

the class RSSWorkItemHandler method executeWorkItem.

public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
    try {
        List<String> urls = new ArrayList<String>();
        String urlsList = (String) workItem.getParameter("URL");
        for (String s : urlsList.split(";")) {
            if (s != null && !"".equals(s)) {
                urls.add(s);
            }
        }
        for (String url : urls) {
            URL feedSource = new URL(url);
            if (input == null) {
                input = new SyndFeedInput();
            }
            SyndFeed feed = input.build(new XmlReader(feedSource));
            feeds.add(feed);
        }
        manager.completeWorkItem(workItem.getId(), null);
    } catch (Exception ex) {
        handleException(ex);
    }
}
Also used : SyndFeed(com.sun.syndication.feed.synd.SyndFeed) SyndFeedInput(com.sun.syndication.io.SyndFeedInput) ArrayList(java.util.ArrayList) XmlReader(com.sun.syndication.io.XmlReader) URL(java.net.URL)

Example 84 with SyndFeed

use of com.sun.syndication.feed.synd.SyndFeed in project quickstarts by jboss-switchyard.

the class CamelRSSPollTest method shouldRetrieveGreetings.

@Test
public void shouldRetrieveGreetings() throws Exception {
    _testKit.removeService("PrintService");
    final MockHandler printService = _testKit.registerInOnlyService("PrintService");
    Thread.sleep(10001);
    final LinkedBlockingQueue<Exchange> receivedMessages = printService.getMessages();
    for (Exchange e : receivedMessages) {
        SyndFeed feed = (SyndFeed) e.getMessage().getContent();
        @SuppressWarnings("unchecked") List<SyndEntry> entries = feed.getEntries();
        Assert.assertEquals(feed.getEntries().size(), 1);
        Iterator<SyndEntry> itEntries = entries.iterator();
        while (itEntries.hasNext()) {
            SyndEntry entry = (SyndEntry) itEntries.next();
            Assert.assertTrue(entry.getTitle().equals(SONG_TITLE));
            Assert.assertTrue(entry.getLink().equals(SONG_URL));
            Assert.assertTrue(entry.getDescription().getValue().equals(SONG_DESCRIPTION));
        }
    }
}
Also used : Exchange(org.switchyard.Exchange) SyndFeed(com.sun.syndication.feed.synd.SyndFeed) SyndEntry(com.sun.syndication.feed.synd.SyndEntry) MockHandler(org.switchyard.test.MockHandler) Test(org.junit.Test)

Example 85 with SyndFeed

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

the class SyndicationUtils method readFeed.

/**
 * Reads a Gitblit RSS feed.
 *
 * @param url
 *            the url of the Gitblit server
 * @param parameters
 *            the list of RSS parameters
 * @param repository
 *            the repository name
 * @param username
 * @param password
 * @return a list of SyndicationModel entries
 * @throws {@link IOException}
 */
private static List<FeedEntryModel> readFeed(String url, List<String> parameters, String repository, String branch, String username, char[] password) throws IOException {
    // build url
    StringBuilder sb = new StringBuilder();
    sb.append(MessageFormat.format("{0}" + Constants.SYNDICATION_PATH + "{1}", url, repository));
    if (parameters.size() > 0) {
        boolean first = true;
        for (String parameter : parameters) {
            if (first) {
                sb.append('?');
                first = false;
            } else {
                sb.append('&');
            }
            sb.append(parameter);
        }
    }
    String feedUrl = sb.toString();
    URLConnection conn = ConnectionUtils.openReadConnection(feedUrl, username, password);
    InputStream is = conn.getInputStream();
    SyndFeedInput input = new SyndFeedInput();
    SyndFeed feed = null;
    try {
        feed = input.build(new XmlReader(is));
    } catch (FeedException f) {
        throw new GitBlitException(f);
    }
    is.close();
    List<FeedEntryModel> entries = new ArrayList<FeedEntryModel>();
    for (Object o : feed.getEntries()) {
        SyndEntryImpl entry = (SyndEntryImpl) o;
        FeedEntryModel model = new FeedEntryModel();
        model.repository = repository;
        model.branch = branch;
        model.title = entry.getTitle();
        model.author = entry.getAuthor();
        model.published = entry.getPublishedDate();
        model.link = entry.getLink();
        model.content = entry.getDescription().getValue();
        model.contentType = entry.getDescription().getType();
        if (entry.getCategories() != null && entry.getCategories().size() > 0) {
            List<String> tags = new ArrayList<String>();
            for (Object p : entry.getCategories()) {
                SyndCategory cat = (SyndCategory) p;
                tags.add(cat.getName());
            }
            model.tags = tags;
        }
        entries.add(model);
    }
    return entries;
}
Also used : SyndCategory(com.sun.syndication.feed.synd.SyndCategory) FeedEntryModel(com.gitblit.models.FeedEntryModel) InputStream(java.io.InputStream) FeedException(com.sun.syndication.io.FeedException) ArrayList(java.util.ArrayList) GitBlitException(com.gitblit.GitBlitException) XmlReader(com.sun.syndication.io.XmlReader) URLConnection(java.net.URLConnection) SyndFeed(com.sun.syndication.feed.synd.SyndFeed) SyndFeedInput(com.sun.syndication.io.SyndFeedInput) SyndEntryImpl(com.sun.syndication.feed.synd.SyndEntryImpl)

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