From 4872092c687a2f5e9d91db44c2fc8ca6dcdc2081 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Fri, 10 Feb 2017 01:03:24 +0100 Subject: [PATCH] SONAR-8761 clean-up UserPermissionDao --- .../org/sonar/db/permission/UserPermissionDao.java | 7 ------- .../sonar/db/permission/UserPermissionMapper.java | 2 -- .../sonar/db/permission/UserPermissionMapper.xml | 6 ------ .../sonar/db/permission/UserPermissionDaoTest.java | 13 ++----------- 4 files changed, 2 insertions(+), 26 deletions(-) diff --git a/sonar-db/src/main/java/org/sonar/db/permission/UserPermissionDao.java b/sonar-db/src/main/java/org/sonar/db/permission/UserPermissionDao.java index 65ca4a89b5d..765a7ee03f2 100644 --- a/sonar-db/src/main/java/org/sonar/db/permission/UserPermissionDao.java +++ b/sonar-db/src/main/java/org/sonar/db/permission/UserPermissionDao.java @@ -82,13 +82,6 @@ public class UserPermissionDao implements Dao { return executeLargeInputs(projectIds, mapper(dbSession)::countUsersByProjectPermission); } - /** - * @return {@code true} if the project has at least one user permission defined, else returns {@code false} - */ - public boolean hasRootComponentPermissions(DbSession dbSession, long rootComponentId) { - return mapper(dbSession).countRowsByRootComponentId(rootComponentId) > 0; - } - /** * Gets all the global permissions granted to user for the specified organization. * diff --git a/sonar-db/src/main/java/org/sonar/db/permission/UserPermissionMapper.java b/sonar-db/src/main/java/org/sonar/db/permission/UserPermissionMapper.java index 7a693b5899c..2a6c7b32e07 100644 --- a/sonar-db/src/main/java/org/sonar/db/permission/UserPermissionMapper.java +++ b/sonar-db/src/main/java/org/sonar/db/permission/UserPermissionMapper.java @@ -48,8 +48,6 @@ public interface UserPermissionMapper { void insert(UserPermissionDto dto); - int countRowsByRootComponentId(@Param("rootComponentId") long projectId); - void deleteGlobalPermission(@Param("userId") long userId, @Param("permission") String permission, @Param("organizationUuid") String organizationUuid); diff --git a/sonar-db/src/main/resources/org/sonar/db/permission/UserPermissionMapper.xml b/sonar-db/src/main/resources/org/sonar/db/permission/UserPermissionMapper.xml index cfb0ea572b1..699ed00d86e 100644 --- a/sonar-db/src/main/resources/org/sonar/db/permission/UserPermissionMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/permission/UserPermissionMapper.xml @@ -80,12 +80,6 @@ group by ur.resource_id, ur.role - - insert into user_roles ( organization_uuid, diff --git a/sonar-db/src/test/java/org/sonar/db/permission/UserPermissionDaoTest.java b/sonar-db/src/test/java/org/sonar/db/permission/UserPermissionDaoTest.java index 837500eb7d7..528cd03b971 100644 --- a/sonar-db/src/test/java/org/sonar/db/permission/UserPermissionDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/permission/UserPermissionDaoTest.java @@ -319,15 +319,6 @@ public class UserPermissionDaoTest { assertThatProjectHasNoPermissions(project1); } - @Test - public void projectHasPermissions() { - addGlobalPermission(organizationDto, SYSTEM_ADMIN, user1); - addProjectPermission(organizationDto, USER, user1, project1); - - assertThat(underTest.hasRootComponentPermissions(dbSession, project1.getId())).isTrue(); - assertThat(underTest.hasRootComponentPermissions(dbSession, project2.getId())).isFalse(); - } - @Test public void selectGlobalPermissionsOfUser() { OrganizationDto org = dbTester.organizations().insert(); @@ -405,8 +396,8 @@ public class UserPermissionDaoTest { private void verifyOrganizationUuidsInTable(String... organizationUuids) { assertThat(dbTester.select("select organization_uuid as \"organizationUuid\" from user_roles")) - .extracting((row) -> (String) row.get("organizationUuid")) - .containsOnly(organizationUuids); + .extracting((row) -> (String) row.get("organizationUuid")) + .containsOnly(organizationUuids); } private void expectCount(List projectIds, CountPerProjectPermission... expected) { -- 2.39.5