@Override public Account withACL(AuthenticatedAccount raw) { return raw.getAccount() // Global role .withGlobalRole( roleRepository.findGlobalRoleByAccount(raw.getAccount().id()).flatMap(rolesService::getGlobalRole) ) // Project roles .withProjectRoles( roleRepository.findProjectRoleAssociationsByAccount(raw.getAccount().id(), rolesService::getProjectRoleAssociation) ) // Groups from the repository .withGroups( accountGroupRepository.findByAccount(raw.getAccount().id()).stream() .map(this::groupWithACL) .collect(Collectors.toList()) ) // Group contributions .withGroups( accountGroupContributors.stream() .flatMap(accountGroupContributor -> accountGroupContributor.collectGroups(raw).stream()) .map(this::groupWithACL) .collect(Collectors.toList()) ) // OK .lock(); }