You are looking at documentation for an older release. Not what you want? See the current release documentation.
To create a custom Organization Service, you need to implement several interfaces and extend some classes which will be listed below.
First, you need to create classes implementing the following interfaces (each of which represents a basic unit of organization service):
org.exoplatform.services.organization.User
This is the interface for a User data model. The OrganizationService implementor can implement this class in different ways. For example, the implementor can use the native field for each GET method or the Map to hold the user data.
org.exoplatform.services.organization.UserProfile
This is the interface for a UserProfile data model. The implementor should have a user map info in the implementation. The map should only accept java.lang.String for the key and the value.
org.exoplatform.services.organization.Group
This is the interface for the group data model.
org.exoplatform.services.organization.Membership
This is the interface for the membership data model.
org.exoplatform.services.organization.MembershipType
This is the interface for the membership type data model.
After each set method is called, the developer must call the UserHandler.saveUser (GroupHandler.saveGroup, MembershipHandler.saveMembership) method to persist changes.
You can find examples of the mentioned above implementations at Github server:
After you have created basic Organization Service unit instances, you need to create classes to handle them (for example, to persist changes, to add listener). For that purpose, you need to implement several interfaces correspondingly:
User handler
org.exoplatform.services.organization.UserHandler
This class is acted as a sub-component of the organization service. It is used to manage the user account and broadcast the user event to all the registered listeners in the organization service. The user event can be: creating new, updating and deleting. Each event should have 2 phases: pre-event and post-event. The methods, including createUser, saveUser and removeUser, broadcast the event at each phase, so the listeners can handle the event properly.
org.exoplatform.services.organization.ExtendedUserHandler
This class is optional. You can implement this if you want to use Digest access authentication. For example, you need a one-way password encryption for authentication.
org.exoplatform.services.organization.UserEventListenerHandler
This class is optional that provides ability to get the list of org.exoplatform.services.organization.UserEventListener. The list should be unmodifiable to prevent modification outside of org.exoplatform.services.organization.UserHandler.
User profile handler
org.exoplatform.services.organization.UserProfileHandler
This interface is acted as a sub-interface of the Organization Service. It is used to manage the UserProfile record, the extra information of a user, such as address, phone. The interface should allow developers to create, delete and update a UserProfile and broadcast the event to the user profile event listeners.
org.exoplatform.services.organization.UserProfileEventListenerHandler
This class is optional that provides ability to get the list of org.exoplatform.services.organization.UserProfileEventListener. The list should be unmodifiable to prevent modification outside of org.exoplatform.services.organization.UserProfileHandler.
Group handler
org.exoplatform.services.organization.GroupHandler
This class is acted as a sub-component of the organization service. It is used to manage the group and broadcast the group event to all the registered listeners in the organization service. The group event can be: creating new, updating and deleting. Each event should have 2 phases: pre-event and post-event. The methods, including createGroup, saveGroup and removeGroup, broadcast the event at each phase, so the listeners can handle the event properly.
org.exoplatform.services.organization.GroupEventListenerHandler
This class is optional that provides ability to get the list of org.exoplatform.services.organization.GroupEventListener. The list should be unmodifiable to prevent modification outside of org.exoplatform.services.organization.GroupHandler.
Membership handler
org.exoplatform.services.organization.MembershipHandler
This class is acted as a sub-component of the organization service. It is used to manage the membership - relation of user, group and membership type and broadcast the membership event to all the registered listeners in the organization service. The membership event can be: creating new linked membership and deleting the membership type event. Each event should have 2 phases: pre-event and post-event. The methods, including linkMembership and removeMembership, broadcast the event at each phase, so the listeners can handle the event properly.
org.exoplatform.services.organization.MembershipEventListenerHandler
This class is optional that provides ability to get the list of org.exoplatform.services.organization.MembershipEventListener. The list should be unmodifiable to prevent modification outside of org.exoplatform.services.organization.MembershipHandler.
Membership type handler
org.exoplatform.services.organization.MembershipTypeHandler
This class is acted as a sub-component of the organization service. It is used to manage the membership - relation of user, group and membership type, and broadcast the membership event to all the registered listeners in the organization service. The membership event can be: creating new linked membership and deleting the membership type event. Each event should have 2 phases: pre-event and post-event. The methods, including linkMembership and removeMembership, broadcast the event at each phase, so the listeners can handle the event properly.
org.exoplatform.services.organization.MembershipTypeEventListenerHandler
This class is optional that provides ability to get the list of org.exoplatform.services.organization.MembershipTypeEventListener. The list should be unmodifiable to prevent modification outside of org.exoplatform.services.organization.MembershipTypeHandler.
You can find examples of the mentioned above implementations at Github server:
Finally, you need to create your main custom Organization Service class. It must extend org.exoplatform.services.organization.BaseOrganizationService. The BaseOrganizationService class contains Organization Service unit handlers as protected fields, so you can initialize them according to your purposes. It also has org.exoplatform.services.organization.OrganizationService interface methods' implementations. This is the class you need to mention in the configuration file if you want to use your custom Organization Service.
You can find example of this class at Github server: JCROrganizationServiceImpl.
Make sure that your custom Organization Service implementation is fully compliant with the Organization Service TCK tests. Tests are available as Maven artifact:
groupId - org.exoplatform.core
artifactId - exo.core.component.organization.tests
You can find the source code of TCK tests package here.
To run unit tests, you may need to configure the following Maven plugins:
Check the pom.xml file to find out one of the ways to configure the Maven project object model. See Organization Service TCK tests for more details.