diff options
author | Julien Lancelot <julien.lancelot@gmail.com> | 2013-06-18 18:54:40 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@gmail.com> | 2013-06-18 18:54:40 +0200 |
commit | 63deafdb8bac4e0f907397094f4855167d3dd1e5 (patch) | |
tree | 32e1393d880b0aadb82a95c4c73adc26731db5dd /sonar-core/src/main | |
parent | 076dc17e1f50c4b9c31759d4640ab24472a43469 (diff) | |
download | sonarqube-63deafdb8bac4e0f907397094f4855167d3dd1e5.tar.gz sonarqube-63deafdb8bac4e0f907397094f4855167d3dd1e5.zip |
SONAR-4394 Provide ability to share issue filters
Diffstat (limited to 'sonar-core/src/main')
9 files changed, 63 insertions, 8 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterDao.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterDao.java index d74fafd02ae..b4ffcaeb880 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterDao.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterDao.java @@ -80,6 +80,15 @@ public class IssueFilterDao implements BatchComponent, ServerComponent { } } + public List<IssueFilterDto> selectSharedForUser(String user) { + SqlSession session = mybatis.openSession(); + try { + return getMapper(session).selectSharedForUser(user); + } finally { + MyBatis.closeQuietly(session); + } + } + public void insert(IssueFilterDto filter) { SqlSession session = mybatis.openSession(); try { diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterDto.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterDto.java index ac366e66a1f..5a831c285fa 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterDto.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterDto.java @@ -33,7 +33,7 @@ public class IssueFilterDto { private Long id; private String name; private String userLogin; - private Boolean shared; + private boolean shared; private String description; private String data; private Date createdAt; diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterFavouriteDao.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterFavouriteDao.java index 2f692c1b967..17e2b17b1de 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterFavouriteDao.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterFavouriteDao.java @@ -64,10 +64,20 @@ public class IssueFilterFavouriteDao implements BatchComponent, ServerComponent } } - public void delete(Long id) { + public void delete(Long issueFilterFavouriteId) { SqlSession session = mybatis.openSession(); try { - getMapper(session).delete(id); + getMapper(session).delete(issueFilterFavouriteId); + session.commit(); + } finally { + MyBatis.closeQuietly(session); + } + } + + public void deleteByIssueFilterId(Long issueFilterId) { + SqlSession session = mybatis.openSession(); + try { + getMapper(session).deleteByIssueFilterId(issueFilterId); session.commit(); } finally { MyBatis.closeQuietly(session); diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterFavouriteMapper.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterFavouriteMapper.java index 03986f82118..d11fc9d1ca1 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterFavouriteMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterFavouriteMapper.java @@ -36,5 +36,7 @@ public interface IssueFilterFavouriteMapper { void insert(IssueFilterFavouriteDto filterFavourite); - void delete(Long id); + void delete(Long issueFilterFavouriteId); + + void deleteByIssueFilterId(Long issueFilterId); } diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterMapper.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterMapper.java index f07316f07a1..53cf2b936eb 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterMapper.java @@ -41,6 +41,8 @@ public interface IssueFilterMapper { List<IssueFilterDto> selectByUserWithOnlyFavoriteFilters(String user); + List<IssueFilterDto> selectSharedForUser(String user); + void insert(IssueFilterDto filter); void update(IssueFilterDto filter); diff --git a/sonar-core/src/main/java/org/sonar/core/user/AuthorizationDao.java b/sonar-core/src/main/java/org/sonar/core/user/AuthorizationDao.java index 90f0fcefb69..7a826417df0 100644 --- a/sonar-core/src/main/java/org/sonar/core/user/AuthorizationDao.java +++ b/sonar-core/src/main/java/org/sonar/core/user/AuthorizationDao.java @@ -27,10 +27,7 @@ import org.sonar.core.persistence.MyBatis; import javax.annotation.Nullable; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; -import java.util.Set; +import java.util.*; import static com.google.common.collect.Maps.newHashMap; @@ -92,4 +89,15 @@ public class AuthorizationDao implements ServerComponent { return session.selectList(sql, params); } + + public List<String> selectGlobalPermissions(String userLogin){ + SqlSession session = mybatis.openSession(); + try { + Map<String, Object> params = newHashMap(); + params.put("userLogin", userLogin); + return session.selectList("selectGlobalPermissions", params); + } finally { + MyBatis.closeQuietly(session); + } + } } diff --git a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueFilterFavouriteMapper.xml b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueFilterFavouriteMapper.xml index 3c8d2db4718..80c36ec8c09 100644 --- a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueFilterFavouriteMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueFilterFavouriteMapper.xml @@ -46,4 +46,8 @@ delete from issue_filter_favourites where id=#{id} </delete> + <delete id="deleteByIssueFilterId" parameterType="int"> + delete from issue_filter_favourites where issue_filter_id=#{issueFilterId} + </delete> + </mapper> diff --git a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueFilterMapper.xml b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueFilterMapper.xml index 2d62e89af3d..a31b00273c5 100644 --- a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueFilterMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueFilterMapper.xml @@ -52,6 +52,15 @@ </where> </select> + <select id="selectSharedForUser" parameterType="String" resultType="IssueFilter"> + select <include refid="issueFilterColumns"/> + from issue_filters filters + <where> + filters.shared=${_true} + and filters.user_login<>#{user} + </where> + </select> + <insert id="insert" parameterType="IssueFilter" useGeneratedKeys="true" keyProperty="id"> INSERT INTO issue_filters (name, user_login, shared, description, data, created_at, updated_at) VALUES (#{name}, #{userLogin}, #{shared}, #{description}, #{data}, #{createdAt}, #{updatedAt}) diff --git a/sonar-core/src/main/resources/org/sonar/core/user/AuthorizationMapper.xml b/sonar-core/src/main/resources/org/sonar/core/user/AuthorizationMapper.xml index 88677e1dd94..c872b7274ac 100644 --- a/sonar-core/src/main/resources/org/sonar/core/user/AuthorizationMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/user/AuthorizationMapper.xml @@ -67,4 +67,15 @@ </choose> </sql> + <select id="selectGlobalPermissions" parameterType="map" resultType="String"> + SELECT gr.role + FROM group_roles gr + inner join groups_users gu on gu.group_id=gr.id + inner join users u on u.id=gu.user_id + <where> + u.login=#{userLogin} + and gr.resource_id is null + </where> + </select> + </mapper> |