Package org.apache.wiki.rss
Class DefaultRSSGenerator
- java.lang.Object
-
- org.apache.wiki.rss.DefaultRSSGenerator
-
- All Implemented Interfaces:
Initializable,RSSGenerator
public class DefaultRSSGenerator extends java.lang.Object implements RSSGenerator
Default implementation forRSSGenerator.
-
-
Field Summary
-
Fields inherited from interface org.apache.wiki.rss.RSSGenerator
ATOM, MODE_BLOG, MODE_FULL, MODE_WIKI, PROP_CHANNEL_DESCRIPTION, PROP_CHANNEL_LANGUAGE, PROP_CHANNEL_TITLE, PROP_GENERATE_RSS, PROP_INTERVAL, PROP_RSS_AUTHOR, PROP_RSS_AUTHOREMAIL, PROP_RSSFILE, RSS10, RSS20
-
-
Constructor Summary
Constructors Constructor Description DefaultRSSGenerator(Engine engine, java.util.Properties properties)Builds the RSS generator for a given Engine.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringgenerate()Generates the RSS resource.java.lang.StringgenerateBlogRSS(Context wikiContext, java.util.List<Page> changed, Feed feed)Creates RSS from modifications as if this page was a blog (using the WeblogPlugin).java.lang.StringgenerateFeed(Context wikiContext, java.util.List<Page> changed, java.lang.String mode, java.lang.String type)Generates a feed based on a context and list of changes.java.lang.StringgenerateFullWikiRSS(Context wikiContext, Feed feed)Generates an RSS feed for the entire wiki.java.lang.StringgenerateWikiPageRSS(Context wikiContext, java.util.List<Page> changed, Feed feed)Create RSS/Atom as if this page was a wikipage (in contrast to Blog mode).java.lang.StringgetRssFile()returns the rss file.voidinitialize(Engine engine, java.util.Properties properties)Initializes this Engine component.booleanisEnabled()Returnstrueif RSS generation is enabled.voidsetEnabled(boolean enabled)Turns RSS generation on or off.
-
-
-
Constructor Detail
-
DefaultRSSGenerator
public DefaultRSSGenerator(Engine engine, java.util.Properties properties)
Builds the RSS generator for a given Engine.- Parameters:
engine- The Engine.properties- The properties.
-
-
Method Detail
-
initialize
public void initialize(Engine engine, java.util.Properties properties)
Initializes this Engine component. Note that the engine is not fully initialized at this point, so don't do anything fancy here - use lazy init, if you have to.
Start the RSS generator & generator thread
- Specified by:
initializein interfaceInitializable- Parameters:
engine- Engine performing the initialization.properties- Properties for setup.
-
generate
public java.lang.String generate()
Generates the RSS resource. You probably want to output this result into a file or something, or serve as output from a servlet.- Specified by:
generatein interfaceRSSGenerator- Returns:
- A RSS 1.0 feed in the "full" mode.
-
generateFeed
public java.lang.String generateFeed(Context wikiContext, java.util.List<Page> changed, java.lang.String mode, java.lang.String type) throws java.lang.IllegalArgumentException
Generates a feed based on a context and list of changes.- Specified by:
generateFeedin interfaceRSSGenerator- Parameters:
wikiContext- The WikiContextchanged- A list of Entry objectsmode- The mode (wiki/blog)type- The type (RSS10, RSS20, ATOM). Default is RSS 1.0- Returns:
- Fully formed XML.
- Throws:
java.lang.IllegalArgumentException- If an illegal mode is given.
-
isEnabled
public boolean isEnabled()
Returnstrueif RSS generation is enabled.- Specified by:
isEnabledin interfaceRSSGenerator- Returns:
- whether RSS generation is currently enabled
-
setEnabled
public void setEnabled(boolean enabled)
Turns RSS generation on or off. This setting is used to set the "enabled" flag only for use by callers, and does not actually affect whether theRSSGenerator.generate()orRSSGenerator.generateFeed(Context, List, String, String)methods output anything.- Specified by:
setEnabledin interfaceRSSGenerator- Parameters:
enabled- whether RSS generation is considered enabled.
-
getRssFile
public java.lang.String getRssFile()
returns the rss file.- Specified by:
getRssFilein interfaceRSSGenerator- Returns:
- the rss file.
-
generateFullWikiRSS
public java.lang.String generateFullWikiRSS(Context wikiContext, Feed feed)
Generates an RSS feed for the entire wiki. Each item should be an instance of the RSSItem class.- Specified by:
generateFullWikiRSSin interfaceRSSGenerator- Parameters:
wikiContext- A WikiContextfeed- A Feed to generate the feed to.- Returns:
- feed.getString().
-
generateWikiPageRSS
public java.lang.String generateWikiPageRSS(Context wikiContext, java.util.List<Page> changed, Feed feed)
Create RSS/Atom as if this page was a wikipage (in contrast to Blog mode).- Specified by:
generateWikiPageRSSin interfaceRSSGenerator- Parameters:
wikiContext- The WikiContextchanged- A List of changed WikiPages.feed- A Feed object to fill.- Returns:
- the RSS representation of the wiki context
-
generateBlogRSS
public java.lang.String generateBlogRSS(Context wikiContext, java.util.List<Page> changed, Feed feed)
Creates RSS from modifications as if this page was a blog (using the WeblogPlugin).- Specified by:
generateBlogRSSin interfaceRSSGenerator- Parameters:
wikiContext- The WikiContext, as usual.changed- A list of the changed pages.feed- A valid Feed object. The feed will be used to create the RSS/Atom, depending on which kind of an object you want to put in it.- Returns:
- A String of valid RSS or Atom.
-
-