本文整理汇总了Java中com.sun.syndication.io.SyndFeedOutput.output方法的典型用法代码示例。如果您正苦于以下问题:Java SyndFeedOutput.output方法的具体用法?Java SyndFeedOutput.output怎么用?Java SyndFeedOutput.output使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.syndication.io.SyndFeedOutput
的用法示例。
在下文中一共展示了SyndFeedOutput.output方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doGet
import com.sun.syndication.io.SyndFeedOutput; //导入方法依赖的package包/类
public void doGet(HttpServletRequest req,HttpServletResponse res) throws IOException {
try {
SyndFeed feed = getFeed(req);
String feedType = req.getParameter(FEED_TYPE);
feedType = (feedType!=null) ? feedType : _defaultFeedType;
feed.setFeedType(feedType);
res.setContentType(MIME_TYPE);
SyndFeedOutput output = new SyndFeedOutput();
output.output(feed,res.getWriter());
}
catch (FeedException ex) {
String msg = COULD_NOT_GENERATE_FEED_ERROR;
log(msg,ex);
res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,msg);
}
}
示例2: doGet
import com.sun.syndication.io.SyndFeedOutput; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
String sourceConfigurationId = req.getPathInfo();
log.info("Received " + sourceConfigurationId);
SourceConfiguration sourceConfiguration = Configuration.sourceConfigurations.get(sourceConfigurationId);
if (sourceConfiguration == null) {
log.severe("Wrong resource " + req.getPathInfo());
resp.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
List<SourceItem> items = DatabaseService.getItems(sourceConfigurationId, 25);
SyndFeed feed = FeedUtils.createFeed(sourceConfigurationId, sourceConfiguration, items);
SyndFeedOutput output = new SyndFeedOutput();
resp.setCharacterEncoding("UTF-8");
PrintWriter writer = resp.getWriter();
try {
output.output(feed, writer);
} catch (FeedException e) {
e.printStackTrace();
}
writer.close();
}
示例3: doGet
import com.sun.syndication.io.SyndFeedOutput; //导入方法依赖的package包/类
@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);
}
}
示例4: main
import com.sun.syndication.io.SyndFeedOutput; //导入方法依赖的package包/类
public static void main(String[] args) {
boolean ok = false;
if (args.length==2) {
try {
String outputType = args[0];
URL feedUrl = new URL(args[1]);
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(feedUrl));
feed.setFeedType(outputType);
SyndFeedOutput output = new SyndFeedOutput();
output.output(feed,new PrintWriter(System.out));
ok = true;
}
catch (Exception ex) {
System.out.println("ERROR: "+ex.getMessage());
}
}
if (!ok) {
System.out.println();
System.out.println("Converter converts between syndication feeds types.");
System.out.println("The first parameter must be the feed type to convert to.");
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 parameter must be the URL of the feed to convert.");
System.out.println();
}
}
示例5: rssFeed
import com.sun.syndication.io.SyndFeedOutput; //导入方法依赖的package包/类
@RequestMapping("/rss")
public void rssFeed(HttpServletResponse response) throws IOException, FeedException {
SyndFeed feed = new SyndFeedImpl();
feed.setFeedType("atom_1.0");
feed.setEntries(new LinkedList());
podcastEpisodeService.allPodcasts().forEach(podcastEpisode -> {
feed.getEntries().add(podcastEpisode.getSyndEntry());
});
SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, response.getWriter());
}
示例6: writeFeedFile
import com.sun.syndication.io.SyndFeedOutput; //导入方法依赖的package包/类
/**
* Write the syndication feed entries to the file.
*
* @param entries Entry list
*
*/
private void writeFeedFile(List<SyndEntry> entries) {
// write the updated RSS feed for the series
final File encodingDirectory = new File(feedFilePath, subscription.getTranscodeProfile());
final File feedFile =
new File(encodingDirectory, subscription.getSeriesId() + feedFileExtension);
LOGGER.debug("Changes made to feed, updating feed file: path[" + feedFile.getAbsolutePath()
+ "]");
// sort the feed entries by published-date
Collections.sort(entries, entryComparator);
File transformedFeedFile = null;
try {
FileWriter writer = new FileWriter(feedFile);
SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, writer);
transformedFeedFile =
feedFileAccessor.generateTransformationFromFeed(feedFile, feed,
subscription.getSeriesId());
} catch (Exception e) {
LOGGER.error("Error rendering feed", e);
if (feedFile.canWrite()) {
feedFile.delete();
}
if (transformedFeedFile != null && transformedFeedFile.canWrite()) {
transformedFeedFile.delete();
}
}
}
示例7: createFeed
import com.sun.syndication.io.SyndFeedOutput; //导入方法依赖的package包/类
/**
* @param feedFile
* @param seriesId
* @param title
* @param transcodingProfileId
* @return
*/
public SyndFeed createFeed(File feedFile, String seriesId, String title,
String transcodingProfileId) {
final SyndFeed defaultFeed = new SyndFeedImpl();
defaultFeed.setFeedType("rss_2.0");
defaultFeed.setTitle(title);
defaultFeed.setLink(this.applicationURL + PATH_SEPARATOR + transcodingProfileId
+ PATH_SEPARATOR + seriesId + feedFileExtension);
defaultFeed.setDescription("Feed for the MythTV recordings of this program");
File transformedFeedFile = null;
try {
final File feedDirectory = feedFile.getParentFile();
if (!feedDirectory.exists()) {
feedDirectory.mkdirs();
LOGGER.info("Created feed directory: " + feedDirectory.getPath());
}
FileWriter writer = new FileWriter(feedFile);
SyndFeedOutput output = new SyndFeedOutput();
output.output(defaultFeed, writer);
transformedFeedFile = this.generateTransformationFromFeed(feedFile, defaultFeed, seriesId);
return defaultFeed;
} catch (Exception e) {
LOGGER.error("Error rendering feed", e);
if (feedFile.canWrite()) {
feedFile.delete();
}
if (transformedFeedFile != null && transformedFeedFile.canWrite()) {
transformedFeedFile.delete();
}
return null;
}
}
示例8: render
import com.sun.syndication.io.SyndFeedOutput; //导入方法依赖的package包/类
/**
* <p>render</p>
*
* @return a {@link java.lang.String} object.
*/
public String render() {
SyndFeed feed = this.getFeed();
feed.setFeedType(this.getFeedType());
SyndFeedOutput output = new SyndFeedOutput();
try {
StringWriter writer = new StringWriter();
output.output(feed, writer);
return writer.toString();
} catch (Throwable e) {
log().warn("unable to render feed", e);
return "";
}
}
示例9: rss
import com.sun.syndication.io.SyndFeedOutput; //导入方法依赖的package包/类
public String rss() throws IOException, FeedException {
SyndFeed feed = new SyndFeedImpl();
feed.setTitle("hiscores.shmup.com");
feed.setFeedType("rss_2.0");
feed.setDescription("hiscores.shmup.com");
feed.setLink("http://hiscores.shmup.com");
List entries = new ArrayList();
feed.setEntries(entries);
for (Score score : scores) {
SyndEntry entry = new SyndEntryImpl();
entry.setTitle(score.getGameTitle());
entry.setAuthor(score.player.name);
entry.setLink("http://hiscores.shmup.com/score/" + score.id);
SyndContentImpl content = new SyndContentImpl();
content.setValue(score.tweet());
entry.setDescription(content);
entry.setPublishedDate(score.getCreatedAt());
entry.setUpdatedDate(score.getCreatedAt());
SyndEnclosureImpl enclosure = new SyndEnclosureImpl();
enclosure.setUrl(score.game.cover);
enclosure.setType(score.game.getCoverType());
entry.setEnclosures(Lists.newArrayList(enclosure));
entries.add(entry);
}
Writer writer = new StringWriter();
SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, writer);
writer.close();
Controller.response().setContentType("application/rss+xml");
return writer.toString();
}
示例10: writeRss
import com.sun.syndication.io.SyndFeedOutput; //导入方法依赖的package包/类
@Override
public void writeRss(Writer out, IRssChannel rssChannel) throws RssException, IOException {
SyndFeed syndFeed = ((RomeRssChannel)rssChannel).getSyndFeed();
SyndFeedOutput syndFeedOutput = new SyndFeedOutput();
try {
syndFeedOutput.output(syndFeed, out);
} catch (FeedException e) {
String msg = "Cannot write RSS feed.";
log.error(msg, e);
throw new RssException(msg, e);
}
}
示例11: main
import com.sun.syndication.io.SyndFeedOutput; //导入方法依赖的package包/类
public static void main(String[] args) {
boolean ok = false;
if (args.length>=2) {
try {
String outputType = args[0];
SyndFeed aggrFeed = new SyndFeedImpl();
aggrFeed.setFeedType(outputType);
aggrFeed.setTitle("Aggregated Feed");
aggrFeed.setDescription("Anonymous Aggregated Feed");
aggrFeed.setAuthor("anonymous");
aggrFeed.setLink("http://www.anonymous.com");
List entries = new ArrayList();
aggrFeed.setEntries(entries);
for (int i=1;i<args.length;i++) {
URL feedUrl = new URL(args[i]);
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(feedUrl));
entries.addAll(feed.getEntries());
}
SyndFeedOutput output = new SyndFeedOutput();
output.output(aggrFeed,new PrintWriter(System.out));
ok = true;
}
catch (Exception ex) {
System.out.println("ERROR: "+ex.getMessage());
}
}
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();
}
}
示例12: main
import com.sun.syndication.io.SyndFeedOutput; //导入方法依赖的package包/类
public static void main(String[] args) {
boolean ok = false;
if (args.length==2) {
try {
String feedType = args[0];
String fileName = args[1];
DateFormat dateParser = new SimpleDateFormat(DATE_FORMAT);
SyndFeed feed = new SyndFeedImpl();
feed.setFeedType(feedType);
feed.setTitle("Sample Feed (created with Rome)");
feed.setLink("http://rome.dev.java.net");
feed.setDescription("This feed has been created using Rome (Java syndication utilities");
List entries = new ArrayList();
SyndEntry entry;
SyndContent description;
entry = new SyndEntryImpl();
entry.setTitle("Rome v1.0");
entry.setLink("http://wiki.java.net/bin/view/Javawsxml/Rome01");
entry.setPublishedDate(dateParser.parse("2004-06-08"));
description = new SyndContentImpl();
description.setType("text/plain");
description.setValue("Initial release of Rome");
entry.setDescription(description);
entries.add(entry);
entry = new SyndEntryImpl();
entry.setTitle("Rome v2.0");
entry.setLink("http://wiki.java.net/bin/view/Javawsxml/Rome02");
entry.setPublishedDate(dateParser.parse("2004-06-16"));
description = new SyndContentImpl();
description.setType("text/xml");
description.setValue("Bug fixes, <xml>XML</xml> minor API changes and some new features");
entry.setDescription(description);
entries.add(entry);
entry = new SyndEntryImpl();
entry.setTitle("Rome v3.0");
entry.setLink("http://wiki.java.net/bin/view/Javawsxml/Rome03");
entry.setPublishedDate(dateParser.parse("2004-07-27"));
description = new SyndContentImpl();
description.setType("text/html");
description.setValue("<p>More Bug fixes, mor API changes, some new features and some Unit testing</p>"+
"<p>For details check the <a href=\"http://wiki.java.net/bin/view/Javawsxml/RomeChangesLog#RomeV03\">Changes Log</a></p>");
entry.setDescription(description);
entries.add(entry);
feed.setEntries(entries);
Writer writer = new FileWriter(fileName);
SyndFeedOutput output = new SyndFeedOutput();
output.output(feed,writer);
writer.close();
System.out.println("The feed has been written to the file ["+fileName+"]");
ok = true;
}
catch (Exception ex) {
ex.printStackTrace();
System.out.println("ERROR: "+ex.getMessage());
}
}
if (!ok) {
System.out.println();
System.out.println("FeedWriter creates a RSS/Atom feed and writes it to a file.");
System.out.println("The first parameter must be the syndication format for the feed");
System.out.println(" (rss_0.90, rss_0.91, rss_0.92, rss_0.93, rss_0.94, rss_1.0 rss_2.0 or atom_0.3)");
System.out.println("The second parameter must be the file name for the feed");
System.out.println();
}
}
示例13: WriteToFile
import com.sun.syndication.io.SyndFeedOutput; //导入方法依赖的package包/类
private boolean WriteToFile(String title, String link, String description, Date Pubdate,
String copyright,String imageTitle, String imageDescription,String imageLink, String imageUrl,String language,String author)
{
boolean retval=false;
try
{
// Specify Filename
String fileName=data.filename;;
// Set channel ...
data.feed =new SyndFeedImpl();
if(Const.isEmpty(meta.getVersion()))
data.feed.setFeedType("rss_2.0");
else
data.feed.setFeedType(meta.getVersion());
// Set encoding ...
if(Const.isEmpty(meta.getEncoding()))
data.feed.setEncoding("iso-8859-1");
else
data.feed.setEncoding(meta.getEncoding());
if(title!=null) data.feed.setTitle(title);
if(link!=null) data.feed.setLink(link);
if(description!=null) data.feed.setDescription(description);
if(Pubdate!=null) data.feed.setPublishedDate(Pubdate);//data.dateParser.parse(Pubdate.toString()));
// Set image ..
if(meta.AddImage())
{
SyndImage image = new SyndImageImpl();
if(imageTitle!=null) image.setTitle(title);
if(imageLink!=null) image.setLink(link);
if(imageUrl!=null) image.setUrl(imageUrl);
if(imageDescription!=null) image.setDescription(imageDescription);
data.feed.setImage(image);
}
if(language!=null) data.feed.setLanguage(language);
if(copyright!=null) data.feed.setCopyright(copyright);
if(author!=null) data.feed.setAuthor(author);
// Add entries
data.feed.setEntries(data.entries);
Writer writer = new FileWriter(fileName);
SyndFeedOutput output = new SyndFeedOutput();
output.output(data.feed,writer);
writer.close();
if (meta.AddToResult())
{
// Add this to the result file names...
ResultFile resultFile = new ResultFile(ResultFile.FILE_TYPE_GENERAL, KettleVFS.getFileObject(fileName), getTransMeta().getName(), getStepname());
resultFile.setComment("This file was created with a RSS Output step");
addResultFile(resultFile);
}
if(log.isDetailed())
log.logDetailed(toString(),Messages.getString("RssOutput.Log.CreatingFileOK",fileName));
retval=true;
}
catch(Exception e)
{
logError(Messages.getString("RssOutput.Log.ErrorCreatingFile",e.toString()));
setErrors(1);
retval = false;
}
return retval;
}
示例14: WriteToFile
import com.sun.syndication.io.SyndFeedOutput; //导入方法依赖的package包/类
private boolean WriteToFile(String title, String link, String description, Date Pubdate,
String copyright,String imageTitle, String imageDescription,String imageLink, String imageUrl,String language,String author)
{
boolean retval=false;
try
{
// Specify Filename
String fileName=data.filename;;
// Set channel ...
data.feed =new SyndFeedImpl();
if(Const.isEmpty(meta.getVersion()))
data.feed.setFeedType("rss_2.0");
else
data.feed.setFeedType(meta.getVersion());
// Set encoding ...
if(Const.isEmpty(meta.getEncoding()))
data.feed.setEncoding("iso-8859-1");
else
data.feed.setEncoding(meta.getEncoding());
if(title!=null) data.feed.setTitle(title);
if(link!=null) data.feed.setLink(link);
if(description!=null) data.feed.setDescription(description);
if(Pubdate!=null) data.feed.setPublishedDate(Pubdate);//data.dateParser.parse(Pubdate.toString()));
// Set image ..
if(meta.AddImage())
{
SyndImage image = new SyndImageImpl();
if(imageTitle!=null) image.setTitle(title);
if(imageLink!=null) image.setLink(link);
if(imageUrl!=null) image.setUrl(imageUrl);
if(imageDescription!=null) image.setDescription(imageDescription);
data.feed.setImage(image);
}
if(language!=null) data.feed.setLanguage(language);
if(copyright!=null) data.feed.setCopyright(copyright);
if(author!=null) data.feed.setAuthor(author);
// Add entries
data.feed.setEntries(data.entries);
Writer writer = new FileWriter(fileName);
SyndFeedOutput output = new SyndFeedOutput();
output.output(data.feed,writer);
writer.close();
if (meta.AddToResult())
{
// Add this to the result file names...
ResultFile resultFile = new ResultFile(ResultFile.FILE_TYPE_GENERAL, KettleVFS.getFileObject(fileName, getTransMeta()), getTransMeta().getName(), getStepname());
resultFile.setComment("This file was created with a RSS Output step");
addResultFile(resultFile);
}
if(log.isDetailed())
logDetailed(BaseMessages.getString(PKG, "RssOutput.Log.CreatingFileOK",fileName));
retval=true;
}
catch(Exception e)
{
logError(BaseMessages.getString(PKG, "RssOutput.Log.ErrorCreatingFile",e.toString()));
setErrors(1);
retval = false;
}
return retval;
}
示例15: doGet
import com.sun.syndication.io.SyndFeedOutput; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
Thread.currentThread().setContextClassLoader(SyndFeed.class.getClassLoader());
SyndFeed feed = new SyndFeedImpl();
feed.setFeedType("atom_1.0");
feed.setTitle("Sample Feed (created with ROME)");
feed.setLink("http://www.example.com");
List<SyndLink> links = new ArrayList<SyndLink>();
SyndLinkImpl hubLink = new SyndLinkImpl();
hubLink.setRel("hub");
hubLink.setHref("http://localhost:8080/hub/main");
links.add(hubLink);
feed.setLinks(links);
feed.setDescription("This feed has been created using ROME");
feed.setFeedType("atom_0.3");//rss_2.0
List entries = new ArrayList();
SyndEntry entry;
SyndContent description;
entry = new SyndEntryImpl();
entry.setTitle("ROME v1.0");
entry.setLink("http://wiki.java.net/bin/view/Javawsxml/Rome01");
entry.setPublishedDate(new Date());
description = new SyndContentImpl();
description.setType(MediaType.TEXT_PLAIN);
description.setValue("Initial release of ROME");
entry.setDescription(description);
entries.add(entry);
feed.setEntries(entries);
SyndFeedOutput output = new SyndFeedOutput();
try {
output.output(feed, resp.getWriter());
resp.getWriter().close();
} catch (FeedException e) {
LOG.error("Failed to create feed", e);
}
resp.getWriter().write(feed.createWireFeed().toString());
}