Chapter 22. Wildcard Membership Type

Wildcard (*) membership type is considered identical to any membership type.
If a user is assigned the wildcard membership type for a group, when a membership type for this group and the user is checked, then it is alway true regardless of the membership type.

22.1. Wildcard Membership Configuration and Initialization

The wildcard membership can not be created at runtime through the User Interface. It can only be initialized by configuring OrganizationDatabaseInitializer plug-in correctly.

Example 22.1. Wildcard Membership Initilization and Configuration


  	<external-component-plugins>
    <target-component>org.exoplatform.services.organization.OrganizationService</target-component>
    <component-plugin>
      <name>init.service.listener</name>
      <set-method>addListenerPlugin</set-method>
      <type>org.exoplatform.services.organization.OrganizationDatabaseInitializer</type>
      <description>this listener populate organization data for the first launch</description>
      <init-params>
        <object-param>
          <name>configuration</name>
          <description>description</description>
          <object type="org.exoplatform.services.organization.OrganizationConfig">
            <field name="membershipType">
              <collection type="java.util.ArrayList">
                <value>
                  <object type="org.exoplatform.services.organization.OrganizationConfig$MembershipType">
                    <field name="type">
                      <string>*</string>
                    </field>
                    <field name="description">
                      <string>any membership type</string>
                    </field>
                  </object>
                </value>
              </collection>
            </field>
          </object>
        </object-param>
      </init-params>
    </component-plugin>
  </external-component-plugins>
  		

22.2. Wildcard Membership API

The existing method behavior in the API is unchanged, to ensure backward compatibility is maintained. A new method in the GroupHandler interface is available to perform the wildcard membership type resolution.
The following method returns a collection of groups that the user has the specified membership type relationship, or the wildcard membership.

Collection resolveGroupByMembership(String userName, String membershipType)
In the MembershipTypeHandler interface, the following method returns a collection of all membership types. In this particuar usage example, the wildcard membership would be the first element returned (if it exists).

Collection findMembershipTypes()