Search in sources :

Example 1 with UsersWsResponse

use of org.sonarqube.ws.Permissions.UsersWsResponse in project sonarqube by SonarSource.

the class UsersAction method handle.

@Override
public void handle(Request request, Response response) throws Exception {
    try (DbSession dbSession = dbClient.openSession(false)) {
        Optional<ComponentDto> project = wsSupport.findProject(dbSession, request);
        wsSupport.checkPermissionManagementAccess(userSession, project.orElse(null));
        PermissionQuery query = buildPermissionQuery(request, project.orElse(null));
        List<UserDto> users = findUsers(dbSession, query);
        int total = dbClient.userPermissionDao().countUsersByQuery(dbSession, query);
        List<UserPermissionDto> userPermissions = findUserPermissions(dbSession, users, project.orElse(null));
        Paging paging = Paging.forPageIndex(request.mandatoryParamAsInt(Param.PAGE)).withPageSize(query.getPageSize()).andTotal(total);
        UsersWsResponse usersWsResponse = buildResponse(users, userPermissions, paging);
        writeProtobuf(usersWsResponse, request, response);
    }
}
Also used : DbSession(org.sonar.db.DbSession) UserDto(org.sonar.db.user.UserDto) Paging(org.sonar.api.utils.Paging) ComponentDto(org.sonar.db.component.ComponentDto) UserPermissionDto(org.sonar.db.permission.UserPermissionDto) PermissionQuery(org.sonar.db.permission.PermissionQuery) UsersWsResponse(org.sonarqube.ws.Permissions.UsersWsResponse)

Aggregations

Paging (org.sonar.api.utils.Paging)1 DbSession (org.sonar.db.DbSession)1 ComponentDto (org.sonar.db.component.ComponentDto)1 PermissionQuery (org.sonar.db.permission.PermissionQuery)1 UserPermissionDto (org.sonar.db.permission.UserPermissionDto)1 UserDto (org.sonar.db.user.UserDto)1 UsersWsResponse (org.sonarqube.ws.Permissions.UsersWsResponse)1