Uploaded image for project: 'Syncope'
  1. Syncope
  2. SYNCOPE-902

Provide helper method to retrieve all the groups of a user

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-M4
    • Fix Version/s: 2.0.0.M5
    • Component/s: client, console, core
    • Labels:
      None

      Description

      Syncope could provide a helper method to retrieve all the groups of a user.

      For the moment, we need to code something like :

      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();
      }
      

        Attachments

          Activity

            People

            • Assignee:
              ilgrosso Francesco Chicchiriccò
              Reporter:
              gonzalad gonzalad
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: