diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2013-04-19 13:39:23 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2013-04-19 13:50:58 +0200 |
commit | 7f8c6bc89dbc2f5a1792b17228b1a17b2c8483d6 (patch) | |
tree | 82db25d1945e42e1b11d274f8d8784feb957f731 /sonar-server | |
parent | 455c2922640c42a504caf3e32beb38ba5c64905b (diff) | |
download | sonarqube-7f8c6bc89dbc2f5a1792b17228b1a17b2c8483d6.tar.gz sonarqube-7f8c6bc89dbc2f5a1792b17228b1a17b2c8483d6.zip |
SONAR-3755 rename Issue#message() to description()
Diffstat (limited to 'sonar-server')
7 files changed, 88 insertions, 22 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/issue/DefaultJRubyIssues.java b/sonar-server/src/main/java/org/sonar/server/issue/DefaultJRubyIssues.java index 07887c8073e..29b013e7f35 100644 --- a/sonar-server/src/main/java/org/sonar/server/issue/DefaultJRubyIssues.java +++ b/sonar-server/src/main/java/org/sonar/server/issue/DefaultJRubyIssues.java @@ -28,6 +28,7 @@ import org.sonar.api.issue.IssueQuery; import org.sonar.api.issue.JRubyIssues; import org.sonar.api.rule.RuleKey; import org.sonar.api.utils.DateUtils; +import org.sonar.api.web.UserRole; import org.sonar.server.ui.JRubyFacades; import javax.annotation.Nullable; @@ -50,8 +51,11 @@ public class DefaultJRubyIssues implements JRubyIssues { JRubyFacades.setIssues(this); } + /** + * Requires the role {@link org.sonar.api.web.UserRole#CODEVIEWER} + */ public IssueFinder.Results find(Map<String, Object> params, Integer currentUserId) { - return finder.find(newQuery(params), currentUserId); + return finder.find(newQuery(params), currentUserId, UserRole.CODEVIEWER); } IssueQuery newQuery(Map<String, Object> props) { @@ -64,7 +68,7 @@ public class DefaultJRubyIssues implements JRubyIssues { builder.componentRoots(toStrings(props.get("componentRoots"))); builder.rules(toRules(props.get("rules"))); builder.userLogins(toStrings(props.get("userLogins"))); - builder.assigneeLogins(toStrings(props.get("assigneeLogins"))); + builder.assignees(toStrings(props.get("assignees"))); builder.createdAfter(toDate(props.get("createdAfter"))); builder.createdBefore(toDate(props.get("createdBefore"))); builder.limit(toInteger(props.get("limit"))); diff --git a/sonar-server/src/main/java/org/sonar/server/issue/ServerIssueChanges.java b/sonar-server/src/main/java/org/sonar/server/issue/ServerIssueChanges.java new file mode 100644 index 00000000000..0fce2d9edcd --- /dev/null +++ b/sonar-server/src/main/java/org/sonar/server/issue/ServerIssueChanges.java @@ -0,0 +1,68 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2012 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar 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. + * + * Sonar 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 Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.server.issue; + +import org.sonar.api.issue.Issue; +import org.sonar.api.issue.IssueChange; +import org.sonar.api.web.UserRole; +import org.sonar.core.issue.DefaultIssue; +import org.sonar.core.issue.IssueDao; +import org.sonar.core.issue.IssueDto; +import org.sonar.core.user.AuthorizationDao; + +import javax.annotation.Nullable; +import java.util.Arrays; + +/** + * @since 3.6 + */ +public class ServerIssueChanges { + + private final IssueDao issueDao; + private final AuthorizationDao authorizationDao; + + public ServerIssueChanges(IssueDao issueDao, AuthorizationDao authorizationDao) { + this.issueDao = issueDao; + this.authorizationDao = authorizationDao; + } + + public Issue change(String issueKey, IssueChange change, @Nullable Integer userId) { + if (userId == null) { + // must be logged + throw new IllegalStateException("User is not logged in"); + } + IssueDto dto = issueDao.selectByKey(issueKey); + if (dto == null) { + throw new IllegalStateException("Unknown issue: " + issueKey); + } + String requiredRole = UserRole.USER; + if (!authorizationDao.isAuthorizedComponentId(dto.getResourceId(), userId, requiredRole)) { + throw new IllegalStateException("User does not have the role " + requiredRole + " required to change the issue: " + issueKey); + } + DefaultIssue issue = dto.toDefaultIssue(); + if (change.hasChanges()) { + // TODO apply changes + issueDao.update(Arrays.asList(IssueDto.toDto(issue, dto.getResourceId(), dto.getRuleId()))); + } + + + return issue; + } +} diff --git a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java index a58f005db8e..25f2e016f69 100644 --- a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java +++ b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java @@ -77,6 +77,7 @@ import org.sonar.server.configuration.Backup; import org.sonar.server.configuration.ProfilesManager; import org.sonar.server.database.EmbeddedDatabaseFactory; import org.sonar.server.issue.DefaultJRubyIssues; +import org.sonar.server.issue.ServerIssueChanges; import org.sonar.server.macro.MacroInterpreter; import org.sonar.server.notifications.NotificationCenter; import org.sonar.server.notifications.NotificationService; @@ -268,6 +269,7 @@ public final class Platform { servicesContainer.addSingleton(Periods.class); servicesContainer.addSingleton(DefaultIssueFinder.class); servicesContainer.addSingleton(DefaultJRubyIssues.class); + servicesContainer.addSingleton(ServerIssueChanges.class); // Notifications servicesContainer.addSingleton(EmailSettings.class); diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/issues_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/issues_controller.rb index ac9515d9efe..52dd0f0432d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/issues_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/issues_controller.rb @@ -58,16 +58,16 @@ class Api::IssuesController < Api::ApiController :key => issue.key, :component => issue.componentKey, :rule => issue.ruleKey.toString(), - :status => issue.status, - :resolution => issue.resolution + :resolution => issue.resolution, + :status => issue.status } json[:severity] = issue.severity if issue.severity json[:title] = issue.title if issue.title - json[:desc] = issue.message if issue.message + json[:desc] = issue.description if issue.description json[:line] = issue.line if issue.line json[:cost] = issue.cost if issue.cost json[:userLogin] = issue.userLogin if issue.userLogin - json[:assignee] = issue.assigneeLogin if issue.assigneeLogin + json[:assignee] = issue.assignee if issue.assignee json[:createdAt] = format_java_datetime(issue.createdAt) if issue.createdAt json[:updatedAt] = format_java_datetime(issue.updatedAt) if issue.updatedAt json[:closedAt] = format_java_datetime(issue.closedAt) if issue.closedAt diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_controller.rb index e60daf9c9d1..89f5c5b2935 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_controller.rb @@ -28,9 +28,7 @@ class IssuesController < ApplicationController def find_issues(map) user = current_user ? current_user.id : nil - issues = [] - Api.issues.find(map, user).issues.each {|issue| issues << issue} - issues + Api.issues.find(map, user).issues end end
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_list.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_list.html.erb index 32234197637..7f2034775f8 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_list.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_list.html.erb @@ -54,13 +54,6 @@ </th> </tr> </thead> - <tfoot> - <tr> - <td colspan="6"> - <%= paginate(@issues) -%> - </td> - </tr> - </tfoot> <tbody> <% @issues.each do |issue| @@ -84,7 +77,7 @@ <%= h(issue.title) %> </td> <td> - <%= h(issue.message) %> + <%= h(issue.description) %> </td> <td> <%= h issue.componentKey -%> @@ -99,10 +92,10 @@ <%= issue.cost -%> </td> <td> - <%= issue.user_login -%> + <%= issue.userLogin -%> </td> <td> - <%= issue.assignee_login -%> + <%= issue.assignee -%> </td> <td> <%= issue.attributes -%> diff --git a/sonar-server/src/test/java/org/sonar/server/issue/DefaultJRubyIssuesTest.java b/sonar-server/src/test/java/org/sonar/server/issue/DefaultJRubyIssuesTest.java index ad905028595..d44ce784705 100644 --- a/sonar-server/src/test/java/org/sonar/server/issue/DefaultJRubyIssuesTest.java +++ b/sonar-server/src/test/java/org/sonar/server/issue/DefaultJRubyIssuesTest.java @@ -27,6 +27,7 @@ import org.sonar.api.issue.IssueFinder; import org.sonar.api.issue.IssueQuery; import org.sonar.api.rule.RuleKey; import org.sonar.api.utils.DateUtils; +import org.sonar.api.web.UserRole; import java.util.Map; @@ -51,7 +52,7 @@ public class DefaultJRubyIssuesTest { public boolean matches(Object o) { return ((IssueQuery) o).keys().contains("ABCDE"); } - }), eq(123)); + }), eq(123), eq(UserRole.CODEVIEWER)); } @Test @@ -64,7 +65,7 @@ public class DefaultJRubyIssuesTest { map.put("components", newArrayList("org.apache")); map.put("componentRoots", newArrayList("org.sonar")); map.put("userLogins", newArrayList("marilyn")); - map.put("assigneeLogins", newArrayList("joanna")); + map.put("assignees", newArrayList("joanna")); map.put("createdAfter", "2013-04-16T09:08:24+0200"); map.put("createdBefore", "2013-04-17T09:08:24+0200"); map.put("rules", "squid:AvoidCycle,findbugs:NullReference"); @@ -79,7 +80,7 @@ public class DefaultJRubyIssuesTest { assertThat(query.components()).containsOnly("org.apache"); assertThat(query.componentRoots()).containsOnly("org.sonar"); assertThat(query.userLogins()).containsOnly("marilyn"); - assertThat(query.assigneeLogins()).containsOnly("joanna"); + assertThat(query.assignees()).containsOnly("joanna"); assertThat(query.rules()).hasSize(2); assertThat(query.createdAfter()).isEqualTo(DateUtils.parseDateTime("2013-04-16T09:08:24+0200")); assertThat(query.createdBefore()).isEqualTo(DateUtils.parseDateTime("2013-04-17T09:08:24+0200")); |