taskadapter / redmine-java-api

Redmine Java API
Apache License 2.0
269 stars 162 forks source link

How can i get Groups from user object #294

Closed vbris closed 6 years ago

vbris commented 7 years ago

Hello, I have a problem with retrieving groups from user object. When I do: for (User user : users) { Collection<Group> groups = user.getGroups(); System.out.println(user.getLogin() +","+ groups.isEmpty()); } And I get: user1,true user2,true ... I'm not sure if I call the method correctly. Could you give me an advice please? Thank you very much!

alexeyOnGitHub commented 6 years ago

UserManager has a method to load users:

*** * <p><strong>This operation requires "Redmine Administrator" permission.</strong>***
...
    public List<User> getUsers() throws RedmineException {
        return transport.getObjectsList(User.class, new BasicNameValuePair(
                "include", "memberships,groups"));
    }

it should load groups and memberships automatically. are you using Admin account to load users?

also, if you are using a different "getUsers" method, you need to provide this "include" param manually.