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();
}
}
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());
}
}
}
};
}
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);
}
}
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));
}
}
}
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;
}
Aggregations