Search in sources :

Example 1 with UsersWsResponse

use of org.sonarqube.ws.WsPermissions.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)) {
        OrganizationDto org = support.findOrganization(dbSession, request.param(PARAM_ORGANIZATION));
        Optional<ProjectId> projectId = support.findProjectId(dbSession, request);
        checkProjectAdmin(userSession, org.getUuid(), projectId);
        PermissionQuery query = buildPermissionQuery(request, projectId);
        List<UserDto> users = findUsers(dbSession, org, query);
        int total = dbClient.userPermissionDao().countUsers(dbSession, org.getUuid(), query);
        List<UserPermissionDto> userPermissions = findUserPermissions(dbSession, org, users, projectId);
        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) ProjectId(org.sonar.server.permission.ProjectId) UserPermissionDto(org.sonar.db.permission.UserPermissionDto) OrganizationDto(org.sonar.db.organization.OrganizationDto) PermissionQuery(org.sonar.db.permission.PermissionQuery) UsersWsResponse(org.sonarqube.ws.WsPermissions.UsersWsResponse)

Aggregations

Paging (org.sonar.api.utils.Paging)1 DbSession (org.sonar.db.DbSession)1 OrganizationDto (org.sonar.db.organization.OrganizationDto)1 PermissionQuery (org.sonar.db.permission.PermissionQuery)1 UserPermissionDto (org.sonar.db.permission.UserPermissionDto)1 UserDto (org.sonar.db.user.UserDto)1 ProjectId (org.sonar.server.permission.ProjectId)1 UsersWsResponse (org.sonarqube.ws.WsPermissions.UsersWsResponse)1