Java Code Examples for com.rometools.rome.feed.synd.SyndFeed#setLink()
The following examples show how to use
com.rometools.rome.feed.synd.SyndFeed#setLink() .
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: ITunesGeneratorTest.java From rome with Apache License 2.0 | 6 votes |
public void testCreate() throws Exception { final SyndFeed feed = new SyndFeedImpl(); final String feedType = "rss_2.0"; feed.setFeedType(feedType); feed.setLanguage("en-us"); feed.setTitle("sales.com on the Radio!"); feed.setDescription("sales.com radio shows in MP3 format"); feed.setLink("http://foo/rss/podcasts.rss"); final FeedInformation fi = new FeedInformationImpl(); fi.setOwnerName("sales.com"); fi.getCategories().add(new Category("Shopping")); fi.setOwnerEmailAddress("[email protected]"); fi.setType("serial"); feed.getModules().add(fi); final SyndFeedOutput output = new SyndFeedOutput(); final StringWriter writer = new StringWriter(); output.output(feed, writer); LOG.debug("{}", writer); }
Example 2
Source File: ITunesGeneratorTest.java From rome with Apache License 2.0 | 6 votes |
public void testImage() throws Exception { SyndFeed feed = new SyndFeedImpl(); feed.setFeedType("rss_2.0"); feed.setTitle("title"); feed.setDescription("description"); feed.setLink("https://example.org"); FeedInformation itunesFeed = new FeedInformationImpl(); itunesFeed.setImage(new URL("https://example.org/test.png")); feed.getModules().add(itunesFeed); String xml = new SyndFeedOutput().outputString(feed); AbstractITunesObject parsedItunesFeed = (AbstractITunesObject) new SyndFeedInput() .build(new XmlReader(new ByteArrayInputStream(xml.getBytes("UTF-8")))) .getModule(AbstractITunesObject.URI); assertEquals(new URL("https://example.org/test.png"), parsedItunesFeed.getImage()); assertEquals(new java.net.URI("https://example.org/test.png"), parsedItunesFeed.getImageUri()); }
Example 3
Source File: ITunesGeneratorTest.java From rome with Apache License 2.0 | 6 votes |
public void testImageUri() throws Exception { SyndFeed feed = new SyndFeedImpl(); feed.setFeedType("rss_2.0"); feed.setTitle("title"); feed.setDescription("description"); feed.setLink("https://example.org"); FeedInformation itunesFeed = new FeedInformationImpl(); itunesFeed.setImageUri(new java.net.URI("https://example.org/test.png")); feed.getModules().add(itunesFeed); String xml = new SyndFeedOutput().outputString(feed); AbstractITunesObject parsedItunesFeed = (AbstractITunesObject) new SyndFeedInput() .build(new XmlReader(new ByteArrayInputStream(xml.getBytes("UTF-8")))) .getModule(AbstractITunesObject.URI); assertEquals(new java.net.URI("https://example.org/test.png"), parsedItunesFeed.getImageUri()); assertEquals(new URL("https://example.org/test.png"), parsedItunesFeed.getImage()); }
Example 4
Source File: ITunesGeneratorTest.java From rome with Apache License 2.0 | 6 votes |
public void testImageTakesPrecedenceOverImageUri() throws Exception { SyndFeed feed = new SyndFeedImpl(); feed.setFeedType("rss_2.0"); feed.setTitle("title"); feed.setDescription("description"); feed.setLink("https://example.org"); FeedInformation itunesFeed = new FeedInformationImpl(); itunesFeed.setImage(new URL("https://example.org/test1.png")); itunesFeed.setImageUri(new java.net.URI("https://example.org/test2.png")); feed.getModules().add(itunesFeed); String xml = new SyndFeedOutput().outputString(feed); AbstractITunesObject parsedItunesFeed = (AbstractITunesObject) new SyndFeedInput() .build(new XmlReader(new ByteArrayInputStream(xml.getBytes("UTF-8")))) .getModule(AbstractITunesObject.URI); assertEquals(new URL("https://example.org/test1.png"), parsedItunesFeed.getImage()); assertEquals(new java.net.URI("https://example.org/test1.png"), parsedItunesFeed.getImageUri()); }
Example 5
Source File: RSSFeedServlet.java From wildfly-camel with Apache License 2.0 | 6 votes |
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { SyndFeed feed = new SyndFeedImpl(); feed.setFeedType("rss_2.0"); feed.setTitle("WildFly-Camel Test RSS Feed"); feed.setLink("http://localhost:8080/rss-tests"); feed.setDescription("Test RSS feed for the camel-rss component"); List<SyndEntry> entries = new ArrayList<>(); for (int i = 1; i <= 5; i++) { entries.add(createFeedEntry("Test entry: ", "Test content: ", i)); } feed.setEntries(entries); SyndFeedOutput output = new SyndFeedOutput(); try { output.output(feed, response.getWriter()); } catch (FeedException e) { throw new IllegalStateException("Error generating RSS feed", e); } }
Example 6
Source File: SyndicationServlet.java From BIMserver with GNU Affero General Public License v3.0 | 5 votes |
private void writeRevisionsFeed(HttpServletRequest request, HttpServletResponse response, ServiceMap serviceMap) throws IOException, FeedException, ServiceException, PublicInterfaceNotFoundException { long poid = Long.parseLong(request.getParameter("poid")); SProject sProject = serviceMap.getServiceInterface().getProjectByPoid(poid); SyndFeed feed = new SyndFeedImpl(); feed.setFeedType(FEED_TYPE); feed.setTitle("BIMserver.org revisions feed for project '" + sProject.getName() + "'"); feed.setLink(request.getContextPath()); feed.setDescription("This feed represents all the revisions of project '" + sProject.getName() + "'"); List<SyndEntry> entries = new ArrayList<SyndEntry>(); try { List<SRevision> allRevisionsOfProject = serviceMap.getServiceInterface().getAllRevisionsOfProject(poid); Collections.sort(allRevisionsOfProject, new SRevisionIdComparator(false)); for (SRevision sVirtualRevision : allRevisionsOfProject) { SUser user = serviceMap.getServiceInterface().getUserByUoid(sVirtualRevision.getUserId()); SyndEntry entry = new SyndEntryImpl(); entry.setTitle("Revision " + sVirtualRevision.getOid()); entry.setLink(request.getContextPath() + "/revision.jsp?poid=" + sVirtualRevision.getOid() + "&roid=" + sVirtualRevision.getOid()); entry.setPublishedDate(sVirtualRevision.getDate()); SyndContent description = new SyndContentImpl(); description.setType("text/html"); description.setValue("<table><tr><td>User</td><td>" + user.getUsername() + "</td></tr><tr><td>Comment</td><td>" + sVirtualRevision.getComment() + "</td></tr></table>"); entry.setDescription(description); entries.add(entry); } } catch (ServiceException e) { LOGGER.error("", e); } feed.setEntries(entries); SyndFeedOutput output = new SyndFeedOutput(); output.output(feed, response.getWriter()); }
Example 7
Source File: SyndicationServlet.java From BIMserver with GNU Affero General Public License v3.0 | 5 votes |
private void writeCheckoutsFeed(HttpServletRequest request, HttpServletResponse response, ServiceMap serviceMap) throws ServiceException, IOException, FeedException, PublicInterfaceNotFoundException { long poid = Long.parseLong(request.getParameter("poid")); SProject sProject = serviceMap.getServiceInterface().getProjectByPoid(poid); SyndFeed feed = new SyndFeedImpl(); feed.setFeedType(FEED_TYPE); feed.setTitle("BIMserver.org checkouts feed for project '" + sProject.getName() + "'"); feed.setLink(request.getContextPath()); feed.setDescription("This feed represents all the checkouts of project '" + sProject.getName() + "'"); List<SyndEntry> entries = new ArrayList<SyndEntry>(); try { List<SCheckout> allCheckoutsOfProject = serviceMap.getServiceInterface().getAllCheckoutsOfProjectAndSubProjects(poid); for (SCheckout sCheckout : allCheckoutsOfProject) { SRevision revision = serviceMap.getServiceInterface().getRevision(sCheckout.getRevision().getOid()); SProject project = serviceMap.getServiceInterface().getProjectByPoid(sCheckout.getProjectId()); SUser user = serviceMap.getServiceInterface().getUserByUoid(sCheckout.getUserId()); SyndEntry entry = new SyndEntryImpl(); entry.setTitle("Checkout on " + project.getName() + ", revision " + revision.getId()); entry.setLink(request.getContextPath() + "/project.jsp?poid=" + sProject.getOid()); entry.setPublishedDate(sCheckout.getDate()); SyndContent description = new SyndContentImpl(); description.setType("text/plain"); description .setValue("<table><tr><td>User</td><td>" + user.getUsername() + "</td></tr><tr><td>Revision</td><td>" + sCheckout.getRevision().getOid() + "</td></tr></table>"); entry.setDescription(description); entries.add(entry); } } catch (UserException e) { LOGGER.error("", e); } feed.setEntries(entries); SyndFeedOutput output = new SyndFeedOutput(); output.output(feed, response.getWriter()); }
Example 8
Source File: ConverterForRSS090.java From rome with Apache License 2.0 | 5 votes |
@Override public void copyInto(final WireFeed feed, final SyndFeed syndFeed) { syndFeed.setModules(ModuleUtils.cloneModules(feed.getModules())); final List<Element> foreignMarkup = feed.getForeignMarkup(); if (!foreignMarkup.isEmpty()) { syndFeed.setForeignMarkup(foreignMarkup); } syndFeed.setStyleSheet(feed.getStyleSheet()); syndFeed.setEncoding(feed.getEncoding()); final Channel channel = (Channel) feed; syndFeed.setTitle(channel.getTitle()); syndFeed.setLink(channel.getLink()); syndFeed.setDescription(channel.getDescription()); final Image image = channel.getImage(); if (image != null) { syndFeed.setImage(createSyndImage(image)); } final List<Item> items = channel.getItems(); if (items != null) { syndFeed.setEntries(createSyndEntries(items, syndFeed.isPreservingWireFeed())); } }
Example 9
Source File: BlogRssServices.java From scipio-erp with Apache License 2.0 | 4 votes |
public static Map<String, Object> generateBlogRssFeed(DispatchContext dctx, Map<String, ? extends Object> context) { GenericValue userLogin = (GenericValue) context.get("userLogin"); String contentId = (String) context.get("blogContentId"); String entryLink = (String) context.get("entryLink"); String feedType = (String) context.get("feedType"); Locale locale = (Locale) context.get("locale"); // create the main link String mainLink = (String) context.get("mainLink"); mainLink = mainLink + "?blogContentId=" + contentId; LocalDispatcher dispatcher = dctx.getDispatcher(); Delegator delegator = dctx.getDelegator(); // get the main blog content GenericValue content = null; try { content = EntityQuery.use(delegator).from("Content").where("contentId", contentId).queryOne(); } catch (GenericEntityException e) { Debug.logError(e, module); } if (content == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ContentCannotGenerateBlogRssFeed", UtilMisc.toMap("contentId", contentId), locale)); } // create the feed SyndFeed feed = new SyndFeedImpl(); feed.setFeedType(feedType); feed.setLink(mainLink); feed.setTitle(content.getString("contentName")); feed.setDescription(content.getString("description")); feed.setEntries(generateEntryList(dispatcher, delegator, contentId, entryLink, locale, userLogin)); Map<String, Object> resp = ServiceUtil.returnSuccess(); resp.put("wireFeed", feed.createWireFeed()); return resp; }
Example 10
Source File: FeedAggregator.java From rome with Apache License 2.0 | 4 votes |
public static void main(final String[] args) { boolean ok = false; if (args.length >= 2) { try { final String outputType = args[0]; final SyndFeed feed = new SyndFeedImpl(); feed.setFeedType(outputType); feed.setTitle("Aggregated Feed"); feed.setDescription("Anonymous Aggregated Feed"); feed.setAuthor("anonymous"); feed.setLink("http://www.anonymous.com"); final List<SyndEntry> entries = new ArrayList<SyndEntry>(); feed.setEntries(entries); final FeedFetcherCache feedInfoCache = HashMapFeedInfoCache.getInstance(); final FeedFetcher feedFetcher = new HttpURLFeedFetcher(feedInfoCache); for (int i = 1; i < args.length; i++) { final URL inputUrl = new URL(args[i]); final SyndFeed inFeed = feedFetcher.retrieveFeed(inputUrl); entries.addAll(inFeed.getEntries()); } final SyndFeedOutput output = new SyndFeedOutput(); output.output(feed, new PrintWriter(System.out)); ok = true; } catch (final Exception ex) { System.out.println("ERROR: " + ex.getMessage()); ex.printStackTrace(); } } if (!ok) { System.out.println(); System.out.println("FeedAggregator aggregates different feeds into a single one."); System.out.println("The first parameter must be the feed type for the aggregated feed."); System.out.println(" [valid values are: rss_0.9, rss_0.91, rss_0.92, rss_0.93, ]"); System.out.println(" [ rss_0.94, rss_1.0, rss_2.0 & atom_0.3 ]"); System.out.println("The second to last parameters are the URLs of feeds to aggregate."); System.out.println(); } }