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
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
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
Thanks for the tips. Your instructions got me most of the way. The plugin loaded fine, the Interceptor Settings page found the class, and I was able to configure the interceptor from there as well. Unfortunately, something's not quite working yet. The interceptor is supposed to put new user's discussion messages into the moderation queue, but instead they post immediately.
The NewbieModerationInterceptor code (attached) is based on your ModerationInterceptor and worked fine with CS 1.6. For the plugin version, I added some additional setters for GroupManager and StatusLevelManager to import the properties from my spring.xml file, and I verified that they are being initialized properly. I also updated various other declarations and statements to match the ones in the latest ModerationInterceptor (CS 2.5.13).
I added a bunch of log statements to see if the code was executing, and it appears to function correctly except that the final assignment (line 53) is effectly ignored.
forumManager.setModerationValue(message, JiveConstants.MESSAGE_MODERATION_HIDDEN);
Since it didn't work, I also tried the statement used in the banMessageInterceptor:
ModerationUtil.forceContentObjectModeration(message);
This was even worse, since it yielded a NullPointerException.
I put the first call back in, but can't figure out what I'm doing wrong. Am I using the wrong call to send the message to moderation?
I'll also attach the last few hours of our clearspace.log. The last test using forumManager was done at 18:53, and the one using ModerationUtil was done at 16:31.
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
Excellent, thanks! I just tested the plugin after making your suggested changes and it works great now.
The only minor caveat is that all moderated messages used to show up in my moderation queue (as a system admin and global moderator in CS 1.6). Now the only way I could see the moderation queue for a community was to explicitly set myself as moderator for that community, even though moderation was showing as inherited on the Permission Summary. Is that the expected behavior now?
Bruce
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
I just ran through another set of tests (on our development system) and none of the 3 admins can see a newly-posted moderated message. All 3 of us have all 5 permission types checked on the Console -> Spaces -> Permissions page. I even tried explicitly setting my Moderator Content privilege at the 1st-level (not root) community, and still couldn't see a moderated message from its sub-community. Only after explicitly setting myself as a moderator of that subcommunity could I get a moderated post to appear in my queue.
It's not that onerous to add myself to each community, I guess. OTOH, if user-generated social groups take off, I'm not sure if this will make our newbie plugin put messages in a queue that nobody is moderating.![]()
Bruce
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
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
OK. Thanks for the clarification. In our case, we wrote the Newbie interceptor so only a tiny percentage of posts would go to moderation. Enabling moderation at the root level would totally defeat the purpose (and make our moderators rather grumpy
).
I like the way that CS 1.6 handles this, and think that an Admin (or "global moderator") should be able to access all the active moderation queues by simply electing to "Moderate Content" at the root-level "Admins & Moderators" page. Right now I believe this setting is pointless (unless you want to moderate every item in every community).
And if I understand you correctly, I suggest that someone modify the document/dicussion explanation on your root "Moderation Settings" page. Shouldn't it say it applies to "All spaces, projects, and social groups" instead of just "All social groups"?
Thanks again,
Bruce
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
Thanks for the re-clarification, Todd. Your permission-group tip may come in handy too. ![]()
Cheers,
Bruce
No problem Bruce! Have a good day.
-Todd
Jive combines collaboration software, community software & social networking software into the leading SBS solution.
© Copyright 2000–2009 Jive Software. All rights reserved.
915 SW Stark St., Suite 400, Portland, OR 97205