Clearspace API (2.5.29) Core Javadocs

com.jivesoftware.community
Interface JiveInterceptor


public interface JiveInterceptor

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

Examples of interceptors that would reject a jive object include blocking a set of users from posting, preventing a user from posting more than once every X seconds, or rejecting any message that contain profanity. Interceptors that transform content 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-community. Global interceptors are run first, followed by any that are installed for the community.

Create a JiveInterceptor 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 or in a community. In the case of a global interceptor, the objectType is JiveConstants.SYSTEM and the objectID is -1.

Note that the default implementation of the code that invokes interceptors will detect cyclic calls to interceptors so it is safe to recall methods that called the interceptor. For example, the comment.setBody(body) method will fire interceptor using the JiveInterceptor.Type.TYPE_EDIT type. If an interceptor wants to modify that body and call comment.setBody(body) again with the modified body the implementation will detect the second cyclical call to invoke interceptors and not execute any interceptors in that circumstance.

See Also:
InterceptorManager

Nested Class Summary
static class JiveInterceptor.Type
          Represents the different ways a JiveInterceptor may be run
 
Method Summary
 List<JiveInterceptor.Type> getTypes()
          Returns the interception types the interceptor supports.
 void invokeInterceptor(JiveObject jiveObject, JiveInterceptor.Type type)
          Invokes the interceptor on the specified jive object.
 

Method Detail

getTypes

List<JiveInterceptor.Type> getTypes()
Returns the interception types the interceptor supports.

Returns:
a list of the interceptors interception types.

invokeInterceptor

void invokeInterceptor(JiveObject jiveObject,
                       JiveInterceptor.Type type)
                       throws RejectedException
Invokes the interceptor on the specified jive object. The interceptor can either leave the jive object as it is, modify the object's content or throw a RejectedException to block it from being created/posted. Only a JiveInterceptor.Type.TYPE_PRE interceptor can throw an exception.

Parameters:
jiveObject - the jive object to take action on.
type - the type of interceptor to run
Throws:
RejectedException - if the object should be prevented from being created/posted.

Clearspace Project Page

Copyright © 1999-2007 Jive Software.