コード例 #1
0
ファイル: IssueService.java プロジェクト: icloudkit/sonarqube
 @CheckForNull
 private String findSourceLineUser(DbSession dbSession, String fileUuid, @Nullable Integer line) {
   if (line != null) {
     Optional<DbFileSources.Line> sourceLine = sourceService.getLine(dbSession, fileUuid, line);
     if (sourceLine.isPresent() && sourceLine.get().hasScmAuthor()) {
       UserDoc userDoc = userIndex.getNullableByScmAccount(sourceLine.get().getScmAuthor());
       if (userDoc != null) {
         return userDoc.login();
       }
     }
   }
   return null;
 }
コード例 #2
0
 @Override
 public void handle(Request request, Response response) {
   String fileKey = request.mandatoryParam("resource");
   UserSession.get().checkComponentPermission(UserRole.CODEVIEWER, fileKey);
   Integer from = request.mandatoryParamAsInt("from");
   Integer to = request.paramAsInt("to");
   try (DbSession session = dbClient.openSession(false)) {
     ComponentDto componentDto = dbClient.componentDao().getByKey(session, fileKey);
     List<String> lines =
         sourceService.getLinesAsTxt(componentDto.uuid(), from, to == null ? null : to - 1);
     JsonWriter json = response.newJsonWriter().beginArray().beginObject();
     Integer lineCounter = from;
     for (String line : lines) {
       json.prop(lineCounter.toString(), line);
       lineCounter++;
     }
     json.endObject().endArray().close();
   }
 }