Author: jalkanen
Date: Sun May 25 04:45:51 2008
New Revision: 659967

URL: http://svn.apache.org/viewvc?rev=659967&view=rev
Log:
Javadoc, Java5, checkstyle, and comment fixes.

Added:
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/package.html
Modified:
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/BasicPageFilter.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/CreoleFilter.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/FilterException.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/FilterManager.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/PageFilter.java
    
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/PingWeblogsComFilter.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/ProfanityFilter.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/RedirectException.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/SpamFilter.java

Modified: 
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/BasicPageFilter.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/BasicPageFilter.java?rev=659967&r1=659966&r2=659967&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/BasicPageFilter.java 
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/BasicPageFilter.java 
Sun May 25 04:45:51 2008
@@ -38,6 +38,8 @@
   
     /**
      *  If you override this, you should call super.initialize() first.
+     *  
+     *  [EMAIL PROTECTED]
      */
     public void initialize( WikiEngine engine, Properties properties )
         throws FilterException
@@ -45,29 +47,44 @@
         m_engine = engine;
     }
 
+    /**
+     *  [EMAIL PROTECTED]
+     */
     public String preTranslate( WikiContext wikiContext, String content )
         throws FilterException
     {
         return content;
     }
 
+    /**
+     *  [EMAIL PROTECTED]
+     */
     public String postTranslate( WikiContext wikiContext, String htmlContent )
         throws FilterException
     {
         return htmlContent;
     }
 
+    /**
+     *  [EMAIL PROTECTED]
+     */
     public String preSave( WikiContext wikiContext, String content )
         throws FilterException
     {
         return content;
     }
 
+    /**
+     *  [EMAIL PROTECTED]
+     */
     public void postSave( WikiContext wikiContext, String content )
         throws FilterException
     {
     }
     
+    /**
+     *  [EMAIL PROTECTED]
+     */
     public void destroy( WikiEngine engine ) 
     {
     }

Modified: 
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/CreoleFilter.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/CreoleFilter.java?rev=659967&r1=659966&r2=659967&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/CreoleFilter.java 
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/CreoleFilter.java Sun 
May 25 04:45:51 2008
@@ -104,4 +104,4 @@
         }
     }
 
-}
\ No newline at end of file
+}

Modified: 
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/FilterException.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/FilterException.java?rev=659967&r1=659966&r2=659967&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/FilterException.java 
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/FilterException.java 
Sun May 25 04:45:51 2008
@@ -32,6 +32,11 @@
 {
     private static final long serialVersionUID = 0L;
     
+    /**
+     *  Constructs an exception.
+     *  
+     *  @param msg [EMAIL PROTECTED]
+     */
     public FilterException( String msg )
     {
         super( msg );

Modified: 
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/FilterManager.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/FilterManager.java?rev=659967&r1=659966&r2=659967&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/FilterManager.java 
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/FilterManager.java 
Sun May 25 04:45:51 2008
@@ -93,14 +93,16 @@
  */
 public final class FilterManager extends ModuleManager
 {
-    private PriorityList     m_pageFilters = new PriorityList();
+    private PriorityList    m_pageFilters = new PriorityList();
 
-    private HashMap          m_filterClassMap = new HashMap();
+    private HashMap<String, PageFilterInfo>          m_filterClassMap = new 
HashMap<String,PageFilterInfo>();
 
     private static final Logger log = Logger.getLogger(WikiEngine.class);
 
+    /** Property name for setting the filter XML property file.  Value is 
<tt>[EMAIL PROTECTED]</tt>. */
     public static final String PROP_FILTERXML = "jspwiki.filterConfig";
     
+    /** Default location for the filter XML property file.  Value is 
<tt>[EMAIL PROTECTED]</tt>. */
     public static final String DEFAULT_XMLFILE = "/WEB-INF/filters.xml";
 
     /** JSPWiki system filters are all below this value. */
@@ -109,6 +111,13 @@
     /** The standard user level filtering. */
     public static final int USER_FILTER_PRIORITY   = 0;
     
+    /**
+     *  Constructs a new FilterManager object.
+     *  
+     *  @param engine The WikiEngine which owns the FilterManager
+     *  @param props Properties to initialize the FilterManager with
+     *  @throws WikiException If something goes wrong.
+     */
     public FilterManager( WikiEngine engine, Properties props )
         throws WikiException
     {
@@ -129,7 +138,7 @@
      *  @param priority The priority in which position to add it in.
      *  @throws IllegalArgumentException If the PageFilter is null or invalid.
      */
-    public void addPageFilter( PageFilter f, int priority )
+    public void addPageFilter( PageFilter f, int priority ) throws 
IllegalArgumentException
     {
         if( f == null )
         {
@@ -143,7 +152,7 @@
     {
         try
         {
-            PageFilterInfo info = (PageFilterInfo)m_filterClassMap.get( 
className );
+            PageFilterInfo info = m_filterClassMap.get( className );
             
             if( info != null && !checkCompatibility(info) )
             {
@@ -189,6 +198,9 @@
 
     /**
      *  Initializes the filters from an XML file.
+     *  
+     *  @param props The list of properties.  Typically jspwiki.properties
+     *  @throws WikiException If something goes wrong.
      */
     protected void initialize( Properties props )
         throws WikiException
@@ -200,36 +212,36 @@
         {
             registerFilters();
             
-                       if( m_engine.getServletContext() != null )
-                       {
-                               log.debug("Attempting to locate 
"+DEFAULT_XMLFILE+" from servlet context.");
-                               if( xmlFile == null )
-                               {
-                                       xmlStream = 
m_engine.getServletContext().getResourceAsStream( DEFAULT_XMLFILE );
-                               }
-                               else
-                               {
-                                       xmlStream = 
m_engine.getServletContext().getResourceAsStream( xmlFile );
-                               }
-                       }
-
-                       if( xmlStream == null )
-                       {
-                               //just a fallback element to the old behaviour 
prior to 2.5.8
-                               log.debug("Attempting to locate filters.xml 
from class path.");
-
-                               if( xmlFile == null )
-                               {
-                                       xmlStream = 
getClass().getResourceAsStream( "/filters.xml" );
-                               }
-                               else
-                               {
-                                       xmlStream = 
getClass().getResourceAsStream( xmlFile );
-                               }
-                       }
+            if( m_engine.getServletContext() != null )
+            {
+                log.debug( "Attempting to locate " + DEFAULT_XMLFILE + " from 
servlet context." );
+                if( xmlFile == null )
+                {
+                    xmlStream = 
m_engine.getServletContext().getResourceAsStream( DEFAULT_XMLFILE );
+                }
+                else
+                {
+                    xmlStream = 
m_engine.getServletContext().getResourceAsStream( xmlFile );
+                }
+            }
+
+            if( xmlStream == null )
+            {
+                // just a fallback element to the old behaviour prior to 2.5.8
+                log.debug( "Attempting to locate filters.xml from class path." 
);
+
+                if( xmlFile == null )
+                {
+                    xmlStream = getClass().getResourceAsStream( "/filters.xml" 
);
+                }
+                else
+                {
+                    xmlStream = getClass().getResourceAsStream( xmlFile );
+                }
+            }
 
-                       if( (xmlStream == null) && (xmlFile != null) )
-                       {
+            if( (xmlStream == null) && (xmlFile != null) )
+            {
                 log.debug("Attempting to load property file "+xmlFile);
                 xmlStream = new FileInputStream( new File(xmlFile) );
             }
@@ -294,6 +306,13 @@
  
     /**
      *  Does the filtering before a translation.
+     *  
+     *  @param context The WikiContext
+     *  @param pageData WikiMarkup data to be passed through the preTranslate 
chain.
+     *  @throws FilterException If any of the filters throws a FilterException
+     *  @return The modified WikiMarkup
+     *  
+     *  @see PageFilter#preTranslate(WikiContext, String)
      */
     public String doPreTranslateFiltering( WikiContext context, String 
pageData )
         throws FilterException
@@ -314,8 +333,14 @@
 
     /**
      *  Does the filtering after HTML translation.
+     *  
+     *  @param context The WikiContext
+     *  @param htmlData HTML data to be passed through the postTranslate
+     *  @throws FilterException If any of the filters throws a FilterException
+     *  @return The modified HTML
+     *  @see PageFilter#postTranslate(WikiContext, String)
      */
-    public String doPostTranslateFiltering( WikiContext context, String 
pageData )
+    public String doPostTranslateFiltering( WikiContext context, String 
htmlData )
         throws FilterException
     {
         fireEvent( WikiPageEvent.POST_TRANSLATE_BEGIN, context );
@@ -324,16 +349,22 @@
         {
             PageFilter f = (PageFilter) i.next();
 
-            pageData = f.postTranslate( context, pageData );
+            htmlData = f.postTranslate( context, htmlData );
         }
 
         fireEvent( WikiPageEvent.POST_TRANSLATE_END, context );
 
-        return pageData;
+        return htmlData;
     }
 
     /**
      *  Does the filtering before a save to the page repository.
+     *  
+     *  @param context The WikiContext
+     *  @param pageData WikiMarkup data to be passed through the preSave chain.
+     *  @throws FilterException If any of the filters throws a FilterException
+     *  @return The modified WikiMarkup
+     *  @see PageFilter#preSave(WikiContext, String)
      */
     public String doPreSaveFiltering( WikiContext context, String pageData )
         throws FilterException
@@ -354,6 +385,12 @@
 
     /**
      *  Does the page filtering after the page has been saved.
+     * 
+     *  @param context The WikiContext
+     *  @param pageData WikiMarkup data to be passed through the postSave 
chain.
+     *  @throws FilterException If any of the filters throws a FilterException
+     * 
+     *  @see PageFilter#postSave(WikiContext, String)
      */
     public void doPostSaveFiltering( WikiContext context, String pageData )
         throws FilterException
@@ -371,6 +408,12 @@
         fireEvent( WikiPageEvent.POST_SAVE_END, context );
     }
 
+    /**
+     *  Returns the list of filters currently installed.  Note that this is not
+     *  a copy, but the actual list.  So be careful with it.
+     *  
+     *  @return A List of PageFilter objects
+     */
     public List getFilterList()
     {
         return m_pageFilters;
@@ -410,6 +453,10 @@
         }
     }
 
+    /**
+     *  [EMAIL PROTECTED]
+     */
+    @SuppressWarnings("unchecked")
     public Collection modules()
     {
         ArrayList modules = new ArrayList();

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/PageFilter.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/PageFilter.java?rev=659967&r1=659966&r2=659967&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/PageFilter.java 
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/PageFilter.java Sun 
May 25 04:45:51 2008
@@ -40,7 +40,7 @@
  *  per each WikiEngine invocation.  If you need to store data persistently, 
use
  *  VariableManager, or WikiContext.
  *  <p>
- *  As of 2.5.30, initialize() gains accesso to the WikiEngine.
+ *  As of 2.5.30, initialize() gains access to the WikiEngine.
  *
  */
 public interface PageFilter
@@ -48,31 +48,52 @@
     /**
      *  Is called whenever the a new PageFilter is instantiated and
      *  reset.
+     *  
+     *  @param engine The WikiEngine whic owns this PageFilter
+     *  @param properties The properties ripped from filters.xml.
+     *  @throws FilterException If the filter could not be initialized. If 
this is thrown,
+     *                          the filter is not added to the internal queues.
      */
     public void initialize( WikiEngine engine, Properties properties )
         throws FilterException;
 
     /**
      *  This method is called whenever a page has been loaded from the 
provider,
-     *  but not yet been sent through the TranslatorReader.  Note that you 
cannot
-     *  do HTML translation here, because TranslatorReader is likely to escape 
it.
+     *  but not yet been sent through the markup-translation process.  Note 
that you cannot
+     *  do HTML translation here, because it will be escaped.
      *
      *  @param wikiContext The current wikicontext.
      *  @param content     WikiMarkup.
+     *  @return The modified wikimarkup content.
+     *  @throws FilterException If something goes wrong.  Throwing this causes 
the entire page
+     *                          processing to be abandoned.
      */
     public String preTranslate( WikiContext wikiContext, String content )
         throws FilterException;
 
     /**
-     *  This method is called after a page has been fed through the 
TranslatorReader,
+     *  This method is called after a page has been fed through the 
translation process,
      *  so anything you are seeing here is translated content.  If you want to
      *  do any of your own WikiMarkup2HTML translation, do it here.
+     *  
+     *  @param wikiContext The WikiContext.
+     *  @param htmlContent The translated HTML
+     *  @return The modified HTML
+     *  
+     *  @throws FilterException If something goes wrong.  Throwing this causes 
the entire page
+     *                          processing to be abandoned.
      */
     public String postTranslate( WikiContext wikiContext, String htmlContent )
         throws FilterException;
 
     /**
      *  This method is called before the page has been saved to the 
PageProvider.
+     *  
+     *  @param wikiContext The WikiContext
+     *  @param content The wikimarkup that the user just wanted to save.
+     *  @return The modified wikimarkup
+     *  @throws FilterException If something goes wrong.  Throwing this causes 
the entire page
+     *                          processing to be abandoned.
      */
     public String preSave( WikiContext wikiContext, String content )
         throws FilterException;
@@ -84,17 +105,22 @@
      *  <p>
      *  Since the result is discarded from this method, this is only useful
      *  for things like counters, etc.
+     *  
+     *  @param wikiContext The WikiContext
+     *  @param content The content which was just stored.
+     *  @throws FilterException If something goes wrong.  As the page is 
already saved,
+     *                          This is just logged.
      */
     public void postSave( WikiContext wikiContext, String content )
         throws FilterException;
 
     /**
-     * Called for every filter, e.g. on wiki eingine shutdown. Use this if you 
have to 
-     * clean up or close global resources you allocated in the initialize() 
method.
+     *  Called for every filter, e.g. on wiki eingine shutdown. Use this if 
you have to 
+     *  clean up or close global resources you allocated in the initialize() 
method.
      * 
-     * @since 2.5.36
+     *  @param engine The WikiEngine which owns this filter.
+     *  @since 2.5.36
      */
     public void destroy( WikiEngine engine );
 
-
-}
\ No newline at end of file
+}

Modified: 
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/PingWeblogsComFilter.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/PingWeblogsComFilter.java?rev=659967&r1=659966&r2=659967&view=diff
==============================================================================
--- 
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/PingWeblogsComFilter.java 
(original)
+++ 
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/PingWeblogsComFilter.java 
Sun May 25 04:45:51 2008
@@ -41,15 +41,24 @@
 {
     static Logger log = Logger.getLogger( PingWeblogsComFilter.class );
 
-    public String m_pingURL;
+    private String m_pingURL;
 
+    /**
+     *  The property name for the URL to ping.  Value is <tt>[EMAIL 
PROTECTED]</tt>.
+     */
     public static final String PROP_PINGURL = "pingurl";
 
+    /**
+     *  [EMAIL PROTECTED]
+     */
     public void initialize( WikiEngine engine, Properties props )
     {
         m_pingURL = props.getProperty( PROP_PINGURL, 
"http://rpc.weblogs.com/RPC2"; );
     }
 
+    /**
+     *  [EMAIL PROTECTED]
+     */
     public void postSave( WikiContext context, String pagecontent )
     {
         String     blogName = context.getPage().getName();
@@ -71,7 +80,7 @@
         try
         {
             XmlRpcClient xmlrpc = new XmlRpcClient(m_pingURL);
-            Vector params = new Vector();
+            Vector<String> params = new Vector<String>();
             params.addElement( "The Butt Ugly Weblog" ); // FIXME: Must be 
settable
             params.addElement( engine.getURL( WikiContext.VIEW, blogName, 
null, true ) );
 

Modified: 
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/ProfanityFilter.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/ProfanityFilter.java?rev=659967&r1=659966&r2=659967&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/ProfanityFilter.java 
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/ProfanityFilter.java 
Sun May 25 04:45:51 2008
@@ -59,17 +59,17 @@
             }
             
             BufferedReader br = new BufferedReader( new InputStreamReader( in 
) );
-            List l_profs = new ArrayList();
+            List<String> profs = new ArrayList<String>();
             
             String str;
             while ( ( str = br.readLine() ) != null ) 
             {
                 if( str.length() > 0 && !str.startsWith( "#" ) )
                 { // allow comments on profanities file
-                    l_profs.add( str );
+                    profs.add( str );
                 }
             }
-            c_profanities = ( String[] )l_profs.toArray( new String[ 
l_profs.size() ] );
+            c_profanities = profs.toArray( new String[0] );
         }
         catch( IOException e )
         {
@@ -81,6 +81,9 @@
         }
     }
 
+    /**
+     *  [EMAIL PROTECTED]
+     */
     public String preTranslate( WikiContext context, String content )
     {
         for( int i = 0; i < c_profanities.length; i++ )

Modified: 
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/RedirectException.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/RedirectException.java?rev=659967&r1=659966&r2=659967&view=diff
==============================================================================
--- 
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/RedirectException.java 
(original)
+++ 
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/RedirectException.java 
Sun May 25 04:45:51 2008
@@ -33,6 +33,12 @@
 
     private final String m_where;
 
+    /**
+     *  Constructs a new RedirectException.
+     *  
+     *  @param msg The message for the exception
+     *  @param redirect The redirect URI.
+     */
     public RedirectException( String msg, String redirect )
     {
         super( msg );
@@ -42,6 +48,8 @@
 
     /**
      *  Get the URI for redirection.
+     *  
+     *  @return The URI given in the constructor.
      */
     public String getRedirect()
     {

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/SpamFilter.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/SpamFilter.java?rev=659967&r1=659966&r2=659967&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/SpamFilter.java 
(original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/SpamFilter.java Sun 
May 25 04:45:51 2008
@@ -63,6 +63,9 @@
  *        and calculates a score for the spam, which is then compared to a 
filter level value.
  *  </ul>
  *
+ *  <p>Please see the default editors/plain.jsp for examples on how the 
SpamFilter integrates
+ *  with the editor system.</p>
+ *  
  *  <p>Changes by admin users are ignored in any case.</p>
  *
  *  @since 2.1.112
@@ -81,19 +84,51 @@
     private static final String REASON_UTF8_TRAP = "UTF8Trap";
 
     private static final String LISTVAR = "spamwords";
+    
+    /** The filter property name for specifying the page which contains the 
list of spamwords.
+     *  Value is <tt>[EMAIL PROTECTED]</tt>. */
     public static final String  PROP_WORDLIST              = "wordlist";
+    
+    /** The filter property name for the page to which you are directed if 
Herb rejects your
+     *  edit.  Value is <tt>[EMAIL PROTECTED]</tt>. */
     public static final String  PROP_ERRORPAGE             = "errorpage";
+    
+    /** The filter property name for specifying how many changes is any given 
IP address
+     *  allowed to do per minute.  Value is <tt>[EMAIL PROTECTED]</tt>.
+     */
     public static final String  PROP_PAGECHANGES           = 
"pagechangesinminute";
+    
+    /** The filter property name for specifying how many similar changes are 
allowed
+     *  before a host is banned.  Value is <tt>[EMAIL PROTECTED]</tt>.
+     */
     public static final String  PROP_SIMILARCHANGES        = "similarchanges";
+    
+    /** The filter property name for specifying how long a host is banned.  
Value is <tt>[EMAIL PROTECTED]</tt>.*/
     public static final String  PROP_BANTIME               = "bantime";
+    
+    /** The filter property name for the attachment containing the blacklist.  
Value is <tt>[EMAIL PROTECTED]</tt>.*/
     public static final String  PROP_BLACKLIST             = "blacklist";
+    
+    /** The filter property name for specifying how many URLs can any given 
edit contain.  
+     *  Value is <tt>[EMAIL PROTECTED]</tt> */
     public static final String  PROP_MAXURLS               = "maxurls";
+    
+    /** The filter property name for specifying the Akismet API-key.  Value is 
<tt>[EMAIL PROTECTED]</tt>. */
     public static final String  PROP_AKISMET_API_KEY       = "akismet-apikey";
+    
+    /** The filter property name for specifying whether authenticated users 
should be ignored. Value is <tt>[EMAIL PROTECTED]</tt>. */
     public static final String  PROP_IGNORE_AUTHENTICATED  = 
"ignoreauthenticated";
+    
+    /** The filter property name for specifying which captcha technology 
should be used. Value is <tt>[EMAIL PROTECTED]</tt>. */
     public static final String  PROP_CAPTCHA               = "captcha";
+    
+    /** The filter property name for specifying which filter strategy should 
be used.  Value is <tt>[EMAIL PROTECTED]</tt>. */
     public static final String  PROP_FILTERSTRATEGY        = "strategy";
 
+    /** The string specifying the "eager" strategy. Value is <tt>[EMAIL 
PROTECTED]</tt>. */
     public static final String  STRATEGY_EAGER             = "eager";
+    
+    /** The string specifying the "score" strategy. Value is <tt>[EMAIL 
PROTECTED]</tt>. */
     public static final String  STRATEGY_SCORE             = "score";
 
     private static final String URL_REGEXP = 
"(http://|https://|mailto:)([A-Za-z0-9_/[EMAIL PROTECTED]&;]+)";
@@ -105,19 +140,19 @@
     private PatternMatcher  m_matcher = new Perl5Matcher();
     private PatternCompiler m_compiler = new Perl5Compiler();
 
-    private Collection      m_spamPatterns = null;
+    private Collection<Pattern> m_spamPatterns = null;
 
     private Date            m_lastRebuild = new Date( 0L );
 
-    static  Logger          spamlog = Logger.getLogger( "SpamLog" );
-    static  Logger          log = Logger.getLogger( SpamFilter.class );
+    private static  Logger  c_spamlog = Logger.getLogger( "SpamLog" );
+    private static  Logger  log = Logger.getLogger( SpamFilter.class );
 
 
-    private Vector          m_temporaryBanList = new Vector();
+    private Vector<Host>    m_temporaryBanList = new Vector<Host>();
 
     private int             m_banTime = 60; // minutes
 
-    private Vector          m_lastModifications = new Vector();
+    private Vector<Host>    m_lastModifications = new Vector<Host>();
 
     /**
      *  How many times a single IP address can change a page per minute?
@@ -151,6 +186,21 @@
 
     private boolean         m_stopAtFirstMatch = true;
 
+    private static String   c_hashName;
+    private static long     c_lastUpdate;
+
+    /** The HASH_DELAY value is a maximum amount of time that an user can keep
+     *  a session open, because after the value has expired, we will invent a 
new
+     *  hash field name.  By default this is [EMAIL PROTECTED] hours, which 
should be ample
+     *  time for someone.
+     */
+    private static final long HASH_DELAY = 24;
+
+
+    /**
+     *  [EMAIL PROTECTED]
+     */
+    @Override
     public void initialize( WikiEngine engine, Properties properties )
     {
         m_forbiddenWordsPage = properties.getProperty( PROP_WORDLIST,
@@ -236,12 +286,12 @@
                 throw new InternalWikiException("Illegal type "+type);
         }
 
-        spamlog.info( reason+" "+source+" "+uid+" "+addr+" \""+page+"\" 
"+message );
+        c_spamlog.info( reason+" "+source+" "+uid+" "+addr+" \""+page+"\" 
"+message );
 
         return uid;
     }
 
-
+    /** [EMAIL PROTECTED] */
     public String preSave( WikiContext context, String content )
         throws RedirectException
     {
@@ -297,9 +347,9 @@
      * @param list
      * @return
      */
-    private Collection parseWordList( WikiPage source, String list )
+    private Collection<Pattern> parseWordList( WikiPage source, String list )
     {
-        ArrayList compiledpatterns = new ArrayList();
+        ArrayList<Pattern> compiledpatterns = new ArrayList<Pattern>();
 
         if( list != null )
         {
@@ -332,9 +382,9 @@
      *  @param list
      *  @return
      */
-    private Collection parseBlacklist( String list )
+    private Collection<Pattern> parseBlacklist( String list )
     {
-        ArrayList compiledpatterns = new ArrayList();
+        ArrayList<Pattern> compiledpatterns = new ArrayList<Pattern>();
 
         if( list != null )
         {
@@ -752,7 +802,7 @@
 
                     FileUtil.copyContents( new InputStreamReader(in,"UTF-8"), 
out );
 
-                    Collection blackList = parseBlacklist( out.toString() );
+                    Collection<Pattern> blackList = parseBlacklist( 
out.toString() );
 
                     log.info("...recognizing additional "+blackList.size()+" 
patterns from blacklist "+m_blacklist);
 
@@ -793,10 +843,8 @@
         if( context.getHttpRequest() != null )
             change += context.getHttpRequest().getRemoteAddr();
 
-        for( Iterator i = m_spamPatterns.iterator(); i.hasNext(); )
+        for( Pattern p : m_spamPatterns )
         {
-            Pattern p = (Pattern) i.next();
-
             // log.debug("Attempting to match page contents with 
"+p.getPattern());
 
             if( m_matcher.contains( change, p ) )
@@ -947,8 +995,9 @@
     /**
      *  Checks whether the UserProfile matches certain checks.
      *
-     *  @param profile
-     *  @return the result of the check
+     *  @param profile The profile to check
+     *  @param context The WikiContext
+     *  @return False, if this userprofile is suspect and should not be 
allowed to be added.
      *  @since 2.6.1
      */
     public boolean isValidUserProfile( WikiContext context, UserProfile 
profile )
@@ -1000,16 +1049,6 @@
      *  @since  2.6
      */
 
-    private static String c_hashName;
-    private static long   c_lastUpdate;
-
-    /** The HASH_DELAY value is a maximum amount of time that an user can keep
-     *  a session open, because after the value has expired, we will invent a 
new
-     *  hash field name.  By default this is [EMAIL PROTECTED] hours, which 
should be ample
-     *  time for someone.
-     */
-    private static final long HASH_DELAY = 24;
-
     public static final String getHashFieldName( HttpServletRequest request )
     {
         String hash = null;
@@ -1046,8 +1085,8 @@
      *  and logs the incident in the spam log (it may or may not be spam, but 
it's rather likely
      *  that it is).
      *
-     *  @param context
-     *  @param pageContext
+     *  @param context The WikiContext
+     *  @param pageContext The JSP PageContext.
      *  @return True, if hash is okay.  False, if hash is not okay, and you 
need to redirect.
      *  @throws IOException If redirection fails
      *  @since 2.6
@@ -1075,6 +1114,14 @@
         return true;
     }
 
+    /**
+     *  This helper method adds all the input fields to your editor that the 
SpamFilter requires
+     *  to check for spam.  This <i>must</i> be in your editor form if you 
intend to use
+     *  the SpamFilter.
+     *  
+     *  @param pageContext The PageContext
+     *  @return A HTML string which contains input fields for the SpamFilter.
+     */
     public static final String insertInputFields( PageContext pageContext )
     {
         WikiContext ctx = WikiContext.findContext(pageContext);

Added: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/package.html
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/package.html?rev=659967&view=auto
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/package.html (added)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/filters/package.html Sun May 
25 04:45:51 2008
@@ -0,0 +1,16 @@
+<body>
+Provides page and content filtering functionality for JSPWiki.
+
+<h2>Package specification</h2>
+
+<p>PageFilters are objects which can influence the way a page is translated 
from 
+WikiMarkup to HTML, or change the content when the page is saved.  They're 
fairly
+versatile, and you can do lots of interesting stuff with them, ranging from
+adding your own WikiMarkup rules to purifying your HTML to making a spam 
filter to
+counting popularity of pages.</p>
+
+<h2>Related documentation</h2>
+
+TBD.
+
+</body>
\ No newline at end of file


Reply via email to