Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.forum.interceptor
Class GovernorInterceptor

java.lang.Object
  extended by com.jivesoftware.forum.interceptor.GovernorInterceptor
All Implemented Interfaces:
MessageInterceptor

public class GovernorInterceptor
extends java.lang.Object
implements MessageInterceptor

Provides a mechanism to limit the rate at which a user may post messages -- in effect, a governor on postings. If a user attempts to post a message more often than the specified post interval, the message will be rejected. Note that the check is only done on the local cluster member so it's assumed that sticky load balancing is being used.


Field Summary
 
Fields inherited from interface com.jivesoftware.forum.MessageInterceptor
TYPE_ALL, TYPE_BOTH, TYPE_EDIT, TYPE_POST, TYPE_PRE
 
Constructor Summary
GovernorInterceptor()
           
GovernorInterceptor(int objectType, long objectID)
          Creates a new instance of the class.
 
Method Summary
 int getPostInterval()
          Returns the number of seconds that must elapse before a user is allowed to post each new message.
 java.lang.String getRejectionMessage()
          Returns the rejection message that will be returned if a user attempts to make multiple posts within the post interval.
 int getType()
          Returns the type of the interceptor.
 void invokeInterceptor(ForumMessage message, int type)
          Invokes the interceptor on the specified message.
 void setPostInterval(int postInterval)
          Sets the number of seconds that must elapse before a user is allowed to post each new message.
 void setRejectionMessage(java.lang.String rejectionMessage)
          Sets the rejection message that will be returned if a user attempts to make multiple posts within the post interval.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GovernorInterceptor

public GovernorInterceptor()

GovernorInterceptor

public GovernorInterceptor(int objectType,
                           long objectID)
Creates a new instance of the class. The objectType and objectID indicate whether the interceptor is installed globally, in a category, or in a forum. Every interceptor implementation must have a constructor with these exact parameters.

Parameters:
objectType - the constant JiveConstants.SYSTEM if the interceptor is installed globally JiveConstants.FORUM_CATEGORY if the interceptor is installed in a category, or JiveConstants.FORUM if the interceptor is installed in a forum.
objectID - the id of the object that the interceptor is installed in, or -1 if it is installed globally.
Method Detail

getPostInterval

public int getPostInterval()
Returns the number of seconds that must elapse before a user is allowed to post each new message. If the value is less than one, no post interval will be enforced.

Returns:
the post interval (in seconds).

setPostInterval

public void setPostInterval(int postInterval)
Sets the number of seconds that must elapse before a user is allowed to post each new message. If the value is less than one, no post interval will be enforced.

Parameters:
postInterval - the post interval (in seconds).

getRejectionMessage

public java.lang.String getRejectionMessage()
Returns the rejection message that will be returned if a user attempts to make multiple posts within the post interval. The rejection message may contain a token that will be dynamically replaced with the time interval. For example, "Not allowed to post messages more than once every {0} seconds" would be returned to the user as "Not allowed to post messages more than once every 30 seconds".

Returns:
the rejection message.

setRejectionMessage

public void setRejectionMessage(java.lang.String rejectionMessage)
Sets the rejection message that will be returned if a user attempts to make multiple posts within the post interval. The rejection message may contain a token that will be dynamically replaced with the time interval. For example, "Not allowed to post messages more than once every {0} seconds" would be returned to the user as "Not allowed to post messages more than once every 30 seconds".

Parameters:
rejectionMessage - the rejection message.

getType

public int getType()
Description copied from interface: MessageInterceptor
Returns the type of the interceptor.

Specified by:
getType in interface MessageInterceptor
Returns:
the interceptor type.

invokeInterceptor

public void invokeInterceptor(ForumMessage message,
                              int type)
                       throws MessageRejectedException
Description copied from interface: MessageInterceptor
Invokes the interceptor on the specified message. The interceptor can either modify the message, or throw a MessageRejectedException to block it from being posted. Only a TYPE_PRE interceptor can throw an exception.

Specified by:
invokeInterceptor in interface MessageInterceptor
Parameters:
message - the message to take action on.
Throws:
MessageRejectedException - if the message should be prevented from being posted.

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.