Return to Jive Software

1,747 Views 14 Replies Last post: Jul 21, 2009 11:04 AM by Todd West RSS
Bruce VanAartsen Novice 72 posts since
Mar 29, 2007
Currently Being Moderated

Jul 2, 2009 12:03 PM

Interceptor as a Plugin

In our 1.X implementation of Clearspace, we had developed and deployed our own intercepter by putting the Jar in the WEB-INF/lib directory and setting the proper system property. Now we're running 2.5.X, and I'm guessing there's a fairly easy way to deploy our inteceptor as a plugin, right? I can't find any documentation that says how to do this.

 

Thanks for any advice,

Bruce

Tags: plugin, interceptor
Todd West Jive Employee 15,918 posts since
Jul 14, 2008
Currently Being Moderated
Jul 2, 2009 2:39 PM in response to: Bruce VanAartsen
Re: Interceptor as a Plugin

Hey Bruce,

 

If I'm not mistaken you should be able to do this by simply creating a simple plugin with your interceptor class in it (and a plugin.xml). Then you should be able to take this plugin (compiled as a jar) and deploy it through the admin console. Once you restart you should be able to go to:

 

 

Communities -> Settings -> Interceptor Settings

 

Add the path your plugin at the bottom of the page and click "Add". Since this class should be loaded it should be able to find it. Hope that helps! Thanks.

 

-Todd

Nebiyu Yohannes Jive Employee 10 posts since
Oct 11, 2007
Currently Being Moderated
Jul 9, 2009 1:38 PM in response to: Todd West
Re: Interceptor as a Plugin

YMMV, but it should also be possible to install it programmatically in your plugin init method. Just inject the interceptorManagerImpl bean into your plugin bean.

 

You should then be able to install your plugin's interceptor.

 

        try {
            log.info("Installing MyObjectManipulationInterceptor");
            if (interceptorManager.getAvailableInterceptors().length > 0) {
                interceptorManager.addInterceptorClass(MyObjectManipulationInterceptor.class.getName());
            }
            else {
                //As a precaution, if the available interceptors have never been initialized, we won't install our
                //plugin's interceptor. This should never happen, but if it does the plugin's interceptor can
                //be installed manually if need be. The validation performed by this interceptor is not required,
                //so we are not logging this as an error. If the plugin's interceptor was very important we would  
                //handle the error more robustly
                log.warn("Error installing MyObjectManipulationInterceptor. MyObject creation will not be pre-processed.");
            }
        }
        catch (ClassNotFoundException e) {            
            log.warn("Error installing MyObjectManipulationInterceptor. MyObject creation will not be pre-processed.");
        }

 

Interceptor installation should probably be supported by the plugin framework, either through a bean in spring.xml or a setting in plugin.xml

Todd West Jive Employee 15,918 posts since
Jul 14, 2008
Currently Being Moderated
Jul 20, 2009 8:58 AM in response to: Bruce VanAartsen
Re: Interceptor as a Plugin

Hey Bruce,

 

Here's what you'll want to do:

 

1) Change replace the call to setModerationValue with:

 

ModerationUtil.forceContentObjectModeration(message);

 

2) Modify the getTypes method from this:

 

public List<Type> getTypes() {
        return new ArrayList<Type>() {{ add(Type.TYPE_PRE); }};
}

 


to this:

 

 

public List<Type> getTypes() {
        return new ArrayList<Type>() {{ add(Type.TYPE_POST); }};
}

 


Having the type set as PRE will try to run the interceptor before the content has been accepted into the system (written to the database) so when it tries to check for the message ID to set the moderation value it fails with an NPE. Hope that helps! Thanks.

 

-Todd

Todd West Jive Employee 15,918 posts since
Jul 14, 2008
Currently Being Moderated
Jul 20, 2009 1:05 PM in response to: Bruce VanAartsen
Re: Interceptor as a Plugin

Hey Bruce,

 

If you set yourself as being able to "Moderate Content" at the root level (Admin Console -> Spaces -> Permissions) then you should automatically get all moderation requests. Is this not the case?

 

-Todd

Todd West Jive Employee 15,918 posts since
Jul 14, 2008
Currently Being Moderated
Jul 20, 2009 3:14 PM in response to: Bruce VanAartsen
Re: Interceptor as a Plugin

Hmm, that doesn't sound right. Have you made sure that moderation is enabled at the root level?

 

Admin Console -> Spaces -> Settings -> Moderation Settings (Make sure you are at the root space)

 

 

-Todd

Todd West Jive Employee 15,918 posts since
Jul 14, 2008
Currently Being Moderated
Jul 20, 2009 3:46 PM in response to: Bruce VanAartsen
Re: Interceptor as a Plugin

Yes and no.

 

1) In order to have a moderator at the root space automatically get moderation notifications for subspaces, this setting has to be enabled

2) This also forces all items into the moderation queue

 

So really, this is working as expected. In order for you to define moderators of spaces you will havet to define them in each space. In order to automatically attach to all spaces you have to enable it globally. Hope that helps! Thanks.

 

-Todd

Todd West Jive Employee 15,918 posts since
Jul 14, 2008
Currently Being Moderated
Jul 21, 2009 9:07 AM in response to: Bruce VanAartsen
Re: Interceptor as a Plugin

Hey Bruce,

 

Actually, I apologize it turns out I wasn't fully correct. Enabling moderation at the root level does indeed only apply to social groups and other specific global items (not all spaces like I originally though). If you try to enable moderation for a community without specifying a moderator at that level you will get an error and you will be unable to change the moderation settings. So at this point, in order to allow moderators to moderate specific spaces your best bet would be the following:

 

1) Create a Permission group to hold all of these moderators

2) Add the permission group as a moderator for all the spaces you wish to moderate this way

3) Enable moderation for these spaces

 

 

Having the people in the group means that if you need to switch out moderators you only have to change the group membership and you will not have to go into each space and manually change the moderators. Hope that helps. Thanks.

 

-Todd

Todd West Jive Employee 15,918 posts since
Jul 14, 2008
Currently Being Moderated
Jul 21, 2009 11:04 AM in response to: Bruce VanAartsen
Re: Interceptor as a Plugin

No problem Bruce! Have a good day.

 

-Todd

More Like This

  • Retrieving data ...

Bookmarked By (0)

To better serve our customers we have included functionality to automatically follow up on a case after it has been idle for more than 5 days, and then auto close after an additional 3 days of inactivity. Choose No to acknowledge that this case will remain idle for longer than 5 days.
Making cases public allows other customers to learn from the solution of the case. It can also be used to gain feedback from others in the community. Ask our Support Engineers for more info, but we encourage you to make your cases public.