cancel
Showing results for 
Search instead for 
Did you mean: 

[NUXEO IDE] impossible to change user's group without restarting the server

milonette_
Star Collaborator
Star Collaborator

Hello,

I would like to add a user to a nuxeo group with an automation operation write in IDE.

I try to do that with :

    String groupName="group";
    String user="userlogin";
    NuxeoGroup group = usermanager.getGroup(groupName);
    NuxeoPrincipal up=usermanager.getPrincipal(user); 
    List<String> userGroups = up.getGroups();
    userGroups.add(group.getName());
    up.setGroups(userGroups);
    //this part don't works
    usermanager.updatePrincipal(up);

    //same problem don't update
    DocumentModel userModel = userManager.getUserModel(user);
    userModel.setProperty("user", "groups", userGroups);
    userManager.updateUser(userModel);

    //this part works
    group.getMemberUsers().add(user);
    usermanager.updateGroup(group);

The group's user are Ok, but the user's group information is not set while I don't restart the server.

Why ? Why group is instantally set and user not?

What can I do to make this work ?

thanks

ps: try also code nuxeo code example and it failed.

ps2 : my user is a ldap user

2 REPLIES 2

Vladimir_Pasqui
Star Collaborator
Star Collaborator

Hi,

milonette_
Star Collaborator
Star Collaborator

Hello Vladimir,

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.