Hello,
Just to terminate this thread, the following code retrieves all the groups
associated to a user.
UserTO userTO = ...
List<GroupTO> groupTOs = Collections.<GroupTO> emptyList();
List<Long> keys = userTO.getMembershipMap().entrySet().stream()
.filter(entry -> "GROUP".equals(entry.getValue().getRightType()))
.map(entry ->
entry.getValue().getRightKey()).collect(Collectors.toList());
if (keys.size() > 0) {
// cannot say I like the next 2 lines
Long firstKey = keys.get(0);
keys.remove(0);
String fiql = SyncopeClient.getGroupSearchConditionBuilder().is("key")
.equalTo(firstKey, keys.toArray(new Long[keys.size()])).query();
PagedResult<GroupTO> groupTOsPage =
syncopeClient.getService(GroupService.class)
.search(new
AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM).fiql(fiql).build());
groupTOs = (List<GroupTO>) groupTOsPage.getResult();
}
Regards,Adrian
De : Adrian Gonzalez <[email protected]>
À : "[email protected]" <[email protected]>; Adrian Gonzalez
<[email protected]>
Envoyé le : Vendredi 8 juillet 2016 16h27
Objet : Re: Query : get all groups of a user
Shoot, searching since hours, and think I just found a ways,something like [1]
should do the trick.
I'll update the thread once it works ;)
Thanks
[1]
List<Integer> groupKeys = new ArrayList<Integer>();
for (Membership membership : userTO.getMemberships) { if (""GROUP".equals
(membership.getRightType()) { groupKeys.add(membership.getRightKey()); }
}GroupFiqlSearchConditionBuilder fiql =
SyncopeClient.getGroupSearchConditionBuilder();for (int key : keys) {
fiql.or("key").equalTo(key);}
new AnySearchQuery.Builder().realm(SyncopeConstants.ROOT_REALM)
.fiql(fiql.query())
.build()
De : Adrian Gonzalez <[email protected]>
À : "[email protected]" <[email protected]>
Envoyé le : Vendredi 8 juillet 2016 16h14
Objet : Query : get all groups of a user
Hello,
Sorry, I'm a bit stuck, should be easy, but I don't find.
How can I get all the groups (and their scimid atribute) of a User with a
single call to syncope ?I'm using syncope Client API and have already an
instance of UserTO.
>From what I see, in userTO I have the memberships, but I can't get the group's
>scimid from there.
I'm having a look at
https://github.com/apache/syncope/blob/master/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SearchITCase.java,
but no inspiration.
Thanks,Adrian