Java Client SDK 3.2

User & Group

Updated: December 19, 2019

This page is scheduled for review and update. Check back soon for updated content!

This section is about how handling users and groups with Nuxeo Java Client.

User is highly configurable in Nuxeo. Java Client allows such configurability but also offer common methods to get name, password, email, etc.

This page presents examples on basic configuration. If you need to get/set more properties you can use the method below:

  • getProperties
  • setProperties

Let's first retrieve user manager to handle them:

UserManager userManager = client.userManager();


APIs below are available to create user/group:

  • createUser which takes a user
  • createGroup which takes a group

Let's first create a user:

User user = new User();
user = userManager.createUser(user);

Now we want to create a new group and add John to it. Furthermore we want this group to be part of members group present on stock Nuxeo Server:

Group group = new Group();
group.setGroupLabel("My Group");
group = userManager.createGroup(group);


APIs below are available to fetch user/group:

  • fetchUser which takes a user name
  • fetchCurrentUser which takes nothing
  • fetchGroup which takes a group name

Let's fetch our user:

User user = userManager.fetchUser("john");
String firstName = user.getFirstName(); // equals to John
String lastName = user.getLastName(); // equals to Doe
String password = user.getPassword(); // equals to null / empty

User currentUser = userManager.fetchCurrentUser(); // get the log-in user

Let's fetch our group:

Group group = userManager.fetchGroup("myGroup");
String label = group.getGroupLabel(); // equals to My Group

As Group is a connectable entity and we get myGroup from client we can do the following:

Users users = group.fetchMemberUsers();
Groups subGroups = group.fetchMemberGroups();

You can also retrieve them during the fetch with help of the fetch properties:

Group group = userManager.fetchPropertiesForGroup("memberUsers", "memberGroups", "parentGroups")
List<String> memberUsers = group.getMemberUsers();
List<String> memberGroups = group.getMemberGroups();
List<String> parentGroups = group.getParentGroups();


APIs below are available to update user/group:

  • updateUser which takes a user
  • updateUser which takes a user name and a user
  • updateGroup which takes a group
  • updateGroup which takes a group name and a group
  • addUserToGroup which takes a user name and a group name
  • attachGroupToUser which takes a group name and a user name

Let's update our user:

User john = userManager.fetchUser("john");

Let's update our group:

User myGroup = userManager.fetchUser("myGroup");
myGroup.setGroupLabel("Company Group");

Now we want to add another user to our group, let's say jean:

userManager.addUserToGroup("jean", "myGroup");


APIs below are available to delete user/group:

  • deleteUser which takes a user name
  • deleteGroup which takes a group name

Let's delete our entities:


APIs below are available to search user/group:

  • searchUser which takes a pattern
  • searchUser which takes a pattern, current page index and page size
  • searchGroup which takes a pattern
  • searchGroup which takes a pattern, current page index and page size

These APIs leverage a page provider server side, depending on your configuration you can have different behavior than the regular one leveraged in these examples.

Examples are available for both users and groups.

Let's retrieve all groups:

Groups groups = userManager.searchGroup("*"); // retrieve maxResult groups
for (Group group : groups.getEntries()) {
    // do something with group

Let's see how retrieving a paginated query result and loop over pages:

Users users = null;
do {
    int pageIndex = users == null ? 0 : users.getCurrentPageIndex() + 1;
    users = userManager.searchUser("*", pageIndex, 50);
    for (User user : users.getEntries()) {
        // do something with user
} while (users.isNextPageAvailable());

Depending on your directory configuration, the pattern will act differently, see substringMatchType in your directory configuration.

Let's search for john:

Users users = userManager.searchUser("jo");
List<User> userList = users.getEntries(); // contains john user

We'd love to hear your thoughts!

All fields required