Package com.ibm.portal.community

This package and its subpackages define the portal community API.

See:
          Description

Interface Summary
AbstractRole The interface represents a role type in the scope of the community API.
CommunityController The CommunityController provides functions to modify community roles, domain roles and membership assignments.
CommunityHome This interface can be used to access the community administration component of WebSphere Portal.
CommunityLocator The CommunityLocator provides functions to retrieve information about community roles, domain roles and membership.
An instance of this Interface can be retrieved by calling CommunityHome,
CommunityObjectFactory The CommunityObjectFactory provides functions to create filled Localized, LocalizedDomainRole and LocalizedCommunityRole objects that can be used as input parameter for the Comunity API method calls.
An instance of this Interface can be retrieved through the Home Interface: CommunityHome
CommunityRole The interface represents community roles.
DomainRole This interface represents domain specific roles that are exposed by business components.
LocalizedCommunityRole This interface represents extended community roles that provide localized titles and descriptions for the role.
LocalizedDomainRole This interface represents extended domain roles that provide localized titles and descriptions for the domain specific role.
 

Class Summary
LocalizedDataObject Default implementation for the Localized interface.
 

Enum Summary
CommunityAccessPrivilege The CommunityAccessPrivilege enum provides a fixed set of access levels.
 

Package com.ibm.portal.community Description

This package and its subpackages define the portal community API.

Overview

The portal community API offers functionality to retrieve and modify access control related informatation of application communities (see also Composite Application Infrastructure APIs). In particular, the following data objects and relationships can be created, retrieved, modified and deleted:

Note that all objects handled by the community API are protected through Portal Access Control. A user without appropriate permissions will receive MissingAccessRightsException s during method execution. The required permissions for the various operations are listed in the portal info center section 'Access Rights' under 'Applications'.

Class Overview - Service Interfaces

The main service interfaces as listed below can be retrieved through the CommunityHome .

Class Overview - Data Objects

Code Samples

Retrieve CommunityLocator and CommunityController Instances

The following sample shows how instances of the CommunityLocator and CommunityController can be retrieved through a JNDI lookup and the CommunityHome class.
        Context ctx = new InitialContext();
        CommunityHome chome = (CommunityHome) ctx.lookup(CommunityHome.JNDI_NAME);
        CommunityLocator locator = chome.getLocator();
        CommunityController controller = chome.getController();

Retrieve CommunityRole objects and their localized titles

The following sample shows how an instance of the CommunityLocator is used to query for community roles of an application. Localized information (title) is retrieved for the queried roles and displayed together with the rolename as String object.
        Context ctx = new InitialContext();
        CommunityHome chome = (CommunityHome) ctx.lookup(CommunityHome.JNDI_NAME);
        CommunityLocator locator = chome.getLocator();
        
        // use locator to query for community roles
        ObjectID applicationEntityObjectID = null; // use ObjectID from CompositeApplication environment
        Set communityRoles = locator.getCommunityRolesForCommunity(applicationEntityObjectID);
        
        // use locator to query for localized information of the all roles at the same time
        List sortedCommunityRoles = new ArrayList(communityRoles);
        List localizedCRData = locator.getLocalizedDataForRoles(sortedCommunityRoles);
        
        // loop over result and display role title for a available locale
        StringBuilder sb = new StringBuilder(100);
        Iterator crIterator = sortedCommunityRoles.iterator();
        for (Localized localized : localizedCRData)
        {
            CommunityRole role = crIterator.next();
            sb.append("- ").append(role.getRoleName()).append(": ");
            String localizedTitle = localized.getTitle(localized.getLocales().iterator().next());
            sb.append(localizedTitle).append("\n");
        }
        System.out.println(sb.toString());

Creating a new CommunityRole

The following sample shows how an instance of the CommunityController is used to create a new community role for an application. A given group principal is mapped as member to this new role.
        Context ctx = new InitialContext();
        CommunityHome chome = (CommunityHome) ctx.lookup(CommunityHome.JNDI_NAME);
        CommunityController controller = chome.getController();
        CommunityObjectFactory objFactory = chome.getObjectFactory();

        // use controller and object factory to create a new community role
        ObjectID applicationEntityObjectID = appEntityOID; // use ObjectID from CompositeApplication environment

        // create localized titles and descriptions for the role
        HashMap titles = new HashMap();
        HashMap descriptions = new HashMap();
        titles.put(Locale.ENGLISH, "my english title");
        titles.put(Locale.GERMAN, "my german title");
        descriptions.put(Locale.ENGLISH, "my english description");
        Localized locObj = objFactory.createLocalizedObject(titles, descriptions);
        
        // create role through controller
        CommunityRole newRole = controller.createCommunityRole(appEntityOID, "NewRolename", locObj);

        // map group as member to the new community role
        Principal group = null; // use Portal User and Group Management API to retrieve group data
        controller.addMemberToCommunityRole(newRole, Collections.singleton(group));