summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-08-05 14:15:40 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-08-05 19:32:14 +0200
commite518e7cde4b3583df1978ac70fc03195784bb5f2 (patch)
tree95c2e985c7ba95795b298020204a4f0b77b09ddf /server
parent9c468c36ec6c64a6706f28ab3fc6993883451fee (diff)
downloadsonarqube-e518e7cde4b3583df1978ac70fc03195784bb5f2.tar.gz
sonarqube-e518e7cde4b3583df1978ac70fc03195784bb5f2.zip
Do not allow componentId nor msg on primary location
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/issue/TrackerRawInputFactory.java37
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java37
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java9
3 files changed, 46 insertions, 37 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/TrackerRawInputFactory.java b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/TrackerRawInputFactory.java
index f9ce138eea6..59ca037c8bd 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/TrackerRawInputFactory.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/TrackerRawInputFactory.java
@@ -131,7 +131,9 @@ public class TrackerRawInputFactory {
DbIssues.Locations.Builder dbLocationsBuilder = DbIssues.Locations.newBuilder();
if (reportIssue.hasPrimaryLocation()) {
BatchReport.IssueLocation location = reportIssue.getPrimaryLocation();
- dbLocationsBuilder.setPrimary(convertLocation(location));
+ if (location.hasTextRange()) {
+ dbLocationsBuilder.setPrimary(convertTextRange(location.getTextRange()));
+ }
}
for (BatchReport.IssueLocation location : reportIssue.getAdditionalLocationList()) {
dbLocationsBuilder.addSecondary(convertLocation(location));
@@ -139,7 +141,7 @@ public class TrackerRawInputFactory {
for (BatchReport.ExecutionFlow flow : reportIssue.getExecutionFlowList()) {
DbIssues.ExecutionFlow.Builder dbFlowBuilder = DbIssues.ExecutionFlow.newBuilder();
for (BatchReport.IssueLocation location : flow.getLocationList()) {
- dbFlowBuilder.addLocations(convertLocation(location));
+ dbFlowBuilder.addLocation(convertLocation(location));
}
dbLocationsBuilder.addExecutionFlow(dbFlowBuilder);
}
@@ -167,22 +169,27 @@ public class TrackerRawInputFactory {
}
if (source.hasTextRange()) {
BatchReport.TextRange sourceRange = source.getTextRange();
- DbCommons.TextRange.Builder targetRange = DbCommons.TextRange.newBuilder();
- if (sourceRange.hasStartLine()) {
- targetRange.setStartLine(sourceRange.getStartLine());
- }
- if (sourceRange.hasStartOffset()) {
- targetRange.setStartOffset(sourceRange.getStartOffset());
- }
- if (sourceRange.hasEndLine()) {
- targetRange.setEndLine(sourceRange.getEndLine());
- }
- if (sourceRange.hasEndOffset()) {
- targetRange.setEndOffset(sourceRange.getEndOffset());
- }
+ DbCommons.TextRange.Builder targetRange = convertTextRange(sourceRange);
target.setTextRange(targetRange);
}
return target.build();
}
}
+
+ private DbCommons.TextRange.Builder convertTextRange(BatchReport.TextRange sourceRange) {
+ DbCommons.TextRange.Builder targetRange = DbCommons.TextRange.newBuilder();
+ if (sourceRange.hasStartLine()) {
+ targetRange.setStartLine(sourceRange.getStartLine());
+ }
+ if (sourceRange.hasStartOffset()) {
+ targetRange.setStartOffset(sourceRange.getStartOffset());
+ }
+ if (sourceRange.hasEndLine()) {
+ targetRange.setEndLine(sourceRange.getEndLine());
+ }
+ if (sourceRange.hasEndOffset()) {
+ targetRange.setEndOffset(sourceRange.getEndOffset());
+ }
+ return targetRange;
+ }
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java
index 47b6c83616f..073f7af942f 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java
@@ -197,15 +197,15 @@ public class SearchResponseFormat {
DbIssues.Locations locations = dto.parseLocations();
if (locations != null) {
if (locations.hasPrimary()) {
- DbIssues.Location primary = locations.getPrimary();
- issueBuilder.setLocation(convertLocation(primary));
+ DbCommons.TextRange primary = locations.getPrimary();
+ issueBuilder.setTextRange(convertTextRange(primary));
}
for (DbIssues.Location secondary : locations.getSecondaryList()) {
issueBuilder.addSecondaryLocations(convertLocation(secondary));
}
for (DbIssues.ExecutionFlow flow : locations.getExecutionFlowList()) {
Issues.ExecutionFlow.Builder targetFlow = Issues.ExecutionFlow.newBuilder();
- for (DbIssues.Location flowLocation : flow.getLocationsList()) {
+ for (DbIssues.Location flowLocation : flow.getLocationList()) {
targetFlow.addLocations(convertLocation(flowLocation));
}
issueBuilder.addExecutionFlows(targetFlow);
@@ -223,24 +223,29 @@ public class SearchResponseFormat {
}
if (source.hasTextRange()) {
DbCommons.TextRange sourceRange = source.getTextRange();
- Common.TextRange.Builder targetRange = Common.TextRange.newBuilder();
- if (sourceRange.hasStartLine()) {
- targetRange.setStartLine(sourceRange.getStartLine());
- }
- if (sourceRange.hasStartOffset()) {
- targetRange.setStartOffset(sourceRange.getStartOffset());
- }
- if (sourceRange.hasEndLine()) {
- targetRange.setEndLine(sourceRange.getEndLine());
- }
- if (sourceRange.hasEndOffset()) {
- targetRange.setEndOffset(sourceRange.getEndOffset());
- }
+ Common.TextRange.Builder targetRange = convertTextRange(sourceRange);
target.setTextRange(targetRange);
}
return target.build();
}
+ private static Common.TextRange.Builder convertTextRange(DbCommons.TextRange sourceRange) {
+ Common.TextRange.Builder targetRange = Common.TextRange.newBuilder();
+ if (sourceRange.hasStartLine()) {
+ targetRange.setStartLine(sourceRange.getStartLine());
+ }
+ if (sourceRange.hasStartOffset()) {
+ targetRange.setStartOffset(sourceRange.getStartOffset());
+ }
+ if (sourceRange.hasEndLine()) {
+ targetRange.setEndLine(sourceRange.getEndLine());
+ }
+ if (sourceRange.hasEndOffset()) {
+ targetRange.setEndOffset(sourceRange.getEndOffset());
+ }
+ return targetRange;
+ }
+
private static void formatIssueTransitions(SearchResponseData data, Issues.Issue.Builder issueBuilder, IssueDto dto) {
issueBuilder.setTransitionsPresentIfEmpty(true);
List<Transition> transitions = data.getTransitionsForIssueKey(dto.getKey());
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java
index 44fd5f1c7d3..c00158ef0cc 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseLoader.java
@@ -182,23 +182,20 @@ public class SearchResponseLoader {
add(RULES, issue.getRuleKey());
add(USERS, issue.getReporter());
add(USERS, issue.getAssignee());
- collectIssueLocations(issue);
+ collectComponentsFromIssueLocations(issue);
}
}
- private void collectIssueLocations(IssueDto issue) {
+ private void collectComponentsFromIssueLocations(IssueDto issue) {
DbIssues.Locations locations = issue.parseLocations();
if (locations != null) {
- if (locations.hasPrimary() && locations.getPrimary().hasComponentId()) {
- componentUuids.add(locations.getPrimary().getComponentId());
- }
for (DbIssues.Location location : locations.getSecondaryList()) {
if (location.hasComponentId()) {
componentUuids.add(location.getComponentId());
}
}
for (DbIssues.ExecutionFlow flow : locations.getExecutionFlowList()) {
- for (DbIssues.Location location : flow.getLocationsList()) {
+ for (DbIssues.Location location : flow.getLocationList()) {
if (location.hasComponentId()) {
componentUuids.add(location.getComponentId());
}