aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-core/src/main')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/user/PermissionDao.java16
-rw-r--r--sonar-core/src/main/java/org/sonar/core/user/PermissionTemplateMapper.java2
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/user/PermissionTemplateMapper.xml6
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}