diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-08-21 14:33:51 +0200 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-08-24 10:09:54 +0200 |
commit | 0e271c15e6aa0e77fb1edc1ba42d0589948d141d (patch) | |
tree | 9870a0a037c5fa2ae4153a6f951f2827e5305b87 /sonar-db | |
parent | bb85616bc47bdc6ea6e067c61adc6d99c55cf5af (diff) | |
download | sonarqube-0e271c15e6aa0e77fb1edc1ba42d0589948d141d.tar.gz sonarqube-0e271c15e6aa0e77fb1edc1ba42d0589948d141d.zip |
SONAR-6501 WS permissions/remove_user_from_template remove a user from a permission template
Diffstat (limited to 'sonar-db')
-rw-r--r-- | sonar-db/src/main/java/org/sonar/db/permission/PermissionTemplateDao.java | 22 | ||||
-rw-r--r-- | sonar-db/src/test/java/org/sonar/db/user/UserTesting.java | 15 |
2 files changed, 25 insertions, 12 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/permission/PermissionTemplateDao.java b/sonar-db/src/main/java/org/sonar/db/permission/PermissionTemplateDao.java index eb084a0de38..b5c58686816 100644 --- a/sonar-db/src/main/java/org/sonar/db/permission/PermissionTemplateDao.java +++ b/sonar-db/src/main/java/org/sonar/db/permission/PermissionTemplateDao.java @@ -243,20 +243,28 @@ public class PermissionTemplateDao implements Dao { session.commit(); } + /** + * @deprecated since 5.2 please use method with DbSession + */ + @Deprecated public void deleteUserPermission(Long templateId, Long userId, String permission) { - PermissionTemplateUserDto permissionTemplateUser = new PermissionTemplateUserDto() - .setTemplateId(templateId) - .setPermission(permission) - .setUserId(userId); - SqlSession session = myBatis.openSession(false); + DbSession session = myBatis.openSession(false); try { - mapper(session).deleteUserPermission(permissionTemplateUser); - session.commit(); + deleteUserPermission(session, templateId, userId, permission); } finally { MyBatis.closeQuietly(session); } } + public void deleteUserPermission(DbSession session, Long templateId, Long userId, String permission) { + PermissionTemplateUserDto permissionTemplateUser = new PermissionTemplateUserDto() + .setTemplateId(templateId) + .setPermission(permission) + .setUserId(userId); + mapper(session).deleteUserPermission(permissionTemplateUser); + session.commit(); + } + public void insertGroupPermission(Long templateId, @Nullable Long groupId, String permission) { PermissionTemplateGroupDto permissionTemplateGroup = new PermissionTemplateGroupDto() .setTemplateId(templateId) diff --git a/sonar-db/src/test/java/org/sonar/db/user/UserTesting.java b/sonar-db/src/test/java/org/sonar/db/user/UserTesting.java index 1dcb0fab207..2592ef1e2fb 100644 --- a/sonar-db/src/test/java/org/sonar/db/user/UserTesting.java +++ b/sonar-db/src/test/java/org/sonar/db/user/UserTesting.java @@ -20,14 +20,19 @@ package org.sonar.db.user; -import org.apache.commons.lang.RandomStringUtils; -import org.apache.commons.lang.math.RandomUtils; +import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; +import static org.apache.commons.lang.math.RandomUtils.nextBoolean; +import static org.apache.commons.lang.math.RandomUtils.nextLong; public class UserTesting { public static UserDto newUserDto() { - return new UserDto() - .setActive(RandomUtils.nextBoolean()) - .setLogin(RandomStringUtils.randomAlphanumeric(30)); + UserDto user = new UserDto() + .setActive(nextBoolean()) + .setName(randomAlphanumeric(30)) + .setLogin(randomAlphanumeric(30)); + user.setCreatedAt(nextLong()) + .setUpdatedAt(nextLong()); + return user; } } |