Difference between revisions of "UserManagement Core"
(→User Management) |
(→User Management) |
||
Line 11: | Line 11: | ||
These interfaces provide the functionalities necessary for CRUD operation on Users, Roles and Organizations and additional functionalities that organise users into Organizations and assigning/dismissal of roles. | These interfaces provide the functionalities necessary for CRUD operation on Users, Roles and Organizations and additional functionalities that organise users into Organizations and assigning/dismissal of roles. | ||
− | === | + | === Maven Dependency === |
− | + | ||
+ | Add the following dependency to your maven project to use the library. | ||
+ | <source lang="xml"> | ||
+ | <dependency> | ||
+ | <groupId>org.gcube.dvos</groupId> | ||
+ | <artifactId>usermanagement-core</artifactId> | ||
+ | <version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version> | ||
+ | <scope>provided</scope> | ||
+ | </dependency> | ||
+ | </source> | ||
+ | |||
+ | === 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. | ||
+ | |||
+ | <source lang="java"> | ||
+ | // Instanciate the manager | ||
+ | UserManager userManager = new LiferayUserManager(); | ||
+ | |||
+ | /* | ||
+ | * Create the user and let you choose if you want to send him/her a mail notification and force or not the user to change | ||
+ | * his/her password. | ||
+ | * You can also pass the avatar to set as bytes. | ||
+ | * @param autoScreenName set true if you want liferay to auto generate a screename for this user, false otherwise | ||
+ | * @param username the username of the user you want | ||
+ | * @param email a valid email address | ||
+ | * @param firstName | ||
+ | * @param middleName | ||
+ | * @param lastName | ||
+ | * @param jobTitle | ||
+ | * @param backgroundSummary | ||
+ | * @param male | ||
+ | * @param portraitBytes the bytes of the avatar to use for the user | ||
+ | * @param openId user's openId | ||
+ | * @return an instance of the yet created user | ||
+ | * @throws UserManagementSystemException | ||
+ | */ | ||
+ | GCubeUser createdUser = userManager.createUser(autoScreenName, username, email, firstName, middleName, lastName, jobTitle, locationIndustry, | ||
+ | backgroundSummary, male, reminderQuestion, reminderAnswer, sendEmail, forcePasswordReset, portraitBytes); | ||
+ | |||
+ | // or maybe you want to retrieve information about an existing user | ||
+ | GCubeUser userByMail = userManager.getUserByEmail(validUserMail); | ||
+ | |||
+ | // delete user | ||
+ | userManager.deleteUserByEMail(createdUser.getEmail()); | ||
+ | </source> | ||
+ | |||
+ | === GroupManager APIs=== | ||
+ | |||
+ | === RoleManager APIs=== |
Revision as of 18:55, 2 May 2016
Contents
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) Manager
These interfaces provide the functionalities necessary for CRUD operation on Users, Roles and Organizations and additional functionalities that organise users into Organizations 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(); /* * Create the user and let you choose if you want to send him/her a mail notification and force or not the user to change * his/her password. * You can also pass the avatar to set as bytes. * @param autoScreenName set true if you want liferay to auto generate a screename for this user, false otherwise * @param username the username of the user you want * @param email a valid email address * @param firstName * @param middleName * @param lastName * @param jobTitle * @param backgroundSummary * @param male * @param portraitBytes the bytes of the avatar to use for the user * @param openId user's openId * @return an instance of the yet created user * @throws UserManagementSystemException */ GCubeUser createdUser = userManager.createUser(autoScreenName, username, email, firstName, middleName, lastName, jobTitle, locationIndustry, backgroundSummary, male, reminderQuestion, reminderAnswer, sendEmail, forcePasswordReset, portraitBytes); // or maybe you want to retrieve information about an existing user GCubeUser userByMail = userManager.getUserByEmail(validUserMail); // delete user userManager.deleteUserByEMail(createdUser.getEmail());