diff options
author | Jean-Baptiste Vilain <jean-baptiste.vilain@sonarsource.com> | 2013-07-08 11:00:04 +0200 |
---|---|---|
committer | Jean-Baptiste Vilain <jean-baptiste.vilain@sonarsource.com> | 2013-07-08 11:00:04 +0200 |
commit | 8ca0f28d2bffeb8e8ea3212d84e89685c2d19842 (patch) | |
tree | 6cc13786dbb576e715f211ef5420a6ca4674b7f2 /sonar-core/src/main | |
parent | 1ace6fef25bfce62a9b96a3a079e80cb75f819a7 (diff) | |
download | sonarqube-8ca0f28d2bffeb8e8ea3212d84e89685c2d19842.tar.gz sonarqube-8ca0f28d2bffeb8e8ea3212d84e89685c2d19842.zip |
SONAR-4466 Added controller and pages to handle CRUD operations on permission templates
Diffstat (limited to 'sonar-core/src/main')
3 files changed, 24 insertions, 0 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/user/PermissionDao.java b/sonar-core/src/main/java/org/sonar/core/user/PermissionDao.java index 14deada2ff3..2d1e499c6fc 100644 --- a/sonar-core/src/main/java/org/sonar/core/user/PermissionDao.java +++ b/sonar-core/src/main/java/org/sonar/core/user/PermissionDao.java @@ -110,6 +110,22 @@ public class PermissionDao implements TaskExtension, ServerExtension { } } + public void updatePermissionTemplate(Long templateId, String templateName, @Nullable String description) { + PermissionTemplateDto permissionTemplate = new PermissionTemplateDto() + .setId(templateId) + .setName(templateName) + .setDescription(description) + .setUpdatedAt(now()); + SqlSession session = myBatis.openSession(); + try { + PermissionTemplateMapper mapper = session.getMapper(PermissionTemplateMapper.class); + mapper.update(permissionTemplate); + session.commit(); + } finally { + MyBatis.closeQuietly(session); + } + } + public void addUserPermission(Long templateId, Long userId, String permission) { PermissionTemplateUserDto permissionTemplateUser = new PermissionTemplateUserDto() .setTemplateId(templateId) diff --git a/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateMapper.java b/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateMapper.java index f3f3f85f884..124492f07a5 100644 --- a/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateMapper.java @@ -27,6 +27,8 @@ public interface PermissionTemplateMapper { void insert(PermissionTemplateDto permissionTemplate); + void update(PermissionTemplateDto permissionTemplate); + void delete(Long templateId); void deleteUsersPermissions(Long templateId); diff --git a/sonar-core/src/main/resources/org/sonar/core/user/PermissionTemplateMapper.xml b/sonar-core/src/main/resources/org/sonar/core/user/PermissionTemplateMapper.xml index 0cabe293958..d07c5232aab 100644 --- a/sonar-core/src/main/resources/org/sonar/core/user/PermissionTemplateMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/user/PermissionTemplateMapper.xml @@ -8,6 +8,12 @@ VALUES (#{name}, #{description}, #{createdAt}, #{updatedAt}) </insert> + <update id="update" parameterType="PermissionTemplate"> + UPDATE permission_templates + SET name = #{name}, description = #{description}, updated_at = #{updatedAt} + WHERE id = #{id} + </update> + <delete id="delete" parameterType="Long"> DELETE FROM permission_templates WHERE id = #{templateId} |