@@ -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; |
@@ -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; |
@@ -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()) |
@@ -10,10 +10,10 @@ | |||
} | |||
], | |||
"components": [ | |||
{ "id": "P1" }, | |||
{ "id": "F1" }, | |||
{ "id": "F2" }, | |||
{ "id": "F3" } | |||
{ "key": "PK1" }, | |||
{ "key": "FK1" }, | |||
{ "key": "FK2" }, | |||
{ "key": "FK3" } | |||
], | |||
"facets": [ | |||
{ |
@@ -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": [ | |||
{ |
@@ -8,10 +8,10 @@ | |||
} | |||
], | |||
"components": [ | |||
{ "id": "P1" }, | |||
{ "id": "P2" }, | |||
{ "id": "P3" }, | |||
{ "id": "F1" } | |||
{ "key": "PK1" }, | |||
{ "key": "PK2" }, | |||
{ "key": "PK3" }, | |||
{ "key": "FK1" } | |||
], | |||
"facets": [ | |||
{ |
@@ -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 | |||
} |
@@ -13,12 +13,10 @@ | |||
], | |||
"components": [ | |||
{ | |||
"id": "REMOVED_FILE_ID", | |||
"key": "REMOVED_FILE_KEY", | |||
"enabled" : false | |||
}, | |||
{ | |||
"id": "PROJECT_ID", | |||
"key": "PROJECT_KEY", | |||
"enabled" : true | |||
} |
@@ -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; |
@@ -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; | |||
} |