You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UserPermissionMapper.java 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2020 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. package org.sonar.db.permission;
  21. import java.util.Collection;
  22. import java.util.List;
  23. import java.util.Set;
  24. import org.apache.ibatis.annotations.Param;
  25. public interface UserPermissionMapper {
  26. List<UserPermissionDto> selectUserPermissionsByQueryAndUserUuids(@Param("query") PermissionQuery query, @Param("userUuids") Collection<String> userUuids);
  27. List<String> selectUserUuidsByQuery(@Param("query") PermissionQuery query);
  28. /**
  29. * Fetch user ids based on permission query and only in a specific scope (global permissions only, organization permissions only or project permissions only)
  30. */
  31. List<String> selectUserUuidsByQueryAndScope(@Param("query") PermissionQuery query);
  32. /**
  33. * Count the number of distinct users returned by {@link #selectUserUuidsByQuery(PermissionQuery)}
  34. * {@link PermissionQuery#getPageOffset()} and {@link PermissionQuery#getPageSize()} are ignored.
  35. */
  36. int countUsersByQuery(@Param("query") PermissionQuery query);
  37. /**
  38. * Count the number of users per permission for a given list of projects.
  39. * @param projectUuids a non-null and non-empty list of project ids
  40. */
  41. List<CountPerProjectPermission> countUsersByProjectPermission(@Param("projectUuids") List<String> projectUuids);
  42. /**
  43. * select id of users with at least one permission on the specified project but which do not have the specified permission.
  44. */
  45. Set<String> selectUserUuidsWithPermissionOnProjectBut(@Param("projectUuid") String projectUuid, @Param("permission") String permission);
  46. void insert(@Param("dto")UserPermissionDto dto, @Param("defaultOrgUuid") String defaultOrgUuid);
  47. void deleteGlobalPermission(@Param("userUuid") String userUuid, @Param("permission") String permission);
  48. void deleteProjectPermission(@Param("userUuid") String userUuid, @Param("permission") String permission,
  49. @Param("projectUuid") String projectUuid);
  50. void deleteProjectPermissions(@Param("projectUuid") String projectUuid);
  51. int deleteProjectPermissionOfAnyUser(@Param("projectUuid") String projectUuid, @Param("permission") String permission);
  52. List<String> selectGlobalPermissionsOfUser(@Param("userUuid") String userUuid);
  53. List<String> selectProjectPermissionsOfUser(@Param("userUuid") String userUuid, @Param("projectUuid") String projectUuid);
  54. void deleteByUserUuid(@Param("userUuid") String userUuid);
  55. }