Author: jalkanen
Date: Fri May 30 11:40:39 2008
New Revision: 661811
URL: http://svn.apache.org/viewvc?rev=661811&view=rev
Log:
Javadoc, Java5, checkstyle, and comment fixes.
Modified:
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/UserManager.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/Role.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rpc/RPCManager.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rpc/json/JSONRPCManager.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/AtomFeed.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/Entry.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/Feed.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/RSS10Feed.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/RSS20Feed.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/RSSGenerator.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/RSSThread.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/search/LuceneSearchProvider.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/search/SearchManager.java
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/UserManager.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/UserManager.java?rev=661811&r1=661810&r2=661811&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/UserManager.java
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/UserManager.java Fri May
30 11:40:39 2008
@@ -579,7 +579,6 @@
* This is a database that gets used if nothing else is available. It does
* nothing of note - it just mostly thorws NoSuchPrincipalExceptions if
* someone tries to log in.
- * @author Janne Jalkanen
*/
public static class DummyUserDatabase extends AbstractUserDatabase
{
@@ -811,8 +810,6 @@
/**
* Implements the JSON API for usermanager.
- *
- * @author Janne Jalkanen
*/
public final class JSONUserModule implements RPCCallable
{
@@ -834,4 +831,4 @@
return prof;
}
}
-}
\ No newline at end of file
+}
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/Role.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/Role.java?rev=661811&r1=661810&r2=661811&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/Role.java
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/auth/authorize/Role.java Fri
May 30 11:40:39 2008
@@ -49,6 +49,9 @@
private final String m_name;
+ /**
+ * Create an empty Role.
+ */
protected Role()
{
this(null);
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rpc/RPCManager.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rpc/RPCManager.java?rev=661811&r1=661810&r2=661811&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rpc/RPCManager.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rpc/RPCManager.java Fri May
30 11:40:39 2008
@@ -27,6 +27,10 @@
*/
public class RPCManager
{
+ /**
+ * Private constructor to prevent initialization.
+ */
+ protected RPCManager() {}
/**
* Gets an unique RPC ID for a callable object. This is required because
a plugin
Modified:
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rpc/json/JSONRPCManager.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rpc/json/JSONRPCManager.java?rev=661811&r1=661810&r2=661811&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rpc/json/JSONRPCManager.java
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rpc/json/JSONRPCManager.java
Fri May 30 11:40:39 2008
@@ -59,7 +59,7 @@
public final class JSONRPCManager extends RPCManager
{
private static final String JSONRPCBRIDGE = "JSONRPCBridge";
- private static HashMap c_globalObjects = new HashMap();
+ private static HashMap<String, CallbackContainer> c_globalObjects = new
HashMap<String, CallbackContainer>();
/** Prevent instantiation */
private JSONRPCManager()
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/AtomFeed.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/AtomFeed.java?rev=661811&r1=661810&r2=661811&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/AtomFeed.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/AtomFeed.java Fri May 30
11:40:39 2008
@@ -50,8 +50,16 @@
{
private Namespace m_atomNameSpace =
Namespace.getNamespace("http://www.w3.org/2005/Atom");
+ /**
+ * Defines a SimpleDateFormat string for RFC3339-formatted dates.
+ */
public static final String RFC3339FORMAT = "yyyy-MM-dd'T'HH:mm:ssZZ";
+ /**
+ * Create a new AtomFeed for a given WikiContext.
+ *
+ * @param c A WikiContext.
+ */
public AtomFeed( WikiContext c )
{
super(c);
@@ -75,7 +83,7 @@
private Collection getItems()
{
- ArrayList list = new ArrayList();
+ ArrayList<Element> list = new ArrayList<Element>();
WikiEngine engine = m_wikiContext.getEngine();
ServletContext servletContext = null;
@@ -143,6 +151,10 @@
return list;
}
+ /**
+ * [EMAIL PROTECTED]
+ */
+ @Override
public String getString()
{
Element root = getElement("feed");
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/Entry.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/Entry.java?rev=661811&r1=661810&r2=661811&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/Entry.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/Entry.java Fri May 30
11:40:39 2008
@@ -23,63 +23,112 @@
import com.ecyrd.jspwiki.WikiPage;
/**
- * Represents an entry.
- *
- * @since
+ * Represents an entry, that is, an unit of change, in a Feed.
*/
public class Entry
{
- private String m_content;
- private String m_URL;
- private String m_title;
+ private String m_content;
+ private String m_url;
+ private String m_title;
private WikiPage m_page;
- private String m_author;
+ private String m_author;
+ /**
+ * Set the author of this entry.
+ *
+ * @param author Name of the author.
+ */
public void setAuthor( String author )
{
m_author = author;
}
+ /**
+ * Return the author set by setAuthor().
+ *
+ * @return A String representing the author.
+ */
public String getAuthor()
{
return m_author;
}
+ /**
+ * Returns the page set by [EMAIL PROTECTED] #setPage(WikiPage)}.
+ *
+ * @return The WikiPage to which this Entry refers to.
+ */
public WikiPage getPage()
{
return m_page;
}
+ /**
+ * Sets the WikiPage to which this Entry refers to.
+ *
+ * @param p A valid WikiPage.
+ */
public void setPage( WikiPage p )
{
m_page = p;
}
+ /**
+ * Sets a title for the change. For example, a WebLog entry might use the
+ * post title, or a Wiki change could use something like "XXX changed
page YYY".
+ *
+ * @param title A String description of the change.
+ */
public void setTitle( String title )
{
m_title = title;
}
+ /**
+ * Returns the title.
+ *
+ * @return The title set in setTitle.
+ */
public String getTitle()
{
return m_title;
}
+ /**
+ * Set the URL - the permalink - of the Entry.
+ *
+ * @param url An absolute URL to the entry.
+ */
public void setURL( String url )
{
- m_URL = url;
+ m_url = url;
}
+ /**
+ * Return the URL set by setURL().
+ *
+ * @return The URL.
+ */
public String getURL()
{
- return m_URL;
+ return m_url;
}
+ /**
+ * Set the content of this entry.
+ *
+ * @param content A String of the content.
+ */
public void setContent( String content )
{
m_content = content;
}
+ /**
+ * Return the content set by [EMAIL PROTECTED] #setContent(String)}.
+ *
+ * @return Whatever was set by setContent().
+ */
public String getContent()
{
return m_content;
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/Feed.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/Feed.java?rev=661811&r1=661810&r2=661811&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/Feed.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/Feed.java Fri May 30
11:40:39 2008
@@ -30,11 +30,10 @@
/**
* Represents an abstract feed.
*
- * @since
*/
public abstract class Feed
{
- protected List m_entries = new ArrayList();
+ protected List<Entry> m_entries = new ArrayList<Entry>();
protected String m_feedURL;
protected String m_channelTitle;
@@ -45,22 +44,50 @@
protected String m_mode = RSSGenerator.MODE_WIKI;
+ /**
+ * Create a new Feed for a particular WikiContext.
+ *
+ * @param context The WikiContext.
+ */
public Feed( WikiContext context )
{
m_wikiContext = context;
}
+ /**
+ * Set the mode of the Feed. It can be any of the following:
+ * <ul>
+ * <li>[EMAIL PROTECTED] RSSGenerator#MODE_WIKI} - to create a wiki diff
list per page.</li>
+ * <li>[EMAIL PROTECTED] RSSGenerator#MODE_BLOG} - to assume that the
Entries are blog entries.</li>
+ * <li>[EMAIL PROTECTED] RSSGenerator#MODE_FULL} - to create a wiki diff
list for the entire blog.</li>
+ * </ul>
+ * As the Entry list itself is generated elsewhere, this mostly just
affects the way
+ * that the layout and metadata for each entry is generated.
+ *
+ * @param mode As defined in RSSGenerator.
+ */
public void setMode( String mode )
{
m_mode = mode;
}
+ /**
+ * Adds a new Entry to the Feed, at the end of the list.
+ *
+ * @param e The Entry to add.
+ */
public void addEntry( Entry e )
{
m_entries.add( e );
}
+ /**
+ * Returns the XML for the feed contents in a String format. All
subclasses must implement.
+ *
+ * @return valid XML, ready to be shoved out.
+ */
public abstract String getString();
+
/**
* @return Returns the m_channelDescription.
*/
@@ -119,6 +146,13 @@
m_feedURL = feedurl;
}
+ /**
+ * A helper method for figuring out the MIME type for an enclosure.
+ *
+ * @param c A ServletContext
+ * @param name The filename
+ * @return Something sane for a MIME type.
+ */
protected String getMimeType(ServletContext c, String name)
{
String type = c.getMimeType(name);
@@ -130,7 +164,11 @@
/**
* Does the required formatting and entity replacement for XML.
+ *
+ * @param s The String to format. Null is safe.
+ * @return A formatted string.
*/
+ // FIXME: Should probably be replaced by a library method.
public static String format( String s )
{
if( s != null )
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/RSS10Feed.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/RSS10Feed.java?rev=661811&r1=661810&r2=661811&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/RSS10Feed.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/RSS10Feed.java Fri May 30
11:40:39 2008
@@ -31,12 +31,17 @@
import com.ecyrd.jspwiki.WikiPage;
/**
- * Provides an implementation of an RSS 1.0 feed.
- *
- * @since
+ * Provides an implementation of an RSS 1.0 feed. In addition, this class is
+ * capable of adding RSS 1.0 Wiki Extensions to the Feed, as defined in
+ * <A HREF="http://usemod.com/cgi-bin/mb.pl?ModWiki">UseMod:ModWiki</A>.
*/
public class RSS10Feed extends Feed
{
+ /**
+ * Create an RSS 1.0 feed for a given context.
+ *
+ * @param context [EMAIL PROTECTED]
+ */
public RSS10Feed( WikiContext context )
{
super(context);
@@ -182,9 +187,10 @@
return channel;
}
- /* (non-Javadoc)
- * @see com.ecyrd.jspwiki.rss.Feed#getString()
+ /**
+ * [EMAIL PROTECTED]
*/
+ @Override
public String getString()
{
XML root = new XML("rdf:RDF");
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/RSS20Feed.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/RSS20Feed.java?rev=661811&r1=661810&r2=661811&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/RSS20Feed.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/RSS20Feed.java Fri May 30
11:40:39 2008
@@ -39,14 +39,18 @@
import com.ecyrd.jspwiki.providers.ProviderException;
/**
- * Represents an RSS 2.0 feed (with enclosures).
- *
+ * Represents an RSS 2.0 feed (with enclosures). This feed provides no
+ * fizz-bang features.
*
* @since 2.2.27
*/
public class RSS20Feed extends Feed
{
-
+ /**
+ * Creates an RSS 2.0 feed for the specified Context.
+ *
+ * @param context The WikiContext.
+ */
public RSS20Feed( WikiContext context )
{
super( context );
@@ -54,7 +58,7 @@
private List getItems()
{
- ArrayList list = new ArrayList();
+ ArrayList<Element> list = new ArrayList<Element>();
SimpleDateFormat fmt = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss
'GMT'");
WikiEngine engine = m_wikiContext.getEngine();
@@ -123,6 +127,10 @@
return list;
}
+ /**
+ * [EMAIL PROTECTED]
+ */
+ @Override
public String getString()
{
WikiEngine engine = m_wikiContext.getEngine();
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/RSSGenerator.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/RSSGenerator.java?rev=661811&r1=661810&r2=661811&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/RSSGenerator.java
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/RSSGenerator.java Fri May
30 11:40:39 2008
@@ -30,14 +30,22 @@
import com.ecyrd.jspwiki.providers.ProviderException;
/**
- * Generates an RSS feed from the recent changes.
- * <P>
- * We use the 1.0 spec, including the wiki-specific extensions. Wiki
extensions
- * have been defined in <A
HREF="http://usemod.com/cgi-bin/mb.pl?ModWiki">UseMod:ModWiki</A>.
+ * The master class for generating different kinds of Feeds (including
RSS1.0, 2.0 and Atom).
+ * <p>
+ * This class can produce quite a few different styles of feeds. The
following modes are
+ * available:
+ *
+ * <ul>
+ * <li><b>wiki</b> - All the changes to the given page are enumerated and
announced as diffs.</li>
+ * <li><b>full</b> - Each page is only considered once. This produces a very
RecentChanges-style feed,
+ * where each page is only listed once, even if it has
changed multiple times.</li>
+ * <li><b>blog</b> - Each page change is assumed to be a blog entry, so no
diffs are produced, but
+ * the page content is always completely in the entry in
rendered HTML.</li>
*
* @since 1.7.5.
*/
// FIXME: Limit diff and page content size.
+// FIXME3.0: This class would need a bit of refactoring. Method names, e.g.
are confusing.
public class RSSGenerator
{
static Logger log = Logger.getLogger( RSSGenerator.class );
@@ -47,12 +55,34 @@
private String m_channelLanguage = "en-us";
private boolean m_enabled = true;
+ /**
+ * Parameter value to represent RSS 1.0 feeds. Value is <tt>[EMAIL
PROTECTED]</tt>.
+ */
public static final String RSS10 = "rss10";
+
+ /**
+ * Parameter value to represent RSS 2.0 feeds. Value is <tt>[EMAIL
PROTECTED]</tt>.
+ */
public static final String RSS20 = "rss20";
+
+ /**
+ * Parameter value to represent Atom feeds. Value is <tt>[EMAIL
PROTECTED]</tt>.
+ */
public static final String ATOM = "atom";
+ /**
+ * Parameter value to represent a 'blog' style feed. Value is <tt>[EMAIL
PROTECTED]</tt>.
+ */
public static final String MODE_BLOG = "blog";
+
+ /**
+ * Parameter value to represent a 'wiki' style feed. Value is <tt>[EMAIL
PROTECTED]</tt>.
+ */
public static final String MODE_WIKI = "wiki";
+
+ /**
+ * Parameter value to represent a 'full' style feed. Value is <tt>[EMAIL
PROTECTED]</tt>.
+ */
public static final String MODE_FULL = "full";
/**
@@ -69,6 +99,9 @@
*/
public static final String PROP_CHANNEL_LANGUAGE =
"jspwiki.rss.channelLanguage";
+ /**
+ * Defins the property name for the RSS channel title. Value is
<tt>[EMAIL PROTECTED]</tt>.
+ */
public static final String PROP_CHANNEL_TITLE =
"jspwiki.rss.channelTitle";
/**
@@ -83,23 +116,43 @@
*/
public static final String PROP_RSSFILE =
"jspwiki.rss.fileName";
- public static final String PROP_RSSAUTHOR = "jspwiki.rss.author";
- public static final String PROP_RSSAUTHOREMAIL =
"jspwiki.rss.author.email";
-
/**
* Defines the property name for the RSS generation interval in seconds.
* @since 1.7.6.
*/
public static final String PROP_INTERVAL =
"jspwiki.rss.interval";
+ /**
+ * Defines the property name for the RSS author. Value is <tt>[EMAIL
PROTECTED]</tt>.
+ */
public static final String PROP_RSS_AUTHOR = "jspwiki.rss.author";
+
+ /**
+ * Defines the property name for the RSS author email. Value is
<tt>[EMAIL PROTECTED]</tt>.
+ */
public static final String PROP_RSS_AUTHOREMAIL =
"jspwiki.rss.author.email";
+
+ /**
+ * Property name for the RSS copyright info. Value is <tt>[EMAIL
PROTECTED]</tt>.
+ */
public static final String PROP_RSS_COPYRIGHT =
"jspwiki.rss.copyright";
+ /** Just for compatibilty. [EMAIL PROTECTED] */
+ public static final String PROP_RSSAUTHOR = PROP_RSS_AUTHOR;
+
+ /** Just for compatibilty. [EMAIL PROTECTED] */
+ public static final String PROP_RSSAUTHOREMAIL = PROP_RSS_AUTHOREMAIL;
+
+
private static final int MAX_CHARACTERS = Integer.MAX_VALUE-1;
/**
- * Initialize the RSS generator.
+ * Initialize the RSS generator for a given WikiEngine. Currently the
only
+ * required property is <tt>[EMAIL PROTECTED]
com.ecyrd.jspwiki.WikiEngine#PROP_BASEURL}</tt>.
+ *
+ * @param engine The WikiEngine.
+ * @param properties The properties.
+ * @throws NoRequiredPropertyException If something is missing from the
given property set.
*/
public RSSGenerator( WikiEngine engine, Properties properties )
throws NoRequiredPropertyException
@@ -121,7 +174,11 @@
/**
* Does the required formatting and entity replacement for XML.
+ *
+ * @param s String to format.
+ * @return A formatted string.
*/
+ // FIXME: Replicates Feed.format().
public static String format( String s )
{
s = TextUtil.replaceString( s, "&", "&" );
@@ -214,6 +271,8 @@
/**
* Generates the RSS resource. You probably want to output this
* result into a file or something, or serve as output from a servlet.
+ *
+ * @return A RSS 1.0 feed in the "full" mode.
*/
public String generate()
{
@@ -260,7 +319,7 @@
* @throws IllegalArgumentException If an illegal mode is given.
*/
public String generateFeed( WikiContext wikiContext, List changed, String
mode, String type )
- throws ProviderException
+ throws ProviderException, IllegalArgumentException
{
Feed feed = null;
String res = null;
@@ -324,6 +383,10 @@
/**
* Generates an RSS feed for the entire wiki. Each item should be an
instance of the RSSItem class.
+ *
+ * @param wikiContext A WikiContext
+ * @param feed A Feed to generate the feed to.
+ * @return feed.getString().
*/
protected String generateFullWikiRSS( WikiContext wikiContext, Feed feed )
{
@@ -386,9 +449,9 @@
/**
* Create RSS/Atom as if this page was a wikipage (in contrast to Blog
mode).
*
- * @param wikiContext
- * @param changed
- * @param feed
+ * @param wikiContext The WikiContext
+ * @param changed A List of changed WikiPages.
+ * @param feed A Feed object to fill.
* @return the RSS representation of the wiki context
*/
protected String generateWikiPageRSS( WikiContext wikiContext, List
changed, Feed feed )
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/RSSThread.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/RSSThread.java?rev=661811&r1=661810&r2=661811&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/RSSThread.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/rss/RSSThread.java Fri May 30
11:40:39 2008
@@ -53,6 +53,13 @@
private WatchDog m_watchdog;
+ /**
+ * Create a new RSS thread.
+ *
+ * @param engine A WikiEngine to own this thread.
+ * @param rssFile A File to write the RSS data to.
+ * @param rssInterval How often the RSS should be generated.
+ */
public RSSThread( WikiEngine engine, File rssFile, int rssInterval )
{
super( engine, rssInterval );
@@ -64,6 +71,10 @@
log.debug( "RSS refresh interval (seconds): "+m_rssInterval );
}
+ /**
+ * [EMAIL PROTECTED]
+ */
+ @Override
public void startupTask() throws Exception
{
m_watchdog = getEngine().getCurrentWatchDog();
@@ -75,7 +86,9 @@
* file I/O or other error, this method will turn off generation.
* <code>false</code>.
* @see java.lang.Thread#run()
+ * @throws Exception All exceptions are thrown upwards.
*/
+ @Override
public void backgroundTask() throws Exception
{
if ( m_generator.isEnabled() )
Modified:
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/search/LuceneSearchProvider.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/search/LuceneSearchProvider.java?rev=661811&r1=661810&r2=661811&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/search/LuceneSearchProvider.java
(original)
+++
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/search/LuceneSearchProvider.java
Fri May 30 11:40:39 2008
@@ -92,7 +92,7 @@
private String m_luceneDirectory = null;
private int m_updateCount = 0;
- protected Vector m_updates = new Vector(); // Vector because
multi-threaded.
+ protected Vector<Object[]> m_updates = new Vector<Object[]>(); // Vector
because multi-threaded.
/** Maximum number of fragments from search matches. */
private static final int MAX_FRAGMENTS = 3;
@@ -273,6 +273,11 @@
/**
* Fetches the attachment content from the repository.
* Content is flat text that can be used for indexing/searching or display
+ *
+ * @param attachmentName Name of the attachment.
+ * @param version The version of the attachment.
+ *
+ * @return the content of the Attachment as a String.
*/
protected String getAttachmentContent( String attachmentName, int version )
{
@@ -550,7 +555,7 @@
throws ProviderException
{
Searcher searcher = null;
- ArrayList list = null;
+ ArrayList<SearchResult> list = null;
Highlighter highlighter = null;
try
@@ -580,7 +585,7 @@
Hits hits = searcher.search(luceneQuery);
- list = new ArrayList(hits.length());
+ list = new ArrayList<SearchResult>(hits.length());
for ( int curr = 0; curr < hits.length(); curr++ )
{
Document doc = hits.doc(curr);
@@ -611,7 +616,8 @@
}
- SearchResult result = new SearchResultImpl( page, score,
fragments ); list.add(result);
+ SearchResult result = new SearchResultImpl( page, score,
fragments );
+ list.add(result);
}
else
{
@@ -715,7 +721,7 @@
{
while( m_provider.m_updates.size() > 0 )
{
- Object[] pair = ( Object[] )
m_provider.m_updates.remove(0);
+ Object[] pair = m_provider.m_updates.remove(0);
WikiPage page = ( WikiPage ) pair[0];
String text = ( String ) pair[1];
m_provider.updateLuceneIndex(page, text);
Modified:
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/search/SearchManager.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/search/SearchManager.java?rev=661811&r1=661810&r2=661811&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/search/SearchManager.java
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/search/SearchManager.java Fri
May 30 11:40:39 2008
@@ -54,13 +54,29 @@
private static final Logger log = Logger.getLogger(SearchManager.class);
private static final String DEFAULT_SEARCHPROVIDER =
"com.ecyrd.jspwiki.search.LuceneSearchProvider";
- public static final String PROP_USE_LUCENE = "jspwiki.useLucene";
+
+ /** Old option, now deprecated. */
+ private static final String PROP_USE_LUCENE = "jspwiki.useLucene";
+
+ /**
+ * Property name for setting the search provider. Value is <tt>[EMAIL
PROTECTED]</tt>.
+ */
public static final String PROP_SEARCHPROVIDER =
"jspwiki.searchProvider";
private SearchProvider m_searchProvider = null;
+ /**
+ * The name of the JSON object that manages search.
+ */
public static final String JSON_SEARCH = "search";
+ /**
+ * Creates a new SearchManager.
+ *
+ * @param engine The WikiEngine that owns this SearchManager.
+ * @param properties The list of Properties.
+ * @throws WikiException If it cannot be instantiated.
+ */
public SearchManager( WikiEngine engine, Properties properties )
throws WikiException
{
@@ -90,7 +106,7 @@
{
StopWatch sw = new StopWatch();
sw.start();
- List list = new ArrayList(maxLength);
+ List<String> list = new ArrayList<String>(maxLength);
if( wikiName.length() > 0 )
{
@@ -131,7 +147,7 @@
StopWatch sw = new StopWatch();
sw.start();
- List list = new ArrayList(maxLength);
+ List<HashMap> list = new ArrayList<HashMap>(maxLength);
if( searchString.length() > 0 )
{
@@ -148,7 +164,7 @@
for( Iterator i = c.iterator(); i.hasNext() && count <
maxLength; count++ )
{
SearchResult sr = (SearchResult)i.next();
- HashMap hm = new HashMap();
+ HashMap<String,Object> hm = new
HashMap<String,Object>();
hm.put( "page", sr.getPage().getName() );
hm.put( "score", new Integer(sr.getScore()) );
list.add( hm );
@@ -251,6 +267,11 @@
log.debug("Loaded search provider " + m_searchProvider);
}
+ /**
+ * Returns the SearchProvider used.
+ *
+ * @return The current SearchProvider.
+ */
public SearchProvider getSearchEngine()
{
return m_searchProvider;
@@ -262,6 +283,8 @@
*
* @param query The query. Null is safe, and is interpreted as an empty
query.
* @return A collection of WikiPages that matched.
+ * @throws ProviderException If the provider fails and a search cannot be
completed.
+ * @throws IOException If something else goes wrong.
*/
public Collection findPages( String query )
throws ProviderException, IOException
@@ -281,6 +304,13 @@
m_searchProvider.pageRemoved(page);
}
+ /**
+ * Reindexes the page.
+ *
+ * @param wikiContext [EMAIL PROTECTED]
+ * @param content [EMAIL PROTECTED]
+ */
+ @Override
public void postSave( WikiContext wikiContext, String content )
{
//
@@ -294,13 +324,18 @@
/**
* Forces the reindex of the given page.
*
- * @param page
+ * @param page The page.
*/
public void reindexPage(WikiPage page)
{
m_searchProvider.reindexPage(page);
}
+ /**
+ * If the page has been deleted, removes it from the index.
+ *
+ * @param event [EMAIL PROTECTED]
+ */
public void actionPerformed(WikiEvent event)
{
if( (event instanceof WikiPageEvent) && (event.getType() ==
WikiPageEvent.PAGE_DELETE_REQUEST) )