diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-02-10 01:03:12 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-02-10 23:32:48 +0100 |
commit | 20d28db2bd1b67d9d7f09ce19766318ef44d7fb5 (patch) | |
tree | 89c853debd578c831704f25b1546f3d2a3cb1459 /sonar-db | |
parent | 4ee759f2116996ae133bc1e2543c4e8a4d6c6320 (diff) | |
download | sonarqube-20d28db2bd1b67d9d7f09ce19766318ef44d7fb5.tar.gz sonarqube-20d28db2bd1b67d9d7f09ce19766318ef44d7fb5.zip |
SONAR-8761 clean-up GroupPermissionDao
Diffstat (limited to 'sonar-db')
4 files changed, 0 insertions, 46 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/permission/GroupPermissionDao.java b/sonar-db/src/main/java/org/sonar/db/permission/GroupPermissionDao.java index a0628d57d6d..4f1680a444d 100644 --- a/sonar-db/src/main/java/org/sonar/db/permission/GroupPermissionDao.java +++ b/sonar-db/src/main/java/org/sonar/db/permission/GroupPermissionDao.java @@ -96,14 +96,6 @@ public class GroupPermissionDao implements Dao { return mapper(session).selectProjectPermissionsOfGroup(organizationUuid, groupId, projectId); } - /** - * @return {@code true} if the project has at least one permission defined, whatever it is - * on a group or on "anyone", else returns {@code false} - */ - public boolean hasRootComponentPermissions(DbSession dbSession, long rootComponentId) { - return mapper(dbSession).countRowsByRootComponentId(rootComponentId) > 0; - } - public void insert(DbSession dbSession, GroupPermissionDto dto) { ensureComponentPermissionConsistency(dbSession, dto); ensureGroupPermissionConsistency(dbSession, dto); diff --git a/sonar-db/src/main/java/org/sonar/db/permission/GroupPermissionMapper.java b/sonar-db/src/main/java/org/sonar/db/permission/GroupPermissionMapper.java index 691001f0acd..9c6ebec558f 100644 --- a/sonar-db/src/main/java/org/sonar/db/permission/GroupPermissionMapper.java +++ b/sonar-db/src/main/java/org/sonar/db/permission/GroupPermissionMapper.java @@ -45,8 +45,6 @@ public interface GroupPermissionMapper { void delete(@Param("permission") String permission, @Param("organizationUuid") String organizationUuid, @Nullable @Param("groupId") Long groupId, @Nullable @Param("rootComponentId") Long rootComponentId); - int countRowsByRootComponentId(@Param("rootComponentId") long rootComponentId); - List<String> selectGlobalPermissionsOfGroup(@Param("organizationUuid") String organizationUuid, @Nullable @Param("groupId") Long groupId); diff --git a/sonar-db/src/main/resources/org/sonar/db/permission/GroupPermissionMapper.xml b/sonar-db/src/main/resources/org/sonar/db/permission/GroupPermissionMapper.xml index 9b254aa693a..9d011a5d647 100644 --- a/sonar-db/src/main/resources/org/sonar/db/permission/GroupPermissionMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/permission/GroupPermissionMapper.xml @@ -140,12 +140,6 @@ </choose> </select> - <select id="countRowsByRootComponentId" parameterType="long" resultType="int"> - select count(1) - from group_roles - where resource_id=#{rootComponentId,jdbcType=BIGINT} - </select> - <insert id="insert" parameterType="GroupPermission" keyColumn="id" useGeneratedKeys="true" keyProperty="id"> insert into group_roles ( organization_uuid, diff --git a/sonar-db/src/test/java/org/sonar/db/permission/GroupPermissionDaoTest.java b/sonar-db/src/test/java/org/sonar/db/permission/GroupPermissionDaoTest.java index 2fef90304d5..d412c1f594d 100644 --- a/sonar-db/src/test/java/org/sonar/db/permission/GroupPermissionDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/permission/GroupPermissionDaoTest.java @@ -331,36 +331,6 @@ public class GroupPermissionDaoTest { } @Test - public void projectHasPermissions_is_false_if_no_permissions_at_all() { - OrganizationDto organizationDto = db.organizations().insert(); - ComponentDto project1 = db.components().insertProject(organizationDto); - db.users().insertPermissionOnAnyone(organizationDto, "perm1"); - - assertThat(underTest.hasRootComponentPermissions(dbSession, project1.getId())).isFalse(); - } - - @Test - public void projectHasPermissions_is_true_if_at_least_one_permission_on_group() { - OrganizationDto organizationDto = db.organizations().insert(); - GroupDto group1 = db.users().insertGroup(organizationDto); - ComponentDto project1 = db.components().insertProject(organizationDto); - db.users().insertProjectPermissionOnGroup(group1, "perm1", project1); - - assertThat(underTest.hasRootComponentPermissions(dbSession, project1.getId())).isTrue(); - } - - @Test - public void projectHasPermissions_is_true_if_at_least_one_permission_on_anyone() { - OrganizationDto org = db.organizations().insert(); - ComponentDto project1 = db.components().insertProject(org); - ComponentDto project2 = db.components().insertProject(org); - db.users().insertProjectPermissionOnAnyone("perm1", project1); - - assertThat(underTest.hasRootComponentPermissions(dbSession, project1.getId())).isTrue(); - assertThat(underTest.hasRootComponentPermissions(dbSession, project2.getId())).isFalse(); - } - - @Test public void deleteByRootComponentId() { OrganizationDto org = db.organizations().insert(); GroupDto group1 = db.users().insertGroup(org); |