aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/source/ws/IssueSnippetsAction.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/source/ws/LinesAction.java8
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/source/ws/LinesJsonWriter.java4
3 files changed, 6 insertions, 9 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/source/ws/IssueSnippetsAction.java b/server/sonar-server/src/main/java/org/sonar/server/source/ws/IssueSnippetsAction.java
index 35c491aa24c..1f0698937a0 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/source/ws/IssueSnippetsAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/source/ws/IssueSnippetsAction.java
@@ -44,7 +44,6 @@ import org.sonar.db.protobuf.DbIssues;
import org.sonar.server.component.ws.ComponentViewerJsonWriter;
import org.sonar.server.issue.IssueFinder;
import org.sonar.server.source.SourceService;
-import org.sonar.server.user.UserSession;
public class IssueSnippetsAction implements SourcesWsAction {
private final IssueFinder issueFinder;
@@ -130,7 +129,7 @@ public class IssueSnippetsAction implements SourcesWsAction {
componentViewerJsonWriter.writeComponentWithoutFav(writer, componentDto, dbSession, false);
componentViewerJsonWriter.writeMeasures(writer, componentDto, dbSession);
writer.endObject();
- linesJsonWriter.writeSource(lineSources, writer, true, periodDateSupplier);
+ linesJsonWriter.writeSource(lineSources, writer, false, periodDateSupplier);
writer.endObject();
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/source/ws/LinesAction.java b/server/sonar-server/src/main/java/org/sonar/server/source/ws/LinesAction.java
index eaa21aa7097..a7ecc8cb5ee 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/source/ws/LinesAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/source/ws/LinesAction.java
@@ -150,16 +150,14 @@ public class LinesAction implements SourcesWsAction {
Iterable<DbFileSources.Line> lines = checkFoundWithOptional(sourceService.getLines(dbSession, file.uuid(), from, to), "No source found for file '%s'", file.getDbKey());
try (JsonWriter json = response.newJsonWriter()) {
json.beginObject();
- linesJsonWriter.writeSource(lines, json, isMemberOfOrganization(dbSession, file), periodDateSupplier);
+ linesJsonWriter.writeSource(lines, json, isMemberOfOrganization(file), periodDateSupplier);
json.endObject();
}
}
}
- private boolean isMemberOfOrganization(DbSession dbSession, ComponentDto file) {
- OrganizationDto organizationDto = dbClient.organizationDao().selectByUuid(dbSession, file.getOrganizationUuid())
- .orElseThrow(() -> new IllegalStateException(String.format("Organization with uuid '%s' not found", file.getOrganizationUuid())));
- return !userSession.hasMembership(organizationDto);
+ private boolean isMemberOfOrganization(ComponentDto file) {
+ return userSession.hasMembership(new OrganizationDto().setUuid(file.getOrganizationUuid()));
}
private ComponentDto loadComponent(DbSession dbSession, Request wsRequest) {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/source/ws/LinesJsonWriter.java b/server/sonar-server/src/main/java/org/sonar/server/source/ws/LinesJsonWriter.java
index d85ac5d0a99..3fba15c87c7 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/source/ws/LinesJsonWriter.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/source/ws/LinesJsonWriter.java
@@ -34,7 +34,7 @@ public class LinesJsonWriter {
this.htmlSourceDecorator = htmlSourceDecorator;
}
- public void writeSource(Iterable<DbFileSources.Line> lines, JsonWriter json, boolean filterScmAuthors, Supplier<Optional<Long>> periodDateSupplier) {
+ public void writeSource(Iterable<DbFileSources.Line> lines, JsonWriter json, boolean showScmAuthors, Supplier<Optional<Long>> periodDateSupplier) {
Optional<Long> periodDate = null;
json.name("sources").beginArray();
@@ -43,7 +43,7 @@ public class LinesJsonWriter {
.prop("line", line.getLine())
.prop("code", htmlSourceDecorator.getDecoratedSourceAsHtml(line.getSource(), line.getHighlighting(), line.getSymbols()))
.prop("scmRevision", line.getScmRevision());
- if (!filterScmAuthors) {
+ if (showScmAuthors) {
json.prop("scmAuthor", line.getScmAuthor());
}
if (line.hasScmDate()) {