aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-09-04 10:38:18 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-09-04 10:38:18 +0200
commitb1c661b552fc1f76db2ed76b0c624712f2d8f3b2 (patch)
tree70c7cbdbe32d4a3c89b6089235cee9af86db328b /sonar-core
parent145e34cfa8c83e3351f92d1a00ba5a79be5ac39d (diff)
downloadsonarqube-b1c661b552fc1f76db2ed76b0c624712f2d8f3b2.tar.gz
sonarqube-b1c661b552fc1f76db2ed76b0c624712f2d8f3b2.zip
SONAR-5559 Implemente IssueAuthorization mapping
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/db/IssueAuthorizationDto.java75
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/db/IssueAuthorizationMapper.java27
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java3
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/issue/db/IssueAuthorizationMapper.xml17
4 files changed, 121 insertions, 1 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueAuthorizationDto.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueAuthorizationDto.java
new file mode 100644
index 00000000000..d66f0c9d231
--- /dev/null
+++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueAuthorizationDto.java
@@ -0,0 +1,75 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.core.issue.db;
+
+import org.sonar.core.persistence.Dto;
+
+import java.io.Serializable;
+import java.util.List;
+
+public final class IssueAuthorizationDto extends Dto<String> implements Serializable {
+
+ private String project;
+ private String permission;
+ private List<String> groups;
+ private List<String> users;
+
+ @Override
+ public String getKey() {
+ return null;
+ }
+
+ public String getProject() {
+ return project;
+ }
+
+ public IssueAuthorizationDto setProject(String project) {
+ this.project = project;
+ return this;
+ }
+
+ public String getPermission() {
+ return permission;
+ }
+
+ public IssueAuthorizationDto setPermission(String permission) {
+ this.permission = permission;
+ return this;
+ }
+
+ public List<String> getGroups() {
+ return groups;
+ }
+
+ public IssueAuthorizationDto setGroups(List<String> groups) {
+ this.groups = groups;
+ return this;
+ }
+
+ public List<String> getUsers() {
+ return users;
+ }
+
+ public IssueAuthorizationDto setUsers(List<String> users) {
+ this.users = users;
+ return this;
+ }
+}
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueAuthorizationMapper.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueAuthorizationMapper.java
new file mode 100644
index 00000000000..d327f7f938d
--- /dev/null
+++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueAuthorizationMapper.java
@@ -0,0 +1,27 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.core.issue.db;
+
+public interface IssueAuthorizationMapper {
+
+ IssueAuthorizationDto selectByKey(String key);
+
+}
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
index 3e9c9d2f5f4..58d40c93502 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
@@ -137,6 +137,7 @@ public class MyBatis implements BatchComponent, ServerComponent {
loadAlias(conf, "Measure", MeasureDto.class);
loadAlias(conf, "Metric", MetricDto.class);
loadAlias(conf, "Issue", IssueDto.class);
+ loadAlias(conf, "IssueAuthorization", IssueAuthorizationDto.class);
loadAlias(conf, "IssueChange", IssueChangeDto.class);
loadAlias(conf, "IssueFilter", IssueFilterDto.class);
loadAlias(conf, "IssueFilterFavourite", IssueFilterFavouriteDto.class);
@@ -163,7 +164,7 @@ public class MyBatis implements BatchComponent, ServerComponent {
loadMapper(conf, "org.sonar.core.permission.PermissionMapper");
Class<?>[] mappers = {ActivityMapper.class, ActiveDashboardMapper.class, AuthorMapper.class, DashboardMapper.class,
DependencyMapper.class, DuplicationMapper.class, GraphDtoMapper.class,
- IssueMapper.class, IssueStatsMapper.class, IssueChangeMapper.class, IssueFilterMapper.class, IssueFilterFavouriteMapper.class,
+ IssueMapper.class, IssueAuthorizationMapper.class, IssueStatsMapper.class, IssueChangeMapper.class, IssueFilterMapper.class, IssueFilterFavouriteMapper.class,
LoadedTemplateMapper.class, MeasureFilterMapper.class, Migration44Mapper.class, PermissionTemplateMapper.class, PropertiesMapper.class, PurgeMapper.class,
ResourceKeyUpdaterMapper.class, ResourceIndexerMapper.class, ResourceSnapshotMapper.class, RoleMapper.class, RuleMapper.class,
SchemaMigrationMapper.class, SemaphoreMapper.class, UserMapper.class, WidgetMapper.class, WidgetPropertyMapper.class,
diff --git a/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueAuthorizationMapper.xml b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueAuthorizationMapper.xml
new file mode 100644
index 00000000000..59dd1496014
--- /dev/null
+++ b/sonar-core/src/main/resources/org/sonar/core/issue/db/IssueAuthorizationMapper.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mappei.dtd">
+
+<mapper namespace="org.sonar.core.issue.db.IssueAuthorizationMapper">
+
+ <select id="selectByKey" parameterType="String" resultType="IssueAuthorization">
+ select *
+ from issues i
+ inner join rules r on r.id=i.rule_id
+ inner join projects p on p.id=i.component_id
+ inner join projects root on root.id=i.root_component_id
+ where i.kee=#{kee}
+ </select>
+
+</mapper>
+