The following code indicates how to use the forum API. The method initialize() is used to position a certain number of parameters.
public void general_useModule() { // creation of an object of forum module IForumModule forumModule = new PortalForumModule(); try { // initialization of the module forumModule.initialize( null ); } catch( Exception e ) { // if an error has occurred getNavigator().processErrors( e ); } finally { forumModule.unInitialize(); } }
The context notion enables to run processing with a user account. Several cases are displayed. Their using depends on the execution context and the available objects.
public void general_getContext( IForumModule forumModule ) throws Exception { // 1st case : retrieving the context from a user object IUser user = forumModule.getUserByLogin( "sysadmin" ); IContext userContext = forumModule.getContext( user ); // 2nd case: retrieving the context from an external ID IContext externalIDContext = forumModule.getContext( getNavigator().getLoggedOnUser().getExternId() ); // 3rd case : retrieving the context from a login IContext loginContext = forumModule.getContextByLogin( "sysadmin" ); }