UserManagement Core

From Gcube Wiki
Revision as of 10:47, 3 May 2016 by Costantino.perciante (Talk | contribs) (GroupManager APIs)

Jump to: navigation, search

User Management

Introduction

User Management is a library that sits between the Liferay portal services and gCube portlets. The main functionality of the Library is to provide management of users, roles and organizations. It provides a layer of abstraction above the liferay services, hiding the configuration complexities of roles and organizations. The gcube requirement of roles in the scope of organization is achieved by creating a role with the organization name suffixed to it. The addition/removal of organization names to the role names are handled by the Library and are transparent to the application and portlets using the library.

Interfaces

The library exposes three interfaces:

  • User Manager
  • Role Manager
  • Group(Organization) and Team (starting from gCube release 4.0.0) Manager

These interfaces provide the functionalities necessary for CRUD operation on Users, Roles and Groups and additional functionalities that organise users into Groups(Teams) and assigning/dismissal of roles.

Maven Dependency

Add the following dependency to your maven project to use the library.

<dependency>
	<groupId>org.gcube.dvos</groupId>
	<artifactId>usermanagement-core</artifactId>
	<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
	<scope>provided</scope>
</dependency>

UserManager APIs

The UserManager interface allows to create, retrieve and delete users. In order to perform such operations you need to instanciate the proper manager. See the below example.

// Instanciate the manager
UserManager userManager = new LiferayUserManager();
 
//you want to retrieve information about an existing user
GCubeUser userByMail = userManager.getUserByEmail(validUserMail);

The UserManager offers a lot of other utilities. They are reported below:

  • get user information such as email, id, username, professional information, fullname and much more;
  • list all the users;
  • list users belonging to a given group;
  • remove users;
  • remove users from groups;
  • manage users' registrations and membership requests.

GroupManager APIs

The GroupManager interface allows to manage VRE, VO and ROOT VO of the gCube Infrastructure that are mapped on the Liferay's Site objects. It offers the APIs to create, delete and modify them. A gCube group is represented by a GCubeGroup class object. In order to perform such operations you need to instanciate the proper manager. See the below example.

// Instanciate the manager
GroupManager groupManager = new LiferayGroupManager();
 
// you can now retrieve the list of VREs, VOs or get the Root VO
GCubeGroup rootVO = groupManager.getRootVO();
 
// you can create a new VO (child of the root VO)
GCubeGroup newVO = groupManager.createVO("newVoName", rootVO.getGroupId(), "VO description goes here");
 
// you can now create a VRE (child of the just created VO)
 
....
 
// retrieve the groups to whom a given user belongs (given the user identifier)
List<GCubeGroup> listOfGroups = groupManager.listGroupsByUser(userId);

Among the other available functions, you can:

  • check if a given group is a VRE, VO or root VO;
  • retrieve the scope of the group;
  • retrieve the infrastructure scope;
  • manage virtual groups (i.e., a collection of groups).

RoleManager APIs