Kaynağa Gözat

Improve compatibility of api/issues/search2

tags/5.2-RC1
Simon Brandhof 8 yıl önce
ebeveyn
işleme
0c439af3ef

+ 1
- 1
server/sonar-server/src/main/java/org/sonar/server/issue/ws/Search2Action.java Dosyayı Görüntüle

@@ -58,7 +58,7 @@ public class Search2Action implements IssuesWsAction {

private static final String INTERNAL_PARAMETER_DISCLAIMER = "This parameter is mostly used by the Issues page, please prefer usage of the componentKeys parameter. ";
public static final String ADDITIONAL_FIELDS = "additionalFields";
public static final String SEARCH_ACTION = "search";
public static final String SEARCH_ACTION = "search2";

private final UserSession userSession;
private final IssueService service;

+ 27
- 3
server/sonar-server/src/main/java/org/sonar/server/issue/ws/SearchResponseFormat.java Dosyayı Görüntüle

@@ -19,6 +19,7 @@
*/
package org.sonar.server.issue.ws;

import com.google.common.base.Strings;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -240,12 +241,35 @@ public class SearchResponseFormat {
return result;
}

private List<Common.Component> formatComponents(SearchResponseData data) {
List<Common.Component> result = new ArrayList<>();
private List<Issues.Component> formatComponents(SearchResponseData data) {
List<Issues.Component> result = new ArrayList<>();
Collection<ComponentDto> components = data.getComponents();
if (components != null) {
for (ComponentDto dto : components) {
result.add(commonFormat.formatComponent(dto).build());
Issues.Component.Builder builder = Issues.Component.newBuilder()
.setId(dto.getId())
.setKey(dto.key())
.setUuid(dto.uuid())
.setQualifier(dto.qualifier())
.setName(nullToEmpty(dto.name()))
.setLongName(nullToEmpty(dto.longName()))
.setEnabled(dto.isEnabled());
String path = dto.path();
// path is not applicable to the components that are not files.
// Value must not be "" in this case.
if (!Strings.isNullOrEmpty(path)) {
builder.setPath(path);
}

// On a root project, parentProjectId is null but projectId is equal to itself, which make no sense.
if (dto.projectUuid() != null && dto.parentProjectId() != null) {
ComponentDto project = data.getComponentByUuid(dto.projectUuid());
builder.setProjectId(project.getId());
}
if (dto.parentProjectId() != null) {
builder.setSubProjectId(dto.parentProjectId());
}
result.add(builder.build());
}
}
return result;

+ 0
- 25
server/sonar-server/src/main/java/org/sonar/server/ws/WsResponseCommonFormat.java Dosyayı Görüntüle

@@ -60,31 +60,6 @@ public class WsResponseCommonFormat {
return builder;
}

public Common.Component.Builder formatComponent(ComponentDto dto) {
Common.Component.Builder builder = Common.Component.newBuilder()
.setId(dto.uuid())
.setKey(dto.key())
.setQualifier(dto.qualifier())
.setName(nullToEmpty(dto.name()))
.setLongName(nullToEmpty(dto.longName()))
.setEnabled(dto.isEnabled());
String path = dto.path();
// path is not applicable to the components that are not files.
// Value must not be "" in this case.
if (!Strings.isNullOrEmpty(path)) {
builder.setPath(path);
}

// On a root project, parentProjectId is null but projectId is equal to itself, which make no sense.
if (dto.projectUuid() != null && dto.parentProjectId() != null) {
builder.setProject(dto.projectUuid());
}
if (dto.parentProjectId() != null) {
builder.setSubProject(dto.moduleUuid());
}
return builder;
}

public Common.User.Builder formatUser(UserDto user) {
return Common.User.newBuilder()
.setLogin(user.getLogin())

+ 4
- 4
server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionComponentsMediumTest/display_file_facet.json Dosyayı Görüntüle

@@ -10,10 +10,10 @@
}
],
"components": [
{ "id": "P1" },
{ "id": "F1" },
{ "id": "F2" },
{ "id": "F3" }
{ "key": "PK1" },
{ "key": "FK1" },
{ "key": "FK2" },
{ "key": "FK3" }
],
"facets": [
{

+ 6
- 6
server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionComponentsMediumTest/display_module_facet.json Dosyayı Görüntüle

@@ -8,12 +8,12 @@
}
],
"components": [
{ "id": "P1" },
{ "id": "M1" },
{ "id": "SUBM1" },
{ "id": "SUBM2" },
{ "id": "SUBM3" },
{ "id": "F1" }
{ "key": "PK1" },
{ "key": "MK1" },
{ "key": "SUBMK1" },
{ "key": "SUBMK2" },
{ "key": "SUBMK3" },
{ "key": "FK1" }
],
"facets": [
{

+ 4
- 4
server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionComponentsMediumTest/display_sticky_project_facet.json Dosyayı Görüntüle

@@ -8,10 +8,10 @@
}
],
"components": [
{ "id": "P1" },
{ "id": "P2" },
{ "id": "P3" },
{ "id": "F1" }
{ "key": "PK1" },
{ "key": "PK2" },
{ "key": "PK3" },
{ "key": "FK1" }
],
"facets": [
{

+ 0
- 4
server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionComponentsMediumTest/issues_on_different_projects.json Dosyayı Görüntüle

@@ -23,22 +23,18 @@
],
"components": [
{
"id": "F1",
"key": "FK1",
"enabled" : true
},
{
"id": "P1",
"key": "PK1",
"enabled" : true
},
{
"id": "F2",
"key": "FK2",
"enabled" : true
},
{
"id": "P2",
"key": "PK2",
"enabled" : true
}

+ 0
- 2
server/sonar-server/src/test/resources/org/sonar/server/issue/ws/SearchActionMediumTest/issue_on_removed_file.json Dosyayı Görüntüle

@@ -13,12 +13,10 @@
],
"components": [
{
"id": "REMOVED_FILE_ID",
"key": "REMOVED_FILE_KEY",
"enabled" : false
},
{
"id": "PROJECT_ID",
"key": "PROJECT_KEY",
"enabled" : true
}

+ 12
- 1679
sonar-ws/src/main/gen-java/org/sonarqube/ws/Common.java
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


+ 1752
- 163
sonar-ws/src/main/gen-java/org/sonarqube/ws/Issues.java
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


+ 0
- 12
sonar-ws/src/main/protobuf/ws-common.proto Dosyayı Görüntüle

@@ -50,18 +50,6 @@ enum Severity {
BLOCKER = 4;
}

message Component {
optional string id = 1;
optional string key = 2;
optional bool enabled = 3;
optional string qualifier = 4;
optional string name = 5;
optional string longName = 6;
optional string path = 7;
optional string project = 8;
optional string subProject = 9;
}

message Rule {
optional string key = 1;
optional string name = 2;

+ 13
- 0
sonar-ws/src/main/protobuf/ws-issues.proto Dosyayı Görüntüle

@@ -129,3 +129,16 @@ message Language {
optional string key = 1;
optional string name = 2;
}

message Component {
optional int64 id = 1;
optional string key = 2;
optional string uuid = 3;
optional bool enabled = 4;
optional string qualifier = 5;
optional string name = 6;
optional string longName = 7;
optional string path = 8;
optional int64 projectId = 9;
optional int64 subProjectId = 10;
}

Loading…
İptal
Kaydet