ClientConnection connection = new ClientConnection(url); XmlReader xmlreader = new XmlReader(connection.getInputStream()); feed = input.build(xmlreader); } catch (Exception e) { e.printStackTrace();
public void run() { try { feed = new SyndFeedInput().build(new InputStreamReader(new ByteArrayInputStream(feedContents.getBytes()))); } catch (FeedException e) { log.warn("Cannot parse remote feed contents from:\n" + feedContents, e); } } }
HttpClient httpClient = new DefaultHttpClient(); HttpGet pageGet = new HttpGet(feedUrl.toURI()); HttpResponse response = httpClient.execute(pageGet); SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = input.build(new XmlReader(response.getEntity().getContent()));
try { SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = input.build(new XmlReader(file)); } catch(Exception e) { Log.e("", "ROME parse error: " + e.toString()); } catch(Error e2) { Log.e("", "ROME parse error2: " + e2.toString()); }
// create a Document from inputstream is DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(is); // fetch the feed SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = input.build(doc);
HttpURLConnection connection = (HttpURLConnection)url.openConnection(); InputStream is = connection.getInputStream(); InputSource source = new InputSource(is); SyndFeedInput input = new SyndFeedInput(); feed = input.build(source);
public static SyndFeed createFeed(String feedUri, ClassLoader classLoader) throws Exception { ClassLoader tccl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(classLoader); InputStream in = new URL(feedUri).openStream(); SyndFeedInput input = new SyndFeedInput(); return input.build(new XmlReader(in)); } finally { Thread.currentThread().setContextClassLoader(tccl); } }
public boolean romeLibraryExample(String address) { boolean ok = false; try{ URL url = new URL(address); HttpURLConnection httpcon = (HttpURLConnection)url.openConnection(); SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = input.build(new XmlReader(url)); ok = true; } catch (Exception exc){ exc.printStackTrace(); } return ok; }
public boolean tryFeed(String feedUrl) throws IOException,MalformedURLException { SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = null; try { feed = input.build(new XmlReader(new URL(feedUrl))); return true; } catch (FeedException e) { // Feed's invalid return false; } }
public static SyndFeed createFeed(String feedUri, ClassLoader classLoader) throws Exception { ClassLoader tccl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(classLoader); URL feedUrl = new URL(feedUri); HttpURLConnection httpcon = (HttpURLConnection)feedUrl.openConnection(); String encoding = new sun.misc.BASE64Encoder().encode("username:password".getBytes()); httpcon.setRequestProperty ("Authorization", "Basic " + encoding); SyndFeedInput input = new SyndFeedInput(); return input.build(new XmlReader(httpcon)); } finally { Thread.currentThread().setContextClassLoader(tccl); } }
URL feedUrl = new URL("http://the.url.to/the/feed"); //URL feedUrl = new URL("http://user:pass@the.url.to/the/feed"); HttpURLConnection connection = (HttpURLConnection) feedUrl.openConnection(); if (feedUrl.getUserInfo() != null) { String encoding = new sun.misc.BASE64Encoder().encode(feedUrl.getUserInfo().getBytes()); connection.setRequestProperty("Authorization", "Basic " + encoding); } SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = input.build(new XmlReader(connection));
SyndFeedInput fr = new SyndFeedInput(); SyndFeed sf = fr.build(new XmlReader(myInputStream)); List<?> entries = sf.getEntries();
URL feedUrl = new URL(feed) HttpURLConnection httpcon = (HttpURLConnection)feedUrl.openConnection(); String encoding = new sun.misc.BASE64Encoder().encode("username:password".getBytes()); httpcon.setRequestProperty ("Authorization", "Basic " + encoding); SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = input.build(new XmlReader(httpcon));
URL feedUrl = new URL("http://www.bloomberg.com/tvradio/podcast/cat_markets.xml"); SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = input.build(new XmlReader(feedUrl)); for (Iterator i = feed.getEntries().iterator(); i.hasNext();) { SyndEntry entry = (SyndEntry) i.next(); System.out.println("title |"+entry.getTitle()+" " -timeStamp "+entry.getPublishedDate()"\n") }
private static FeedResponse validate(String feedRequestUrl) { try { URL url = new URL(feedRequestUrl); SyndFeedInput input = new SyndFeedInput(); input.build(new XmlReader(url)); //ensure request is a valid rss feed return FeedResponse.valid(feedRequestUrl); } catch (Exception e) { logger.debug("could not parse feed request {}, reason {}", feedRequestUrl, e.getMessage()); return FeedResponse.invalid(e.getMessage(), feedRequestUrl); } }
public static RufusFeed generate(Source source) { SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = null; URL url = source.getUrl(); try { feed = input.build(new XmlReader(url)); } catch (Exception e) { logger.debug("Could not build SyndFeedInput for {}", url, e); } if (CollectionUtils.isEmpty(source.getTags())) { source.setTags(Collections.emptyList()); //never null! } return new RufusFeed(source, feed); }
public static SyndFeed getFeed( String feedId ) throws IllegalArgumentException, MalformedURLException, FeedException, IOException { SyndFeedInput input = new SyndFeedInput(); Response response = RequestFacade.sendMessage( FEED_URL_PART + feedId, Method.GET ); Assert.assertTrue( "Expected content", response.getEntity().isAvailable()); SyndFeed feed = input.build( new XmlReader( response.getEntity().getStream() ) ); // sort it by date sortSyndEntryOrderByPublishedDate( feed ); return feed; }
/** This method will take a SyndFeed object with a SimpleListExtension on it and populate the entries * with current SleEntry values for sorting and grouping. * <b>NB</b>: This basically does this by re-generating the XML for all the entries then re-parsing them * into the SLE data structures. It is a very heavy operation and should not be called frequently! */ public static void initializeForSorting( SyndFeed feed )throws FeedException { List syndEntries = feed.getEntries(); // TODO: the null parameter below will break delegating parsers and generators ModuleGenerators g = new ModuleGenerators( feed.getFeedType() + ITEM_MODULE_GENERATORS_POSFIX_KEY, null); SyndFeedOutput o = new SyndFeedOutput(); Document d = o.outputJDom( feed ); SyndFeed feed2 = new SyndFeedInput().build( d ); feed.copyFrom( feed2 ); }
/** This method will take a SyndFeed object with a SimpleListExtension on it and populate the entries * with current SleEntry values for sorting and grouping. * <b>NB</b>: This basically does this by re-generating the XML for all the entries then re-parsing them * into the SLE data structures. It is a very heavy operation and should not be called frequently! */ public static void initializeForSorting( SyndFeed feed )throws FeedException { List syndEntries = feed.getEntries(); // TODO: the null parameter below will break delegating parsers and generators ModuleGenerators g = new ModuleGenerators( feed.getFeedType() + ITEM_MODULE_GENERATORS_POSFIX_KEY, null); SyndFeedOutput o = new SyndFeedOutput(); Document d = o.outputJDom( feed ); SyndFeed feed2 = new SyndFeedInput().build( d ); feed.copyFrom( feed2 ); }
@Test(expected = WorkItemHandlerRuntimeException.class) public void testAddFeedInvalidParams() throws Exception { when(input.build(any(XmlReader.class))).thenReturn(feed); TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); RSSWorkItemHandler handler = new RSSWorkItemHandler(); handler.setInput(input); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(0, manager.getResults().size()); } }