@Override @SuppressWarnings("unchecked") protected T readInternal(Class<? extends T> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { WireFeedInput feedInput = new WireFeedInput(); MediaType contentType = inputMessage.getHeaders().getContentType(); Charset charset = (contentType != null && contentType.getCharset() != null ? contentType.getCharset() : 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, inputMessage); } }
@Override @SuppressWarnings("unchecked") protected T readInternal(Class<? extends T> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { WireFeedInput feedInput = new WireFeedInput(); MediaType contentType = inputMessage.getHeaders().getContentType(); Charset charset = (contentType != null && contentType.getCharset() != null ? contentType.getCharset() : 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, inputMessage); } }
/** * Creates a SyndFeedInput instance. * <p> * * @param validate indicates if the input should be validated. NOT IMPLEMENTED YET (validation * does not happen) * */ public SyndFeedInput(final boolean validate, final Locale locale) { feedInput = new WireFeedInput(validate, locale); }
/** * Creates a SyndFeedInput instance. * <p> * * @param validate indicates if the input should be validated. NOT IMPLEMENTED YET (validation * does not happen) * */ public SyndFeedInput(final boolean validate, final Locale locale) { feedInput = new WireFeedInput(validate, locale); }
/** * Get feed document representing collection. * * @throws com.rometools.rome.propono.atom.server.AtomException On error retrieving feed file. * @return Atom Feed representing collection. */ public Feed getFeedDocument() throws AtomException { InputStream in = null; synchronized (FileStore.getFileStore()) { in = FileStore.getFileStore().getFileInputStream(getFeedPath()); if (in == null) { in = createDefaultFeedDocument(contextURI + servletPath + "/" + handle + "/" + collection); } } try { final WireFeedInput input = new WireFeedInput(); final WireFeed wireFeed = input.build(new InputStreamReader(in, "UTF-8")); return (Feed) wireFeed; } catch (final Exception ex) { throw new AtomException(ex); } }
@Override @SuppressWarnings("unchecked") protected T readInternal(Class<? extends T> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { WireFeedInput feedInput = new WireFeedInput(); MediaType contentType = inputMessage.getHeaders().getContentType(); Charset charset = (contentType != null && contentType.getCharset() != null ? contentType.getCharset() : 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, inputMessage); } }
@Override @SuppressWarnings("unchecked") protected T readInternal(Class<? extends T> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { WireFeedInput feedInput = new WireFeedInput(); MediaType contentType = inputMessage.getHeaders().getContentType(); Charset charset = (contentType != null && contentType.getCharset() != null ? contentType.getCharset() : 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); } }
private void getNextEntries() throws ProponoException { if (nextURI == null) { return; } final GetMethod colGet = new GetMethod(collection.getHrefResolved(nextURI)); collection.addAuthentication(colGet); try { collection.getHttpClient().executeMethod(colGet); final SAXBuilder builder = new SAXBuilder(); final Document doc = builder.build(colGet.getResponseBodyAsStream()); final WireFeedInput feedInput = new WireFeedInput(); col = (Feed) feedInput.build(doc); } catch (final Exception e) { throw new ProponoException("ERROR: fetching or parsing next entries, HTTP code: " + (colGet != null ? colGet.getStatusCode() : -1), e); } finally { colGet.releaseConnection(); } members = col.getEntries().iterator(); col.getEntries().size(); nextURI = null; final List<Link> altLinks = col.getOtherLinks(); if (altLinks != null) { for (final Link link : altLinks) { if ("next".equals(link.getRel())) { nextURI = link.getHref(); } } } }
/** * Parse entry from reader. */ public static Entry parseEntry(final Reader rd, final String baseURI, final Locale locale) throws JDOMException, IOException, IllegalArgumentException, FeedException { // Parse entry into JDOM tree final SAXBuilder builder = new SAXBuilder(); final Document entryDoc = builder.build(rd); final Element fetchedEntryElement = entryDoc.getRootElement(); fetchedEntryElement.detach(); // Put entry into a JDOM document with 'feed' root so that Rome can // handle it final Feed feed = new Feed(); feed.setFeedType("atom_1.0"); final WireFeedOutput wireFeedOutput = new WireFeedOutput(); final Document feedDoc = wireFeedOutput.outputJDom(feed); feedDoc.getRootElement().addContent(fetchedEntryElement); if (baseURI != null) { feedDoc.getRootElement().setAttribute("base", baseURI, Namespace.XML_NAMESPACE); } final WireFeedInput input = new WireFeedInput(false, locale); final Feed parsedFeed = (Feed) input.build(feedDoc); return parsedFeed.getEntries().get(0); }
WireFeedInput input = new WireFeedInput(true, Locale.US); WireFeed wf = input.build(new XmlReader(new URL(url)));
/** * Parse entry from reader. */ public static Entry parseEntry(final Reader rd, final String baseURI, final Locale locale) throws JDOMException, IOException, IllegalArgumentException, FeedException { // Parse entry into JDOM tree final SAXBuilder builder = new SAXBuilder(); final Document entryDoc = builder.build(rd); final Element fetchedEntryElement = entryDoc.getRootElement(); fetchedEntryElement.detach(); // Put entry into a JDOM document with 'feed' root so that Rome can // handle it final Feed feed = new Feed(); feed.setFeedType("atom_1.0"); final WireFeedOutput wireFeedOutput = new WireFeedOutput(); final Document feedDoc = wireFeedOutput.outputJDom(feed); feedDoc.getRootElement().addContent(fetchedEntryElement); if (baseURI != null) { feedDoc.getRootElement().setAttribute("base", baseURI, Namespace.XML_NAMESPACE); } final WireFeedInput input = new WireFeedInput(false, locale); final Feed parsedFeed = (Feed) input.build(feedDoc); return parsedFeed.getEntries().get(0); }