syncope-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francesco Chicchiriccò (JIRA) <j...@apache.org>
Subject [jira] [Resolved] (SYNCOPE-902) Provide helper method to retrieve all the groups of a user
Date Mon, 18 Jul 2016 10:52:20 GMT

     [ https://issues.apache.org/jira/browse/SYNCOPE-902?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Francesco Chicchiriccò resolved SYNCOPE-902.
--------------------------------------------
    Resolution: Fixed

Here is the updated client snippet: https://gist.github.com/ilgrosso/3d56e9c57db283bfaef0068bdbc9b697#gistcomment-1826683

> Provide helper method to retrieve all the groups of a user
> ----------------------------------------------------------
>
>                 Key: SYNCOPE-902
>                 URL: https://issues.apache.org/jira/browse/SYNCOPE-902
>             Project: Syncope
>          Issue Type: Improvement
>          Components: client, console, core
>    Affects Versions: 2.0.0-M4
>            Reporter: gonzalad
>            Assignee: Francesco Chicchiriccò
>            Priority: Minor
>             Fix For: 2.0.0
>
>
> Syncope could provide a helper method to retrieve all the groups of a user.
> For the moment, we need to code something like :
> {code}
> 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();
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message