org.blojsom.plugin.comment
Class MathCommentAuthenticationPlugin

java.lang.Object
  extended byorg.blojsom.plugin.comment.CommentModerationPlugin
      extended byorg.blojsom.plugin.comment.MathCommentAuthenticationPlugin
All Implemented Interfaces:
Listener, Plugin

public class MathCommentAuthenticationPlugin
extends CommentModerationPlugin
implements Listener

Math comment authenticator plugin

Since:
blojsom 3.0
Version:
$Id: MathCommentAuthenticationPlugin.java,v 1.5 2007/01/17 02:35:08 czarneckid Exp $
Author:
David Czarnecki

Field Summary
static java.lang.String BLOJSOM_MATH_AUTHENTICATOR_PLUGIN_ANSWER
           
static java.lang.String BLOJSOM_MATH_AUTHENTICATOR_PLUGIN_ANSWER_CHECK_PARAM
           
static java.lang.String BLOJSOM_MATH_AUTHENTICATOR_PLUGIN_OPERATION
           
static java.lang.String BLOJSOM_MATH_AUTHENTICATOR_PLUGIN_STATUS_MESSAGE
           
static java.lang.String BLOJSOM_MATH_AUTHENTICATOR_PLUGIN_VALUE1
           
static java.lang.String BLOJSOM_MATH_AUTHENTICATOR_PLUGIN_VALUE2
           
 
Fields inherited from class org.blojsom.plugin.comment.CommentModerationPlugin
BLOJSOM_COMMENT_MODERATION_PLUGIN_APPROVED, COMMENT_MODERATION_ENABLED
 
Constructor Summary
MathCommentAuthenticationPlugin()
          Math comment authenticator plugin
 
Method Summary
protected  int getAnswerForOperation(int value1, int value2, int operation)
          Return the result from the specified operation where 0 = addition, 1 = subtraction, 2 = multiplication
protected  java.lang.String getOperatorForOperation(int operation)
          Return the appropriate operator for the operation
 void handleEvent(Event event)
          Handle an event broadcast from another component
 void init()
          Initialize this plugin.
protected  void moderateComment(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, Blog blog, java.util.Map context, Entry[] entries)
          Simple check to see if comment moderation is enabled

 Entry[] process(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, Blog blog, java.util.Map context, Entry[] entries)
          Process the blog entries
 void processEvent(Event event)
          Process an event from another component
 void setEventBroadcaster(EventBroadcaster eventBroadcaster)
          Set the EventBroadcaster to use
 
Methods inherited from class org.blojsom.plugin.comment.CommentModerationPlugin
cleanup, destroy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLOJSOM_MATH_AUTHENTICATOR_PLUGIN_ANSWER

public static final java.lang.String BLOJSOM_MATH_AUTHENTICATOR_PLUGIN_ANSWER
See Also:
Constant Field Values

BLOJSOM_MATH_AUTHENTICATOR_PLUGIN_VALUE1

public static final java.lang.String BLOJSOM_MATH_AUTHENTICATOR_PLUGIN_VALUE1
See Also:
Constant Field Values

BLOJSOM_MATH_AUTHENTICATOR_PLUGIN_VALUE2

public static final java.lang.String BLOJSOM_MATH_AUTHENTICATOR_PLUGIN_VALUE2
See Also:
Constant Field Values

BLOJSOM_MATH_AUTHENTICATOR_PLUGIN_OPERATION

public static final java.lang.String BLOJSOM_MATH_AUTHENTICATOR_PLUGIN_OPERATION
See Also:
Constant Field Values

BLOJSOM_MATH_AUTHENTICATOR_PLUGIN_ANSWER_CHECK_PARAM

public static final java.lang.String BLOJSOM_MATH_AUTHENTICATOR_PLUGIN_ANSWER_CHECK_PARAM
See Also:
Constant Field Values

BLOJSOM_MATH_AUTHENTICATOR_PLUGIN_STATUS_MESSAGE

public static final java.lang.String BLOJSOM_MATH_AUTHENTICATOR_PLUGIN_STATUS_MESSAGE
See Also:
Constant Field Values
Constructor Detail

MathCommentAuthenticationPlugin

public MathCommentAuthenticationPlugin()
Math comment authenticator plugin

Method Detail

setEventBroadcaster

public void setEventBroadcaster(EventBroadcaster eventBroadcaster)
Set the EventBroadcaster to use

Parameters:
eventBroadcaster - EventBroadcaster

init

public void init()
          throws PluginException
Initialize this plugin. This method only called when the plugin is instantiated.

Specified by:
init in interface Plugin
Overrides:
init in class CommentModerationPlugin
Throws:
PluginException - If there is an error initializing the plugin

process

public Entry[] process(javax.servlet.http.HttpServletRequest httpServletRequest,
                       javax.servlet.http.HttpServletResponse httpServletResponse,
                       Blog blog,
                       java.util.Map context,
                       Entry[] entries)
                throws PluginException
Process the blog entries

Specified by:
process in interface Plugin
Overrides:
process in class CommentModerationPlugin
Parameters:
httpServletRequest - Request
httpServletResponse - Response
blog - Blog instance
context - Context
entries - Blog entries retrieved for the particular request
Returns:
Modified set of blog entries
Throws:
PluginException - If there is an error processing the blog entries

moderateComment

protected void moderateComment(javax.servlet.http.HttpServletRequest httpServletRequest,
                               javax.servlet.http.HttpServletResponse httpServletResponse,
                               Blog blog,
                               java.util.Map context,
                               Entry[] entries)
                        throws PluginException
Simple check to see if comment moderation is enabled

Overrides:
moderateComment in class CommentModerationPlugin
Parameters:
httpServletRequest - Request
httpServletResponse - Response
blog - Blog instance
context - Context
entries - Blog entries retrieved for the particular request
Throws:
PluginException - If there is an error in moderating a comment

getAnswerForOperation

protected int getAnswerForOperation(int value1,
                                    int value2,
                                    int operation)
Return the result from the specified operation where 0 = addition, 1 = subtraction, 2 = multiplication

Parameters:
value1 - Value 1
value2 - Value 2
operation - Operation where 0 = addition, 1 = subtraction, 2 = multiplication
Returns:
Value of operation

getOperatorForOperation

protected java.lang.String getOperatorForOperation(int operation)
Return the appropriate operator for the operation

Parameters:
operation - Operation where 0 = addition, 1 = subtraction, 2 = multiplication
Returns:
+ for addition, - for subtraction, and * for multiplication

handleEvent

public void handleEvent(Event event)
Handle an event broadcast from another component

Specified by:
handleEvent in interface Listener
Parameters:
event - Event to be handled

processEvent

public void processEvent(Event event)
Process an event from another component

Specified by:
processEvent in interface Listener
Parameters:
event - Event to be handled