本文整理汇总了Java中com.sun.syndication.io.SyndFeedOutput类的典型用法代码示例。如果您正苦于以下问题:Java SyndFeedOutput类的具体用法?Java SyndFeedOutput怎么用?Java SyndFeedOutput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SyndFeedOutput类属于com.sun.syndication.io包,在下文中一共展示了SyndFeedOutput类的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: feed
import com.sun.syndication.io.SyndFeedOutput; //导入依赖的package包/类
@GetMapping(path = "/feed.xml", produces = MediaType.APPLICATION_ATOM_XML)
public void feed(HttpServletRequest req, Writer writer) {
try {
new SyndFeedOutput().output(getFeed(), writer);
} catch (Exception ex) {
logger.error("Could not generate feed", ex);
}
}
示例6: 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());
}
示例7: makeRSSFromRSSCorresponList
import com.sun.syndication.io.SyndFeedOutput; //导入依赖的package包/类
/**
* コレポンリストからRSSを生成する.
* @param rssCorresponList コレポンリスト
* @param baseURL BaseURL
* @return RSS
* @throws ServiceAbortException 設定値からRSSを出力する際に例外発生
*/
private String makeRSSFromRSSCorresponList(
List<RSSCorrespon> rssCorresponList, String baseURL) throws ServiceAbortException {
String resultRSS = null;
SyndFeed feed = (SyndFeed) new SyndFeedImpl();
feed.setFeedType(FEED_TYPE);
feed.setTitle(RSS_TITLE);
feed.setLink("");
feed.setDescription("");
List<SyndEntry> entries = new ArrayList<SyndEntry>();
if (rssCorresponList != null) {
for (RSSCorrespon c : rssCorresponList) {
entries.add(makeEntryFromRSSCorrespon(c, baseURL));
}
}
feed.setEntries(entries);
try {
SyndFeedOutput output = new SyndFeedOutput();
resultRSS = output.outputString(feed);
} catch (FeedException e) {
// 設定された値から生成されるXMLが異常だった際に発生. 起こり得ない.
ServiceAbortException sae =
new ServiceAbortException("RSS outputString error");
sae.initCause(e);
throw sae;
}
return resultRSS;
}
示例8: buildFeed
import com.sun.syndication.io.SyndFeedOutput; //导入依赖的package包/类
private @Nullable byte[] buildFeed(@Nonnull SyndFeed feed) {
try {
SyndFeedOutput output = new SyndFeedOutput();
feed.setEncoding(UTF_8.name());
return output.outputString(feed, true).getBytes(UTF_8);
} catch (FeedException e) {
logger.error(String.format("Failed to build feed '%s'", pageUrl), e);
}
return null;
}
示例9: buildFeed
import com.sun.syndication.io.SyndFeedOutput; //导入依赖的package包/类
private @Nullable byte[] buildFeed(@Nonnull SyndFeed feed) {
try {
SyndFeedOutput output = new SyndFeedOutput();
feed.setEncoding(UTF_8.name());
return output.outputString(feed, true).getBytes(UTF_8);
} catch (FeedException e) {
logger.error(String.format("Failed to build feed '%s'", feedUrl), e);
}
return null;
}
示例10: SyndFeedMediaResource
import com.sun.syndication.io.SyndFeedOutput; //导入依赖的package包/类
public SyndFeedMediaResource(final SyndFeed feed) {
this.feed = feed;
feedString = null;
try {
final SyndFeedOutput output = new SyndFeedOutput();
feedString = output.outputString(feed);
} catch (final FeedException e) {
/* TODO: ORID-1007 ExceptionHandling */
log.error(e.getMessage());
}
}
示例11: getFeed
import com.sun.syndication.io.SyndFeedOutput; //导入依赖的package包/类
/**
* Get the RSS feed
*
* @return
* @throws FeedException
*/
@GET
@Produces("application/rss+xml")
public StreamSource getFeed() throws FeedException {
feed.setLink(uriInfo.getBaseUri().toString());
feed.setEntries(transform(copyOf(feedQueue).reverse(), event2entry));
// TODO ought to make this stream, not go through a string
return new StreamSource(new ByteArrayInputStream(new SyndFeedOutput()
.outputString(feed).getBytes(UTF_8)));
}
示例12: 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();
}
}
}
示例13: 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;
}
}
示例14: initializeForSorting
import com.sun.syndication.io.SyndFeedOutput; //导入依赖的package包/类
/** This method will take a SyndFeed object with a SimpleListExtension on it and populate the entries
* with current SleEntry values for sorting and grouping.
* <b>NB</b>: This basically does this by re-generating the XML for all the entries then re-parsing them
* into the SLE data structures. It is a very heavy operation and should not be called frequently!
*/
public static void initializeForSorting( SyndFeed feed )throws FeedException {
List syndEntries = feed.getEntries();
// TODO: the null parameter below will break delegating parsers and generators
ModuleGenerators g =
new ModuleGenerators( feed.getFeedType() + ITEM_MODULE_GENERATORS_POSFIX_KEY,
null);
SyndFeedOutput o = new SyndFeedOutput();
Document d = o.outputJDom( feed );
SyndFeed feed2 = new SyndFeedInput().build( d );
feed.copyFrom( feed2 );
}
示例15: 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 "";
}
}