Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.forum
Interface MessageInterceptor

All Known Implementing Classes:
BanMessageInterceptor, GatewayInterceptor, GovernorInterceptor, IPInterceptor, KeywordInterceptor, ModerationInterceptor, UserInterceptor, VirusScanInterceptor

public interface MessageInterceptor

A message interceptor encapsulates an action that is invoked on a message immediately before or after it is added to the system and also when the message subject or body is being edited. These types of actions fall into two broad categories:

Examples of interceptors that would reject a message include blocking a set of users from posting, preventing a user from posting more than once every X seconds, or rejecting any messages that contain profanity. Interceptors that transform messages might include removing mailing list subject pre-fixes, removing HTML, or let certain users bypass moderation.

Any number of interceptors can be installed and removed at run-time. They can be installed globally or per-forum. Global interceptors are run first, followed by any that are installed for the forum.

Create a MesssageInterceptor implementation:

Each interceptor can have properties that are configurable by end-users. These should be exposed through a BeanInfo class.

All interceptor implementations must have two public constructors. One should be a default constructor (no parameters), and the other should have following signature: (int objectType, long objectID). These paramaters tell the interceptor instance if it is installed globally, in a category, or in a forum. In the case of a global interceptor, the objectType is JiveConstants.SYSTEM and the objectID is -1.

See Also:
InterceptorManager

Field Summary
static int TYPE_ALL
          Interceptor that is run before and after a message has been accepted into the system and also during message edits.
static int TYPE_BOTH
          Interceptor that is run before and after the message has been accepted into the system.
static int TYPE_EDIT
          Interceptor that is run when messages are edited by calling setSubject(String) or setBody(String).
static int TYPE_POST
          Interceptor that is run after the message has been accepted into the system.
static int TYPE_PRE
          Interceptor that is run before the message has been accepted into the system.
 
Method Summary
 int getType()
          Returns the type of the interceptor.
 void invokeInterceptor(ForumMessage message, int type)
          Invokes the interceptor on the specified message.
 

Field Detail

TYPE_PRE

static final int TYPE_PRE
Interceptor that is run before the message has been accepted into the system.

See Also:
Constant Field Values

TYPE_POST

static final int TYPE_POST
Interceptor that is run after the message has been accepted into the system.

See Also:
Constant Field Values

TYPE_BOTH

static final int TYPE_BOTH
Interceptor that is run before and after the message has been accepted into the system.

See Also:
Constant Field Values

TYPE_EDIT

static final int TYPE_EDIT
Interceptor that is run when messages are edited by calling setSubject(String) or setBody(String).

See Also:
Constant Field Values

TYPE_ALL

static final int TYPE_ALL
Interceptor that is run before and after a message has been accepted into the system and also during message edits.

See Also:
Constant Field Values
Method Detail

getType

int getType()
Returns the type of the interceptor.

Returns:
the interceptor type.

invokeInterceptor

void invokeInterceptor(ForumMessage message,
                       int type)
                       throws MessageRejectedException
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.

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.