use of org.sonar.db.permission.PermissionQuery in project sonarqube by SonarSource.
the class AddUserToTemplateAction method isUserAlreadyAdded.
private boolean isUserAlreadyAdded(DbSession dbSession, long templateId, String userLogin, String permission) {
PermissionQuery permissionQuery = PermissionQuery.builder().setPermission(permission).build();
List<String> usersWithPermission = dbClient.permissionTemplateDao().selectUserLoginsByQueryAndTemplate(dbSession, permissionQuery, templateId);
return usersWithPermission.stream().anyMatch(s -> s.equals(userLogin));
}
use of org.sonar.db.permission.PermissionQuery in project sonarqube by SonarSource.
the class GroupsAction 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);
// TODO validatePermission(groupsRequest.getPermission(), wsProjectRef);
List<GroupDto> groups = findGroups(dbSession, org, query);
int total = dbClient.groupPermissionDao().countGroupsByQuery(dbSession, org.getUuid(), query);
List<GroupPermissionDto> groupsWithPermission = findGroupPermissions(dbSession, org, groups, projectId);
Paging paging = Paging.forPageIndex(request.mandatoryParamAsInt(Param.PAGE)).withPageSize(query.getPageSize()).andTotal(total);
WsGroupsResponse groupsResponse = buildResponse(groups, groupsWithPermission, paging);
writeProtobuf(groupsResponse, request, response);
}
}
Aggregations