Skip to content

Commit

Permalink
SONARCLOUD-381 Create api/organization/sync_members
Browse files Browse the repository at this point in the history
* Rename organisation to organization in some SonarCloud directories/classes
* Add WS api/organizations/sync_members
* Get list of members from a GitHub organization
* sync_members fails when members sync is disabled
  • Loading branch information
julienlancelot authored and sonartech committed Mar 6, 2019
1 parent 7636fd6 commit 2847ce4
Show file tree
Hide file tree
Showing 16 changed files with 834 additions and 387 deletions.
Expand Up @@ -41,7 +41,7 @@
public class AuthorizationDao implements Dao {

/**
* Loads all the permissions granted to logged-in user for the specified organization
* Loads all the permissions granted to user for the specified organization
*/
public Set<String> selectOrganizationPermissions(DbSession dbSession, String organizationUuid, int userId) {
return mapper(dbSession).selectOrganizationPermissions(organizationUuid, userId);
Expand Down Expand Up @@ -94,6 +94,14 @@ public int countUsersWithGlobalPermissionExcludingUser(DbSession dbSession, Stri
return mapper(dbSession).countUsersWithGlobalPermissionExcludingUser(organizationUuid, permission, excludedUserId);
}

/**
* The list of users who have the global permission.
* The anyone virtual group is not taken into account.
*/
public List<Integer> selectUserIdsWithGlobalPermission(DbSession dbSession, String organizationUuid, String permission) {
return mapper(dbSession).selectUserIdsWithGlobalPermission(organizationUuid, permission);
}

/**
* The number of users who will still have the permission if the user {@code userId}
* is removed from group {@code groupId}. The anyone virtual group is not taken into account.
Expand Down
Expand Up @@ -39,6 +39,8 @@ int countUsersWithGlobalPermissionExcludingGroup(@Param("organizationUuid") Stri
int countUsersWithGlobalPermissionExcludingUser(@Param("organizationUuid") String organizationUuid, @Param("permission") String permission,
@Param("excludedUserId") int excludedUserId);

List<Integer> selectUserIdsWithGlobalPermission(@Param("organizationUuid") String organizationUuid, @Param("permission") String permission);

int countUsersWithGlobalPermissionExcludingGroupMember(@Param("organizationUuid") String organizationUuid,
@Param("permission") String permission, @Param("groupId") int groupId, @Param("userId") int userId);

Expand Down
Expand Up @@ -173,6 +173,10 @@ public UserDto selectByExternalIdAndIdentityProvider(DbSession dbSession, String
return mapper(dbSession).selectByExternalIdAndIdentityProvider(externalId, externalIdentityProvider);
}

public List<UserDto> selectByExternalIdsAndIdentityProvider(DbSession dbSession, Collection<String> externalIds, String externalIdentityProvider) {
return executeLargeInputs(externalIds, e -> mapper(dbSession).selectByExternalIdsAndIdentityProvider(e, externalIdentityProvider));
}

@CheckForNull
public UserDto selectByExternalLoginAndIdentityProvider(DbSession dbSession, String externalLogin, String externalIdentityProvider) {
return mapper(dbSession).selectByExternalLoginAndIdentityProvider(externalLogin, externalIdentityProvider);
Expand Down
Expand Up @@ -62,6 +62,9 @@ public interface UserMapper {
@CheckForNull
UserDto selectByExternalIdAndIdentityProvider(@Param("externalId") String externalId, @Param("externalIdentityProvider") String externalExternalIdentityProvider);

List<UserDto> selectByExternalIdsAndIdentityProvider(@Param("externalIds") List<String> externalIds, @Param("externalIdentityProvider") String externalExternalIdentityProvider);

@CheckForNull
UserDto selectByExternalLoginAndIdentityProvider(@Param("externalLogin") String externalLogin, @Param("externalIdentityProvider") String externalExternalIdentityProvider);

void scrollAll(ResultHandler<UserDto> handler);
Expand Down

0 comments on commit 2847ce4

Please sign in to comment.