com.rometools.rome.io.WireFeedOutput Java Examples
The following examples show how to use
com.rometools.rome.io.WireFeedOutput.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractFeedView.java From spring-analysis-note with MIT License | 6 votes |
@Override protected final void renderMergedOutputModel( Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { T wireFeed = newFeed(); buildFeedMetadata(model, wireFeed, request); buildFeedEntries(model, wireFeed, request, response); setResponseContentType(request, response); if (!StringUtils.hasText(wireFeed.getEncoding())) { wireFeed.setEncoding("UTF-8"); } WireFeedOutput feedOutput = new WireFeedOutput(); ServletOutputStream out = response.getOutputStream(); feedOutput.output(wireFeed, new OutputStreamWriter(out, wireFeed.getEncoding())); out.flush(); }
Example #2
Source File: AbstractFeedView.java From java-technology-stack with MIT License | 6 votes |
@Override protected final void renderMergedOutputModel( Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { T wireFeed = newFeed(); buildFeedMetadata(model, wireFeed, request); buildFeedEntries(model, wireFeed, request, response); setResponseContentType(request, response); if (!StringUtils.hasText(wireFeed.getEncoding())) { wireFeed.setEncoding("UTF-8"); } WireFeedOutput feedOutput = new WireFeedOutput(); ServletOutputStream out = response.getOutputStream(); feedOutput.output(wireFeed, new OutputStreamWriter(out, wireFeed.getEncoding())); out.flush(); }
Example #3
Source File: AbstractFeedView.java From lams with GNU General Public License v2.0 | 6 votes |
@Override protected final void renderMergedOutputModel( Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { T wireFeed = newFeed(); buildFeedMetadata(model, wireFeed, request); buildFeedEntries(model, wireFeed, request, response); setResponseContentType(request, response); if (!StringUtils.hasText(wireFeed.getEncoding())) { wireFeed.setEncoding("UTF-8"); } WireFeedOutput feedOutput = new WireFeedOutput(); ServletOutputStream out = response.getOutputStream(); feedOutput.output(wireFeed, new OutputStreamWriter(out, wireFeed.getEncoding())); out.flush(); }
Example #4
Source File: AbstractFeedView.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Override protected final void renderMergedOutputModel( Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { T wireFeed = newFeed(); buildFeedMetadata(model, wireFeed, request); buildFeedEntries(model, wireFeed, request, response); setResponseContentType(request, response); if (!StringUtils.hasText(wireFeed.getEncoding())) { wireFeed.setEncoding("UTF-8"); } WireFeedOutput feedOutput = new WireFeedOutput(); ServletOutputStream out = response.getOutputStream(); feedOutput.output(wireFeed, new OutputStreamWriter(out, wireFeed.getEncoding())); out.flush(); }
Example #5
Source File: Atom10Parser.java From rome with Apache License 2.0 | 6 votes |
/** * 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); }
Example #6
Source File: Atom10Generator.java From rome with Apache License 2.0 | 6 votes |
/** * Utility method to serialize an entry to writer. */ public static void serializeEntry(final Entry entry, final Writer writer) throws IllegalArgumentException, FeedException, IOException { // Build a feed containing only the entry final List<Entry> entries = new ArrayList<Entry>(); entries.add(entry); final Feed feed1 = new Feed(); feed1.setFeedType("atom_1.0"); feed1.setEntries(entries); // Get Rome to output feed as a JDOM document final WireFeedOutput wireFeedOutput = new WireFeedOutput(); final Document feedDoc = wireFeedOutput.outputJDom(feed1); // Grab entry element from feed and get JDOM to serialize it final Element entryElement = feedDoc.getRootElement().getChildren().get(0); final XMLOutputter outputter = new XMLOutputter(); outputter.output(entryElement, writer); }
Example #7
Source File: OPML20GeneratorTest.java From rome with Apache License 2.0 | 6 votes |
private NodeList categoryOf(final String... categories) { try { final Outline outline = new Outline("outline1", null); outline.setCategories(Arrays.asList(categories)); final Opml opml = new Opml(); opml.setFeedType("opml_2.0"); opml.setTitle("title"); opml.setOutlines(Arrays.asList(outline)); final WireFeedOutput output = new WireFeedOutput(); final String xml = output.outputString(opml); final Document document = XMLUnit.buildControlDocument(xml); return XMLUnit.newXpathEngine().getMatchingNodes("/opml/body/outline/@category", document); } catch (final Exception e) { throw new RuntimeException(e); } }
Example #8
Source File: FileBasedCollection.java From rome with Apache License 2.0 | 6 votes |
private void updateFeedDocument(final Feed f) throws AtomException { try { synchronized (FileStore.getFileStore()) { final WireFeedOutput wireFeedOutput = new WireFeedOutput(); final Document feedDoc = wireFeedOutput.outputJDom(f); final XMLOutputter outputter = new XMLOutputter(); // outputter.setFormat(Format.getPrettyFormat()); final OutputStream fos = FileStore.getFileStore().getFileOutputStream(getFeedPath()); outputter.output(feedDoc, new OutputStreamWriter(fos, "UTF-8")); } } catch (final FeedException fex) { throw new AtomException(fex); } catch (final IOException ex) { throw new AtomException(ex); } }
Example #9
Source File: FeedREST.java From commafeed with Apache License 2.0 | 6 votes |
@GET @Path("/export") @UnitOfWork @Produces(MediaType.APPLICATION_XML) @ApiOperation(value = "OPML export", notes = "Export an OPML file of the user's subscriptions") @Timed public Response exportOpml(@ApiParam(hidden = true) @SecurityCheck User user) { Opml opml = opmlExporter.export(user); WireFeedOutput output = new WireFeedOutput(); String opmlString = null; try { opmlString = output.outputString(opml); } catch (Exception e) { return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e).build(); } return Response.ok(opmlString).build(); }
Example #10
Source File: TestAtomContent.java From rome with Apache License 2.0 | 5 votes |
public void testXML() throws Exception { final Feed feed = createFeed(); final StringWriter sw = new StringWriter(); final WireFeedOutput output = new WireFeedOutput(); output.output(feed, sw); sw.close(); assertTrue(sw.toString().contains("<test xmlns=\"\">Hello Hello</test>")); }
Example #11
Source File: TestOpsOPML10links.java From rome with Apache License 2.0 | 5 votes |
public void testTemp() throws Exception { final WireFeedInput input = new WireFeedInput(); final WireFeed wf = input.build(TestUtil.loadFile("/opml_1.0_links.xml")); final WireFeedOutput output = new WireFeedOutput(); final SyndFeedImpl sf = new SyndFeedImpl(wf); sf.setFeedType("rss_2.0"); sf.setDescription(""); sf.setLink("http://foo.com"); sf.setFeedType("opml_1.0"); output.output(sf.createWireFeed(), new NullWriter()); }
Example #12
Source File: JsonChannelHttpMessageConverter.java From tutorials with MIT License | 5 votes |
@Override protected void writeInternal(Channel wireFeed, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException { WireFeedOutput feedOutput = new WireFeedOutput(); try { String xmlStr = feedOutput.outputString(wireFeed, true); JSONObject xmlJSONObj = XML.toJSONObject(xmlStr); String jsonPrettyPrintString = xmlJSONObj.toString(4); outputMessage.getBody().write(jsonPrettyPrintString.getBytes()); } catch (JSONException | FeedException e) { e.printStackTrace(); } }
Example #13
Source File: RomeEventHandler.java From scipio-erp with Apache License 2.0 | 4 votes |
public void init(ServletContext context) throws EventHandlerException { // get the service event handler this.service = new ServiceEventHandler(); this.service.init(context); this.out = new WireFeedOutput(); }