diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2013-09-27 16:01:55 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2013-09-27 16:02:35 +0200 |
commit | 6c02efe9cfba30f7f0c85e91e9e8812e1be162f6 (patch) | |
tree | b3e92324be810e4341d5922168dd3fbc3c97b638 /sonar-core | |
parent | e55867dca88e32594461805e90d363898d7b7ecf (diff) | |
download | sonarqube-6c02efe9cfba30f7f0c85e91e9e8812e1be162f6.tar.gz sonarqube-6c02efe9cfba30f7f0c85e91e9e8812e1be162f6.zip |
SONAR-4646 Deleting a user should not lead to delete its 'shared' dashboards/filters
Diffstat (limited to 'sonar-core')
5 files changed, 31 insertions, 12 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/user/UserDao.java b/sonar-core/src/main/java/org/sonar/core/user/UserDao.java index a3c21ea51d9..08624145961 100644 --- a/sonar-core/src/main/java/org/sonar/core/user/UserDao.java +++ b/sonar-core/src/main/java/org/sonar/core/user/UserDao.java @@ -116,10 +116,10 @@ public class UserDao implements BatchComponent, ServerComponent { mapper.removeUserFromGroups(dto.getId()); mapper.deleteUserActiveDashboards(dto.getId()); - mapper.deleteUserDashboards(dto.getId()); - mapper.deleteUserIssueFilters(dto.getLogin()); + mapper.deleteUnsharedUserDashboards(dto.getId()); + mapper.deleteUnsharedUserIssueFilters(dto.getLogin()); mapper.deleteUserIssueFilterFavourites(dto.getLogin()); - mapper.deleteUserMeasureFilters(dto.getId()); + mapper.deleteUnsharedUserMeasureFilters(dto.getId()); mapper.deleteUserMeasureFilterFavourites(dto.getId()); mapper.deleteUserProperties(dto.getId()); mapper.deleteUserRoles(dto.getId()); diff --git a/sonar-core/src/main/java/org/sonar/core/user/UserMapper.java b/sonar-core/src/main/java/org/sonar/core/user/UserMapper.java index b8d0a9b8459..3e5780dac56 100644 --- a/sonar-core/src/main/java/org/sonar/core/user/UserMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/user/UserMapper.java @@ -48,13 +48,13 @@ public interface UserMapper { void deleteUserActiveDashboards(long userId); - void deleteUserDashboards(long userId); + void deleteUnsharedUserDashboards(long userId); - void deleteUserIssueFilters(String login); + void deleteUnsharedUserIssueFilters(String login); void deleteUserIssueFilterFavourites(String login); - void deleteUserMeasureFilters(long userId); + void deleteUnsharedUserMeasureFilters(long userId); void deleteUserMeasureFilterFavourites(long userId); diff --git a/sonar-core/src/main/resources/org/sonar/core/user/UserMapper.xml b/sonar-core/src/main/resources/org/sonar/core/user/UserMapper.xml index 0cd5fbbce41..f0368bf8bab 100644 --- a/sonar-core/src/main/resources/org/sonar/core/user/UserMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/user/UserMapper.xml @@ -73,24 +73,24 @@ DELETE FROM properties WHERE user_id=#{id} </delete> - <delete id="deleteUserDashboards" parameterType="long"> - DELETE FROM dashboards WHERE user_id=#{id} + <delete id="deleteUnsharedUserDashboards" parameterType="long"> + DELETE FROM dashboards WHERE user_id=#{id} and shared <> ${_true} </delete> <delete id="deleteUserActiveDashboards" parameterType="long"> DELETE FROM active_dashboards WHERE user_id=#{id} </delete> - <delete id="deleteUserMeasureFilters" parameterType="long"> - DELETE FROM measure_filters WHERE user_id=#{id} + <delete id="deleteUnsharedUserMeasureFilters" parameterType="long"> + DELETE FROM measure_filters WHERE user_id=#{id} and shared <> ${_true} </delete> <delete id="deleteUserMeasureFilterFavourites" parameterType="long"> DELETE FROM measure_filter_favourites WHERE user_id=#{id} </delete> - <delete id="deleteUserIssueFilters" parameterType="String"> - DELETE FROM issue_filters WHERE user_login=#{id} + <delete id="deleteUnsharedUserIssueFilters" parameterType="String"> + DELETE FROM issue_filters WHERE user_login=#{id} and shared <> ${_true} </delete> <delete id="deleteUserIssueFilterFavourites" parameterType="String"> diff --git a/sonar-core/src/test/resources/org/sonar/core/user/UserDaoTest/deactivate_user-result.xml b/sonar-core/src/test/resources/org/sonar/core/user/UserDaoTest/deactivate_user-result.xml index 7ec29baf07d..1ee485b9812 100644 --- a/sonar-core/src/test/resources/org/sonar/core/user/UserDaoTest/deactivate_user-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/user/UserDaoTest/deactivate_user-result.xml @@ -36,11 +36,21 @@ <users id="101" login="jcdus" name="Jean-Claude Dus" email="jcdus@lesbronzes.fr" created_at="2011-05-18" updated_at="2012-07-21" active="[true]"/> <dashboards id="2" user_id="101" NAME="[null]" COLUMN_LAYOUT="[null]" CREATED_AT="[null]" DESCRIPTION="[null]" IS_GLOBAL="[false]" SHARED="[false]" UPDATED_AT="[null]"/> <active_dashboards id="2" user_id="101" dashboard_id="2" ORDER_INDEX="[null]"/> + <active_dashboards id="4" user_id="101" dashboard_id="3" ORDER_INDEX="[null]"/> <issue_filters id="2" user_login="jcdus" name="My issues" CREATED_AT="[null]" DATA="[null]" DESCRIPTION="[null]" SHARED="[false]" UPDATED_AT="[null]"/> <issue_filter_favourites id="2" user_login="jcdus" issue_filter_id="2" CREATED_AT="[null]"/> + <issue_filter_favourites id="4" user_login="jcdus" issue_filter_id="3" CREATED_AT="[null]"/> <measure_filters id="2" user_id="101" name="My measures" CREATED_AT="[null]" DATA="[null]" DESCRIPTION="[null]" SHARED="[false]" UPDATED_AT="[null]"/> <measure_filter_favourites id="2" user_id="101" measure_filter_id="2" CREATED_AT="[null]"/> + <measure_filter_favourites id="4" user_id="101" measure_filter_id="3" CREATED_AT="[null]"/> <properties id="2" user_id="101" PROP_KEY="[null]" RESOURCE_ID="[null]" TEXT_VALUE="[null]" /> <groups_users user_id="101" group_id="200"/> <user_roles id="2" user_id="101" role="admin" RESOURCE_ID="[null]"/> + + <!-- Not deleted because shared --> + <dashboards id="3" user_id="100" NAME="[null]" COLUMN_LAYOUT="[null]" CREATED_AT="[null]" DESCRIPTION="[null]" IS_GLOBAL="[false]" SHARED="[true]" UPDATED_AT="[null]"/> + <issue_filters id="3" user_login="marius" name="My shared issues" CREATED_AT="[null]" DATA="[null]" DESCRIPTION="[null]" SHARED="[true]" UPDATED_AT="[null]"/> + <measure_filters id="3" user_id="100" name="My shared measures" CREATED_AT="[null]" DATA="[null]" DESCRIPTION="[null]" SHARED="[true]" UPDATED_AT="[null]"/> + + </dataset> diff --git a/sonar-core/src/test/resources/org/sonar/core/user/UserDaoTest/deactivate_user.xml b/sonar-core/src/test/resources/org/sonar/core/user/UserDaoTest/deactivate_user.xml index 1b102962bcd..e1891e18d3a 100644 --- a/sonar-core/src/test/resources/org/sonar/core/user/UserDaoTest/deactivate_user.xml +++ b/sonar-core/src/test/resources/org/sonar/core/user/UserDaoTest/deactivate_user.xml @@ -20,11 +20,17 @@ <dataset> <users id="100" login="marius" name="Marius" email="marius@lesbronzes.fr" created_at="2011-05-18" updated_at="2012-07-21" active="[true]"/> <dashboards id="1" user_id="100" NAME="[null]" COLUMN_LAYOUT="[null]" CREATED_AT="[null]" DESCRIPTION="[null]" IS_GLOBAL="[false]" SHARED="[false]" UPDATED_AT="[null]"/> + <dashboards id="3" user_id="100" NAME="[null]" COLUMN_LAYOUT="[null]" CREATED_AT="[null]" DESCRIPTION="[null]" IS_GLOBAL="[false]" SHARED="[true]" UPDATED_AT="[null]"/> <active_dashboards id="1" user_id="100" dashboard_id="1" ORDER_INDEX="[null]"/> + <active_dashboards id="3" user_id="100" dashboard_id="3" ORDER_INDEX="[null]"/> <issue_filters id="1" user_login="marius" name="My issues" CREATED_AT="[null]" DATA="[null]" DESCRIPTION="[null]" SHARED="[false]" UPDATED_AT="[null]"/> + <issue_filters id="3" user_login="marius" name="My shared issues" CREATED_AT="[null]" DATA="[null]" DESCRIPTION="[null]" SHARED="[true]" UPDATED_AT="[null]"/> <issue_filter_favourites id="1" user_login="marius" issue_filter_id="1" CREATED_AT="[null]"/> + <issue_filter_favourites id="3" user_login="marius" issue_filter_id="3" CREATED_AT="[null]"/> <measure_filters id="1" user_id="100" name="My measures" CREATED_AT="[null]" DATA="[null]" DESCRIPTION="[null]" SHARED="[false]" UPDATED_AT="[null]"/> + <measure_filters id="3" user_id="100" name="My shared measures" CREATED_AT="[null]" DATA="[null]" DESCRIPTION="[null]" SHARED="[true]" UPDATED_AT="[null]"/> <measure_filter_favourites id="1" user_id="100" measure_filter_id="1" CREATED_AT="[null]"/> + <measure_filter_favourites id="3" user_id="100" measure_filter_id="3" CREATED_AT="[null]"/> <properties id="1" user_id="100" PROP_KEY="[null]" RESOURCE_ID="[null]" TEXT_VALUE="[null]" /> <groups_users user_id="100" group_id="200"/> <user_roles id="1" user_id="100" role="admin" RESOURCE_ID="[null]"/> @@ -32,10 +38,13 @@ <users id="101" login="jcdus" name="Jean-Claude Dus" email="jcdus@lesbronzes.fr" created_at="2011-05-18" updated_at="2012-07-21" active="[true]"/> <dashboards id="2" user_id="101" NAME="[null]" COLUMN_LAYOUT="[null]" CREATED_AT="[null]" DESCRIPTION="[null]" IS_GLOBAL="[false]" SHARED="[false]" UPDATED_AT="[null]"/> <active_dashboards id="2" user_id="101" dashboard_id="2" ORDER_INDEX="[null]"/> + <active_dashboards id="4" user_id="101" dashboard_id="3" ORDER_INDEX="[null]"/> <issue_filters id="2" user_login="jcdus" name="My issues" CREATED_AT="[null]" DATA="[null]" DESCRIPTION="[null]" SHARED="[false]" UPDATED_AT="[null]"/> <issue_filter_favourites id="2" user_login="jcdus" issue_filter_id="2" CREATED_AT="[null]"/> + <issue_filter_favourites id="4" user_login="jcdus" issue_filter_id="3" CREATED_AT="[null]"/> <measure_filters id="2" user_id="101" name="My measures" CREATED_AT="[null]" DATA="[null]" DESCRIPTION="[null]" SHARED="[false]" UPDATED_AT="[null]"/> <measure_filter_favourites id="2" user_id="101" measure_filter_id="2" CREATED_AT="[null]"/> + <measure_filter_favourites id="4" user_id="101" measure_filter_id="3" CREATED_AT="[null]"/> <properties id="2" user_id="101" PROP_KEY="[null]" RESOURCE_ID="[null]" TEXT_VALUE="[null]" /> <groups_users user_id="101" group_id="200"/> <user_roles id="2" user_id="101" role="admin" RESOURCE_ID="[null]"/> |