JBoss Community Archive (Read Only)

GateIn Portal 3.8

Organization API

With Organization API, you can perform various operations on identity objects, such as users, groups and memberships. For instance, you can retrieve all GateIn Portal users, create a new user, update properties of a given user, etc.

Domain Model

There are five main entities in the Organization API:

  • User contains basic details about the user, such as username, password, first name, last name, and email.

  • UserProfile includes some additional information about a user, such as user's personal information, and business information. UserProfile also allows for adding custom data fields to user if your application requires it.

  • Group provides an access to the group graph.

  • MembershipType contains a list of predefined membership types.

  • Membership connects a User, a Group and a MembershipType together.

Note that a user can have one or more memberships within a group. For example, user "john" can have two memberships: "member" and "admin" in the group "/platform/users". A user belongs to a group if he has at least one membership in that group.

pom.xml

To be able to use Organization API from your code, you need to declare a dependency on Organization API in the pom.xml file of your project:

<dependencies>
  <dependency>
    <groupId>org.exoplatform.core</groupId>
    <artifactId>exo.core.component.organization.api</artifactId>
    <version>2.5.3-GA</version>
    <scope>provided</scope>
  </dependency>
  <!-- other dependencies may appear here, too -->
</dependencies>

Please note that exo.core.component.organization.api artifact is not available in Maven Central. To be able to use it, you need to include JBoss Public repository in your Maven installation's settings.xml file as follows:

<profiles>
  <profile>
    <id>jboss-public-repository</id>
    <repositories>
      <repository>
        <id>jboss-public-repository</id>
        <name>JBoss Public Maven Repository Group</name>
        <url>https://repository.jboss.org/nexus/content/groups/public/</url>
        <updatePolicy>never</updatePolicy>
        <layout>default</layout>
        <releases>
          <enabled>true</enabled>
          <updatePolicy>never</updatePolicy>
        </releases>
        <snapshots>
          <enabled>true</enabled>
          <updatePolicy>never</updatePolicy>
        </snapshots>
      </repository>
    </repositories>
  </profile>
</profiles>
<activeProfiles>
  <activeProfile>jboss-public-repository</activeProfile>
</activeProfiles>

API Usage

Developers can call Organization API operations using handlers. These handlers are designed like data access objects (DAO). There is a dedicated handler for each of the five persistent entities:

  • UserHandler exposes operations related to User

  • UserProfileHandler exposes operations related to UserProfile

  • GroupHandler exposes operations related to Group

  • MembershipTypeHandler exposes operations related to MembershipType

  • MembershipHandler exposes operations related to Membership

A reference to a handler can be obtained from OrganizationService component. In the following snippet, we show how a new user joseph can be created using the Organization API:

OrganizationService orgService = (OrganizationService)PortalContainer.getInstance().getComponentInstanceOfType(OrganizationService.class);
UserHandler userHandler = orgService.getUserHandler();
User user = userHandler.createUserInstance("joseph");
user.setPassword("default12");
user.setFirstName("Joseph");
user.setLastName("Breburda");
user.setEmail("joseph@gatein.org");
userHandler.createUser(user, true);

Another example is available in Access User Profile Chapter.

All available Organization API operations can be seen in the diagram below:

images/author/download/attachments/78709490/OrganizationServiceClassDiagram.png

Relationship to PicketLink IDM

Organization API is a set of interfaces describing a contract. The default implementation provided by GateIn Portal is based on Picketlink IDM framework. Note that you can replace this implementation with your own, if necessary.

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-10 13:19:28 UTC, last content change 2014-05-01 09:41:47 UTC.