/** * Constructor that parses the given feed representation. * * @param feedRepresentation * The feed representation to parse. * @throws IOException */ public SyndFeedRepresentation(Representation feedRepresentation) throws IOException { super(null); InputSource source = new InputSource(feedRepresentation.getStream()); try { this.feed = new SyndFeedInput().build(source); } catch (IllegalArgumentException e) { IOException ioe = new IOException( "Couldn't read the feed representation. " + e.getMessage()); ioe.initCause(e); throw ioe; } catch (FeedException e) { IOException ioe = new IOException( "Couldn't read the feed representation. " + e.getMessage()); ioe.initCause(e); throw ioe; } setMediaType(getMediaType(this.feed.getFeedType())); }
@Override protected void validate(Document document) { try { SyndFeedInput input = new SyndFeedInput(); input.build(getDocument()); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (FeedException e) { if (e instanceof ParsingFeedException) { ParsingFeedException pfe = (ParsingFeedException) e; addError(Type.ERROR, pfe.getLineNumber(), pfe.getColumnNumber(), e.getMessage()); } else { addError(Type.ERROR, -1, -1, e.getMessage()); } } }
log.info("Failed to fetch the feed:" + te.getMessage()); } catch (FeedException fe) { log.info("Failed to parse the feed:" + fe.getMessage());
/** * {@inheritDoc} * * @see org.xwiki.validator.framework.AbstractXMLValidator#validate(org.w3c.dom.Document) */ @Override protected void validate(Document document) { try { SyndFeedInput input = new SyndFeedInput(); input.build(getDocument()); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (FeedException e) { if (e instanceof ParsingFeedException) { ParsingFeedException pfe = (ParsingFeedException) e; addError(Type.ERROR, pfe.getLineNumber(), pfe.getColumnNumber(), e.getMessage()); } else { addError(Type.ERROR, -1, -1, e.getMessage()); } } }
public void run ( ) { while ( isActive( ) ) { try { Thread.sleep( rate ); rss_input = new SyndFeedInput(); feed = rss_input.build(new XmlReader(url)); for (SyndEntry entry: (List<SyndEntry>) feed.getEntries()) { String title = entry.getTitle(); String link = entry.getLink(); String description= entry.getDescription().getValue(); String author = entry.getAuthor(); long publish_date = entry.getPublishedDate().getTime(); postStreamElement(publish_date,new Serializable[] {title,author,description,link}); } }catch (com.sun.syndication.io.FeedException e){ logger.error( e.getMessage( ) , e ); }catch ( InterruptedException e ) { logger.error( e.getMessage( ) , e ); }catch (IOException e) { logger.error( e.getMessage( ) , e ); } } }
LOG.error( "Feed exception while attempting to write out the final xml file. " + "for site: " + siteId + ". " + e.getMessage(), e); throw new PodcastException(e);
throw new IOException(fex.getMessage(), fex);
@Override @SuppressWarnings("unchecked") public T readInternal(Class<? extends T> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { WireFeedInput feedInput = new WireFeedInput(); MediaType contentType = inputMessage.getHeaders().getContentType(); Charset charset; if (contentType != null && contentType.getCharSet() != null) { charset = contentType.getCharSet(); } else { charset = DEFAULT_CHARSET; } try { Reader reader = new InputStreamReader(inputMessage.getBody(), charset); return (T) feedInput.build(reader); } catch (FeedException ex) { throw new HttpMessageNotReadableException("Could not read WireFeed: " + ex.getMessage(), ex); } }
@Override public void writeInternal(T wireFeed, HttpOutputMessage outputMessage,HttpInputMessage inputMessage) throws IOException, HttpMessageNotWritableException { String wireFeedEncoding = wireFeed.getEncoding(); if (!StringUtil.hasLength(wireFeedEncoding)) { wireFeedEncoding = DEFAULT_CHARSET.name(); } MediaType contentType = outputMessage.getHeaders().getContentType(); if (contentType != null) { Charset wireFeedCharset = Charset.forName(wireFeedEncoding); contentType = new MediaType(contentType.getType(), contentType.getSubtype(), wireFeedCharset); outputMessage.getHeaders().setContentType(contentType); } WireFeedOutput feedOutput = new WireFeedOutput(); try { Writer writer = new OutputStreamWriter(outputMessage.getBody(), wireFeedEncoding); feedOutput.output(wireFeed, writer); } catch (FeedException ex) { throw new HttpMessageNotWritableException("Could not write WiredFeed: " + ex.getMessage(), ex); } } }