public List parse(String url, int size) throws Exception { List entries = new ArrayList(); URL feedSource = new URL(url); SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = input.build(new XmlReader(feedSource)); int i = 0; for (Object f : feed.getEntries()) { if (i == size) { break; } entries.add(f); i++; } return entries; } }
private SyndFeed getFeed() { try { synchronized (this.feedMonitor) { Reader reader = this.feedUrl != null ? new XmlReader(this.feedUrl) : new XmlReader(this.feedResource.getInputStream()); SyndFeed feed = this.syndFeedInput.build(reader); if (logger.isDebugEnabled()) { logger.debug("Retrieved feed for [" + this + "]"); } if (feed == null) { if (logger.isDebugEnabled()) { logger.debug("No feeds updated for [" + this + "], returning null"); } } return feed; } } catch (Exception e) { throw new MessagingException("Failed to retrieve feed for '" + this + "'", e); } }
private SyndFeed retrieveFeed() throws IOException, FeedException { XmlReader feedReader = new XmlReader(new URL(feedURL)); SyndFeedInput input = new SyndFeedInput(); return input.build(feedReader); }
/** * Creates the podcastFeed from the url provided * @param url */ public Podcast(String url) { try{ URL theURL = new URL(url); XmlReader reader = null; reader = new XmlReader(theURL); podcastFeed = new SyndFeedInput().build(reader); } catch(IOException | FeedException e){ } }
public void subscribe(final String topic, final boolean sync, final long leaseSeconds, final String secret, final SubscriptionCallback callback) throws IllegalArgumentException, IOException, FeedException { final SyndFeedInput input = new SyndFeedInput(); final SyndFeed feed = input.build(new InputStreamReader(new URL(topic).openStream())); final String hubUrl = findHubUrl(feed); if (hubUrl == null) { throw new FeedException("No hub link"); } this.subscribe(hubUrl, topic, sync, leaseSeconds, secret, callback); }
SyndFeed feed = new SyndFeedInput().build( new InputSource(new CloseShieldInputStream(stream)));
public void subscribe(final String topic, final boolean sync, final long leaseSeconds, final String secret, final SubscriptionCallback callback) throws IllegalArgumentException, IOException, FeedException { final SyndFeedInput input = new SyndFeedInput(); final SyndFeed feed = input.build(new InputStreamReader(new URL(topic).openStream())); final String hubUrl = findHubUrl(feed); if (hubUrl == null) { throw new FeedException("No hub link"); } this.subscribe(hubUrl, topic, sync, leaseSeconds, secret, callback); }
public void callback(final String callbackPath, final InputStream feed) { final SyndFeedInput input = new SyndFeedInput(); try { this.callback(callbackPath, input.build(new InputStreamReader(feed))); } catch (final IllegalArgumentException ex) { LOG.error("Unable to parse feed", ex); throw new HttpStatusCodeException(500, "Unable to parse feed.", ex); } catch (final FeedException ex) { LOG.error("Unable to parse feed", ex); throw new HttpStatusCodeException(400, "Unable to parse feed.", ex); } }
public List parse(String url, int size) throws Exception { List entries = new ArrayList(); URL feedSource = new URL(url); SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = input.build(new XmlReader(feedSource)); int i = 0; for (Object f : feed.getEntries()) { if (i == size) { break; } entries.add(f); i++; } return entries; } }
private SyndFeed getFeed() { try { synchronized (this.feedMonitor) { Reader reader = this.feedUrl != null ? new XmlReader(this.feedUrl) : new XmlReader(this.feedResource.getInputStream()); SyndFeed feed = this.syndFeedInput.build(reader); if (logger.isDebugEnabled()) { logger.debug("Retrieved feed for [" + this + "]"); } if (feed == null) { if (logger.isDebugEnabled()) { logger.debug("No feeds updated for [" + this + "], returning null"); } } return feed; } } catch (Exception e) { throw new MessagingException("Failed to retrieve feed for '" + this + "'", e); } }
public void callback(final String callbackPath, final InputStream feed) { final SyndFeedInput input = new SyndFeedInput(); try { this.callback(callbackPath, input.build(new InputStreamReader(feed))); } catch (final IllegalArgumentException ex) { LOG.error("Unable to parse feed", ex); throw new HttpStatusCodeException(500, "Unable to parse feed.", ex); } catch (final FeedException ex) { LOG.error("Unable to parse feed", ex); throw new HttpStatusCodeException(400, "Unable to parse feed.", ex); } }
private SyndFeed readSyndFeedFromStream(InputStream inputStream, URLConnection connection) throws IOException, IllegalArgumentException, FeedException { BufferedInputStream is; if ("gzip".equalsIgnoreCase(connection.getContentEncoding())) { // handle gzip encoded content is = new BufferedInputStream(new GZIPInputStream(inputStream)); } else { is = new BufferedInputStream(inputStream); } XmlReader reader = null; if (connection.getHeaderField("Content-Type") != null) { reader = new XmlReader(is, connection.getHeaderField("Content-Type"), true); } else { reader = new XmlReader(is, true); } SyndFeedInput syndFeedInput = new SyndFeedInput(); syndFeedInput.setPreserveWireFeed(isPreserveWireFeed()); return syndFeedInput.build(reader); }
private SyndFeed readSyndFeedFromStream(final InputStream inputStream, final URLConnection connection) throws IOException, IllegalArgumentException, FeedException { BufferedInputStream is; if ("gzip".equalsIgnoreCase(connection.getContentEncoding())) { // handle gzip encoded content is = new BufferedInputStream(new GZIPInputStream(inputStream)); } else { is = new BufferedInputStream(inputStream); } final XmlReader reader; if (connection.getHeaderField("Content-Type") != null) { reader = new XmlReader(is, connection.getHeaderField("Content-Type"), true); } else { reader = new XmlReader(is, true); } final SyndFeedInput syndFeedInput = new SyndFeedInput(); syndFeedInput.setPreserveWireFeed(isPreserveWireFeed()); syndFeedInput.setAllowDoctypes(isAllowDoctypes()); return syndFeedInput.build(reader); }
/** * Gets the latest {@link PlatformIndependentMOTD} from the specified RSS-feed * * @param feedUrl The {@code URL} of the RSS-feed to get the {@link PlatformIndependentMOTD} from. * @return The latest {@link PlatformIndependentMOTD} from the specified RSS-feed or {@code null} if the feed contaisn no entry. * @throws IllegalArgumentException thrown if feed type could not be understood by any of the * underlying parsers. * @throws FeedException if the feed could not be parsed * @throws IOException thrown if there is a problem reading the stream of the URL. */ @Nullable public static PlatformIndependentMOTD getLatestMOTD(URL feedUrl) throws IllegalArgumentException, FeedException, IOException { SyndFeed feed = (new SyndFeedInput()).build(new XmlReader(feedUrl)); if (feed.getEntries().isEmpty()) return null; return new PlatformIndependentMOTD(feed.getImage(), feed.getTitle(), feed.getEntries().get(0)); }
public static List<RSS> getRSSFeeds(Language lg){ List<RSS> rss = new ArrayList<>(); try { SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = input.build(new XmlReader(new URL(Translator.getLabel(lg, "game.url") + Translator.getLabel(lg, "feed.url")))); for(SyndEntry entry : feed.getEntries()) { Matcher m = Pattern.compile("<img.+src=\"(.*\\.jpg)\".+>").matcher(entry.getDescription().getValue()); rss.add(new RSS(entry.getTitle(), entry.getLink(), (m.find()? m.group(1) : null), entry.getPublishedDate().getTime())); } } catch (FeedException e){ Reporter.report(e); LOG.error("getRSSFeeds", e); } catch(IOException e){ ExceptionManager.manageSilentlyIOException(e); } catch(Exception e){ ExceptionManager.manageSilentlyException(e); } Collections.sort(rss); return rss; }
/** * 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(final SyndFeed feed) throws FeedException { // TODO: the null parameter below will break delegating parsers and generators // final ModuleGenerators g = new ModuleGenerators(feed.getFeedType() + // ITEM_MODULE_GENERATORS_POSFIX_KEY, null); final SyndFeedOutput output = new SyndFeedOutput(); final Document document = output.outputJDom(feed); final SyndFeed copy = new SyndFeedInput().build(document); feed.copyFrom(copy); }
/** * 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(final SyndFeed feed) throws FeedException { // TODO: the null parameter below will break delegating parsers and generators // final ModuleGenerators g = new ModuleGenerators(feed.getFeedType() + // ITEM_MODULE_GENERATORS_POSFIX_KEY, null); final SyndFeedOutput output = new SyndFeedOutput(); final Document document = output.outputJDom(feed); final SyndFeed copy = new SyndFeedInput().build(document); feed.copyFrom(copy); }
private SyndFeed retrieveFeed(final String urlStr, final HttpMethod method) throws IOException, HttpException, FetcherException, FeedException { final Header contentEncodingHeader = method.getResponseHeader("Content-Encoding"); final InputStream stream; if (contentEncodingHeader != null && "gzip".equalsIgnoreCase(contentEncodingHeader.getValue())) { stream = new GZIPInputStream(method.getResponseBodyAsStream()); } else { stream = method.getResponseBodyAsStream(); } try { final Header contentTypeHeader = method.getResponseHeader("Content-Type"); final XmlReader reader; if (contentTypeHeader != null) { reader = new XmlReader(stream, contentTypeHeader.getValue(), true); } else { reader = new XmlReader(stream, true); } final SyndFeedInput syndFeedInput = new SyndFeedInput(); syndFeedInput.setPreserveWireFeed(isPreserveWireFeed()); syndFeedInput.setAllowDoctypes(isAllowDoctypes()); return syndFeedInput.build(reader); } finally { IO.close(stream); } }
private SyndFeed readFeedFromStream(InputStream inputStream, URLConnection connection) throws IOException, FeedException { BufferedInputStream bufferedInputStream; if ("gzip".equalsIgnoreCase(connection.getContentEncoding())) { // handle gzip encoded content bufferedInputStream = new BufferedInputStream(new GZIPInputStream(inputStream)); } else { bufferedInputStream = new BufferedInputStream(inputStream); } XmlReader reader = null; if (connection.getHeaderField("Content-Type") != null) { reader = new XmlReader(bufferedInputStream, connection.getHeaderField("Content-Type"), true); } else { reader = new XmlReader(bufferedInputStream, true); } SyndFeedInput syndFeedInput = new SyndFeedInput(); syndFeedInput.setPreserveWireFeed(isPreserveWireFeed()); SyndFeed feed = syndFeedInput.build(reader); fireEvent(com.rometools.fetcher.FetcherEvent.EVENT_TYPE_FEED_RETRIEVED, connection, feed); return feed; }
SyndFeedInput input = new SyndFeedInput(); try { feed = input.build(new XmlReader(url)); } catch (Exception e) { throw new KlabException("Can't read GeoRSS feed from url" + url);