com.ecyrd.jspwiki.rss
Class RSSGenerator

java.lang.Object
  extended by com.ecyrd.jspwiki.rss.RSSGenerator

public class RSSGenerator
extends Object

Generates an RSS feed from the recent changes.

We use the 1.0 spec, including the wiki-specific extensions. Wiki extensions have been defined in UseMod:ModWiki.

Since:
1.7.5.
Author:
Janne Jalkanen

Field Summary
static String ATOM
           
static String MODE_BLOG
           
static String MODE_FULL
           
static String MODE_WIKI
           
static String PROP_CHANNEL_DESCRIPTION
          Defines the property name for the RSS channel description.
static String PROP_CHANNEL_LANGUAGE
          Defines the property name for the RSS channel language.
static String PROP_CHANNEL_TITLE
           
static String PROP_GENERATE_RSS
          Defines the property name for the RSS generator main switch.
static String PROP_INTERVAL
          Defines the property name for the RSS generation interval in seconds.
static String PROP_RSS_AUTHOR
           
static String PROP_RSS_AUTHOREMAIL
           
static String PROP_RSS_COPYRIGHT
           
static String PROP_RSSAUTHOR
           
static String PROP_RSSAUTHOREMAIL
           
static String PROP_RSSFILE
          Defines the property name for the RSS file that the wiki should generate.
static String RSS10
           
static String RSS20
           
 
Constructor Summary
RSSGenerator(WikiEngine engine, Properties properties)
          Initialize the RSS generator.
 
Method Summary
static String format(String s)
          Does the required formatting and entity replacement for XML.
 String generate()
          Generates the RSS resource.
protected  String generateBlogRSS(WikiContext wikiContext, List changed, Feed feed)
           
 String generateFeed(WikiContext wikiContext, List changed, String mode, String type)
          Generates a feed based on a context and list of changes.
protected  String generateFullWikiRSS(WikiContext wikiContext, Feed feed)
          Generates an RSS feed for the entire wiki.
protected  String generateWikiPageRSS(WikiContext wikiContext, List changed, Feed feed)
           
static String getContentType(String mode)
          Returns the content type of this RSS feed.
 boolean isEnabled()
          Returns true if RSS generation is enabled.
 void setEnabled(boolean enabled)
          Turns RSS generation on or off.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RSS10

public static final String RSS10
See Also:
Constant Field Values

RSS20

public static final String RSS20
See Also:
Constant Field Values

ATOM

public static final String ATOM
See Also:
Constant Field Values

MODE_BLOG

public static final String MODE_BLOG
See Also:
Constant Field Values

MODE_WIKI

public static final String MODE_WIKI
See Also:
Constant Field Values

MODE_FULL

public static final String MODE_FULL
See Also:
Constant Field Values

PROP_CHANNEL_DESCRIPTION

public static final String PROP_CHANNEL_DESCRIPTION
Defines the property name for the RSS channel description. Default value for the channel description is an empty string.

Since:
1.7.6.
See Also:
Constant Field Values

PROP_CHANNEL_LANGUAGE

public static final String PROP_CHANNEL_LANGUAGE
Defines the property name for the RSS channel language. Default value for the language is "en-us".

Since:
1.7.6.
See Also:
Constant Field Values

PROP_CHANNEL_TITLE

public static final String PROP_CHANNEL_TITLE
See Also:
Constant Field Values

PROP_GENERATE_RSS

public static final String PROP_GENERATE_RSS
Defines the property name for the RSS generator main switch.

Since:
1.7.6.
See Also:
Constant Field Values

PROP_RSSFILE

public static final String PROP_RSSFILE
Defines the property name for the RSS file that the wiki should generate.

Since:
1.7.6.
See Also:
Constant Field Values

PROP_RSSAUTHOR

public static final String PROP_RSSAUTHOR
See Also:
Constant Field Values

PROP_RSSAUTHOREMAIL

public static final String PROP_RSSAUTHOREMAIL
See Also:
Constant Field Values

PROP_INTERVAL

public static final String PROP_INTERVAL
Defines the property name for the RSS generation interval in seconds.

Since:
1.7.6.
See Also:
Constant Field Values

PROP_RSS_AUTHOR

public static final String PROP_RSS_AUTHOR
See Also:
Constant Field Values

PROP_RSS_AUTHOREMAIL

public static final String PROP_RSS_AUTHOREMAIL
See Also:
Constant Field Values

PROP_RSS_COPYRIGHT

public static final String PROP_RSS_COPYRIGHT
See Also:
Constant Field Values
Constructor Detail

RSSGenerator

public RSSGenerator(WikiEngine engine,
                    Properties properties)
             throws NoRequiredPropertyException
Initialize the RSS generator.

Throws:
NoRequiredPropertyException
Method Detail

format

public static String format(String s)
Does the required formatting and entity replacement for XML.


generate

public 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.


getContentType

public static String getContentType(String mode)
Returns the content type of this RSS feed.

Parameters:
mode - the RSS mode: RSS10, RSS20 or ATOM.
Returns:
the content type
Since:
2.3.15

generateFeed

public String generateFeed(WikiContext wikiContext,
                           List changed,
                           String mode,
                           String type)
                    throws ProviderException
Generates a feed based on a context and list of changes.

Parameters:
wikiContext - The WikiContext
changed - A list of Entry objects
mode - The mode (wiki/blog)
type - The type (RSS10, RSS20, ATOM). Default is RSS 1.0
Returns:
Fully formed XML.
Throws:
ProviderException - If the underlying provider failed.
IllegalArgumentException - If an illegal mode is given.

isEnabled

public boolean isEnabled()
Returns true if RSS generation is enabled.

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 the generate() or generateFeed(WikiContext, List, String, String) methods output anything.

Parameters:
enabled - whether RSS generation is considered enabled.

generateFullWikiRSS

protected String generateFullWikiRSS(WikiContext wikiContext,
                                     Feed feed)
Generates an RSS feed for the entire wiki. Each item should be an instance of the RSSItem class.


generateWikiPageRSS

protected String generateWikiPageRSS(WikiContext wikiContext,
                                     List changed,
                                     Feed feed)

generateBlogRSS

protected String generateBlogRSS(WikiContext wikiContext,
                                 List changed,
                                 Feed feed)
                          throws ProviderException
Throws:
ProviderException