@@ -20,15 +20,14 @@ | |||
package org.sonar.server.batch; | |||
import com.google.common.base.Splitter; | |||
import java.io.IOException; | |||
import java.io.OutputStream; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.Map; | |||
import org.sonar.api.resources.Scopes; | |||
import org.sonar.api.rules.RuleType; | |||
import org.sonar.api.server.ws.Change; | |||
import org.sonar.api.server.ws.Request; | |||
import org.sonar.api.server.ws.Response; | |||
import org.sonar.api.server.ws.WebService; | |||
@@ -74,6 +73,7 @@ public class IssuesAction implements BatchWsAction { | |||
.setDescription("Return open issues") | |||
.setResponseExample(getClass().getResource("issues-example.proto")) | |||
.setSince("5.1") | |||
.setChangelog(new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_KEY))) | |||
.setInternal(true) | |||
.setHandler(this); | |||
@@ -22,6 +22,7 @@ package org.sonar.server.batch; | |||
import java.util.Date; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
import org.sonar.api.server.ws.Change; | |||
import org.sonar.api.server.ws.Request; | |||
import org.sonar.api.server.ws.Response; | |||
import org.sonar.api.server.ws.WebService; | |||
@@ -56,6 +57,8 @@ public class ProjectAction implements BatchWsAction { | |||
.setDescription("Return project repository") | |||
.setResponseExample(getClass().getResource("project-example.json")) | |||
.setSince("4.5") | |||
.setChangelog(new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_KEY))) | |||
.setChangelog(new Change("7.6", "Stop returning settings")) | |||
.setInternal(true) | |||
.setHandler(this); | |||
@@ -56,6 +56,7 @@ import static java.util.Arrays.asList; | |||
import static java.util.Collections.emptyList; | |||
import static java.util.Collections.singletonList; | |||
import static org.apache.commons.lang.StringUtils.defaultString; | |||
import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY; | |||
import static org.sonar.api.utils.DateUtils.parseEndingDateOrDateTime; | |||
import static org.sonar.api.utils.DateUtils.parseStartingDateOrDateTime; | |||
import static org.sonar.core.util.stream.MoreCollectors.toList; | |||
@@ -103,7 +104,8 @@ public class ActivityAction implements CeWsAction { | |||
new Change("5.5", "it's no more possible to specify the page parameter."), | |||
new Change("6.1", "field \"logs\" is deprecated and its value is always false"), | |||
new Change("6.6", "fields \"branch\" and \"branchType\" added"), | |||
new Change("7.1", "field \"pullRequest\" added")) | |||
new Change("7.1", "field \"pullRequest\" added"), | |||
new Change("7.6", String.format("The use of module keys in parameters '%s' and '%s' is deprecated", TEXT_QUERY, PARAM_COMPONENT_QUERY))) | |||
.setSince("5.2"); | |||
action.createParam(PARAM_COMPONENT_ID) | |||
@@ -115,10 +117,10 @@ public class ActivityAction implements CeWsAction { | |||
"<li>component keys that are exactly the same as the supplied string</li>" + | |||
"</ul>" + | |||
"Must not be set together with %s.<br />" + | |||
"Deprecated and replaced by '%s'", PARAM_COMPONENT_ID, Param.TEXT_QUERY)) | |||
"Deprecated and replaced by '%s'", PARAM_COMPONENT_ID, TEXT_QUERY)) | |||
.setExampleValue("Apache") | |||
.setDeprecatedSince("5.5"); | |||
action.createParam(Param.TEXT_QUERY) | |||
action.createParam(TEXT_QUERY) | |||
.setDescription(format("Limit search to: <ul>" + | |||
"<li>component names that contain the supplied string</li>" + | |||
"<li>component keys that are exactly the same as the supplied string</li>" + | |||
@@ -288,7 +290,7 @@ public class ActivityAction implements CeWsAction { | |||
private static Request toSearchWsRequest(org.sonar.api.server.ws.Request request) { | |||
Request activityWsRequest = new Request() | |||
.setComponentId(request.param(PARAM_COMPONENT_ID)) | |||
.setQ(defaultString(request.param(Param.TEXT_QUERY), request.param(PARAM_COMPONENT_QUERY))) | |||
.setQ(defaultString(request.param(TEXT_QUERY), request.param(PARAM_COMPONENT_QUERY))) | |||
.setStatus(request.paramAsStrings(PARAM_STATUS)) | |||
.setType(request.param(PARAM_TYPE)) | |||
.setMinSubmittedAt(request.param(PARAM_MIN_SUBMITTED_AT)) |
@@ -35,10 +35,10 @@ import org.sonar.server.user.UserSession; | |||
import org.sonar.server.ws.KeyExamples; | |||
import org.sonarqube.ws.Ce.ActivityStatusWsResponse; | |||
import static org.sonar.server.component.ComponentFinder.ParamNames.COMPONENT_ID_AND_KEY; | |||
import static org.sonar.server.ws.WsUtils.writeProtobuf; | |||
import static org.sonar.server.ce.ws.CeWsParameters.DEPRECATED_PARAM_COMPONENT_KEY; | |||
import static org.sonar.server.ce.ws.CeWsParameters.PARAM_COMPONENT_ID; | |||
import static org.sonar.server.component.ComponentFinder.ParamNames.COMPONENT_ID_AND_KEY; | |||
import static org.sonar.server.ws.WsUtils.writeProtobuf; | |||
public class ActivityStatusAction implements CeWsAction { | |||
private final UserSession userSession; | |||
@@ -66,6 +66,7 @@ public class ActivityStatusAction implements CeWsAction { | |||
.setDescription("Id of the component (project) to filter on") | |||
.setExampleValue(Uuids.UUID_EXAMPLE_03); | |||
action.createParam(DEPRECATED_PARAM_COMPONENT_KEY) | |||
.setDeprecatedSince("6.6") | |||
.setDescription("Key of the component (project) to filter on") | |||
.setExampleValue(KeyExamples.KEY_PROJECT_EXAMPLE_001); | |||
@@ -74,13 +74,11 @@ public class AnalysisStatusAction implements CeWsAction { | |||
action.createParam(PARAM_BRANCH) | |||
.setDescription("Branch key") | |||
.setExampleValue(KEY_BRANCH_EXAMPLE_001) | |||
.setInternal(true); | |||
.setExampleValue(KEY_BRANCH_EXAMPLE_001); | |||
action.createParam(PARAM_PULL_REQUEST) | |||
.setDescription("Pull request id") | |||
.setExampleValue(KEY_PULL_REQUEST_EXAMPLE_001) | |||
.setInternal(true); | |||
.setExampleValue(KEY_PULL_REQUEST_EXAMPLE_001); | |||
} | |||
@Override |
@@ -70,7 +70,8 @@ public class ComponentAction implements CeWsAction { | |||
.setResponseExample(getClass().getResource("component-example.json")) | |||
.setChangelog( | |||
new Change("6.1", "field \"logs\" is deprecated and its value is always false"), | |||
new Change("6.6", "fields \"branch\" and \"branchType\" added")) | |||
new Change("6.6", "fields \"branch\" and \"branchType\" added"), | |||
new Change("7.6", String.format("The use of module keys in parameter \"%s\" is deprecated", PARAM_COMPONENT))) | |||
.setHandler(this); | |||
action.createParam(PARAM_COMPONENT_ID) |
@@ -27,6 +27,7 @@ import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import org.apache.commons.lang.BooleanUtils; | |||
import org.sonar.api.measures.Metric; | |||
import org.sonar.api.server.ws.Change; | |||
import org.sonar.api.server.ws.Request; | |||
import org.sonar.api.server.ws.Response; | |||
import org.sonar.api.server.ws.WebService; | |||
@@ -92,6 +93,7 @@ public class AppAction implements ComponentsWsAction { | |||
"Requires the following permission: 'Browse'.") | |||
.setResponseExample(getClass().getResource("app-example.json")) | |||
.setSince("4.4") | |||
.setChangelog(new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT))) | |||
.setInternal(true) | |||
.setHandler(this); | |||
@@ -23,10 +23,12 @@ import java.util.List; | |||
import java.util.Map; | |||
import java.util.Optional; | |||
import java.util.Set; | |||
import java.util.stream.Collectors; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import org.sonar.api.i18n.I18n; | |||
import org.sonar.api.resources.Languages; | |||
import org.sonar.api.resources.Qualifiers; | |||
import org.sonar.api.resources.ResourceTypes; | |||
import org.sonar.api.server.ws.Response; | |||
import org.sonar.api.server.ws.WebService; | |||
@@ -70,7 +72,7 @@ public class SearchAction implements ComponentsWsAction { | |||
private final DefaultOrganizationProvider defaultOrganizationProvider; | |||
public SearchAction(ComponentIndex componentIndex, DbClient dbClient, ResourceTypes resourceTypes, I18n i18n, Languages languages, | |||
DefaultOrganizationProvider defaultOrganizationProvider) { | |||
DefaultOrganizationProvider defaultOrganizationProvider) { | |||
this.componentIndex = componentIndex; | |||
this.dbClient = dbClient; | |||
this.resourceTypes = resourceTypes; | |||
@@ -146,7 +148,11 @@ public class SearchAction implements ComponentsWsAction { | |||
Set<String> projectUuidsToSearch = components.stream() | |||
.map(ComponentDto::projectUuid) | |||
.collect(toHashSet()); | |||
List<ComponentDto> projects = dbClient.componentDao().selectByUuids(dbSession, projectUuidsToSearch); | |||
List<ComponentDto> projects = dbClient.componentDao() | |||
.selectByUuids(dbSession, projectUuidsToSearch) | |||
.stream() | |||
.filter(c -> !c.qualifier().equals(Qualifiers.MODULE)) | |||
.collect(Collectors.toList()); | |||
return projects.stream().collect(toMap(ComponentDto::uuid, ComponentDto::getDbKey)); | |||
} | |||
@@ -267,5 +273,4 @@ public class SearchAction implements ComponentsWsAction { | |||
} | |||
} | |||
} |
@@ -80,7 +80,8 @@ public class ShowAction implements ComponentsWsAction { | |||
new Change("6.4", "The 'visibility' field is added to the response"), | |||
new Change("6.5", "Leak period date is added to the response"), | |||
new Change("6.6", "'branch' is added to the response"), | |||
new Change("6.6", "'version' is added to the response")) | |||
new Change("6.6", "'version' is added to the response"), | |||
new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT))) | |||
.setHandler(this); | |||
action.createParam(PARAM_COMPONENT_ID) | |||
@@ -136,7 +137,7 @@ public class ShowAction implements ComponentsWsAction { | |||
if (branch == null && pullRequest == null) { | |||
return componentFinder.getByUuidOrKey(dbSession, componentId, componentKey, COMPONENT_ID_AND_COMPONENT); | |||
} | |||
checkRequest(componentKey!=null, "The '%s' parameter is missing", PARAM_COMPONENT); | |||
checkRequest(componentKey != null, "The '%s' parameter is missing", PARAM_COMPONENT); | |||
return componentFinder.getByKeyAndOptionalBranchOrPullRequest(dbSession, componentKey, branch, pullRequest); | |||
} | |||
@@ -28,7 +28,6 @@ public enum SuggestionCategory { | |||
SUBVIEW(Qualifiers.SUBVIEW), | |||
APP(Qualifiers.APP), | |||
PROJECT(Qualifiers.PROJECT), | |||
MODULE(Qualifiers.MODULE), | |||
FILE(Qualifiers.FILE), | |||
UNIT_TEST_FILE(Qualifiers.UNIT_TEST_FILE),; | |||
@@ -85,7 +85,7 @@ public class SuggestionsAction implements ComponentsWsAction { | |||
private static final int MAXIMUM_RECENTLY_BROWSED = 50; | |||
private static final int EXTENDED_LIMIT = 20; | |||
private static final Set<String> QUALIFIERS_FOR_WHICH_TO_RETURN_PROJECT = Stream.of(Qualifiers.MODULE, Qualifiers.FILE, Qualifiers.UNIT_TEST_FILE).collect(Collectors.toSet()); | |||
private static final Set<String> QUALIFIERS_FOR_WHICH_TO_RETURN_PROJECT = Stream.of(Qualifiers.FILE, Qualifiers.UNIT_TEST_FILE).collect(Collectors.toSet()); | |||
private final ComponentIndex index; | |||
private final FavoriteFinder favoriteFinder; | |||
@@ -255,7 +255,10 @@ public class SuggestionsAction implements ComponentsWsAction { | |||
} | |||
private List<String> getQualifiers(@Nullable String more) { | |||
Set<String> availableQualifiers = resourceTypes.getAll().stream().map(ResourceType::getQualifier).collect(MoreCollectors.toSet()); | |||
Set<String> availableQualifiers = resourceTypes.getAll().stream() | |||
.map(ResourceType::getQualifier) | |||
.filter(q -> !q.equals(Qualifiers.MODULE)) | |||
.collect(MoreCollectors.toSet()); | |||
if (more == null) { | |||
return stream(SuggestionCategory.values()) | |||
.map(SuggestionCategory::getQualifier) |
@@ -31,9 +31,11 @@ import java.util.Map; | |||
import java.util.Objects; | |||
import java.util.Optional; | |||
import java.util.Set; | |||
import java.util.stream.Collectors; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import org.sonar.api.i18n.I18n; | |||
import org.sonar.api.resources.Qualifiers; | |||
import org.sonar.api.resources.ResourceTypes; | |||
import org.sonar.api.server.ws.Change; | |||
import org.sonar.api.server.ws.Response; | |||
@@ -120,7 +122,8 @@ public class TreeAction implements ComponentsWsAction { | |||
.setSince("5.4") | |||
.setResponseExample(getClass().getResource("tree-example.json")) | |||
.setChangelog( | |||
new Change("6.4", "The field 'id' is deprecated in the response")) | |||
new Change("6.4", "The field 'id' is deprecated in the response"), | |||
new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT))) | |||
.setHandler(this) | |||
.addPagingParams(100, MAX_SIZE); | |||
@@ -185,7 +188,10 @@ public class TreeAction implements ComponentsWsAction { | |||
OrganizationDto organizationDto = componentFinder.getOrganization(dbSession, baseComponent); | |||
ComponentTreeQuery query = toComponentTreeQuery(treeRequest, baseComponent); | |||
List<ComponentDto> components = dbClient.componentDao().selectDescendants(dbSession, query); | |||
List<ComponentDto> components = dbClient.componentDao().selectDescendants(dbSession, query) | |||
.stream() | |||
.filter(c -> !c.qualifier().equals(Qualifiers.MODULE)) | |||
.collect(Collectors.toList()); | |||
int total = components.size(); | |||
components = sortComponents(components, treeRequest); | |||
components = paginateComponents(components, treeRequest); |
@@ -20,6 +20,7 @@ | |||
package org.sonar.server.favorite.ws; | |||
import java.util.function.Consumer; | |||
import org.sonar.api.server.ws.Change; | |||
import org.sonar.api.server.ws.Request; | |||
import org.sonar.api.server.ws.Response; | |||
import org.sonar.api.server.ws.WebService; | |||
@@ -53,10 +54,11 @@ public class AddAction implements FavoritesWsAction { | |||
.setDescription("Add a component (project, directory, file etc.) as favorite for the authenticated user.<br>" + | |||
"Requires authentication and the following permission: 'Browse' on the project of the specified component.") | |||
.setSince("6.3") | |||
.setChangelog(new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT))) | |||
.setPost(true) | |||
.setHandler(this); | |||
action.createParam("component") | |||
action.createParam(PARAM_COMPONENT) | |||
.setDescription("Component key") | |||
.setRequired(true) | |||
.setExampleValue(KeyExamples.KEY_FILE_EXAMPLE_001); |
@@ -20,6 +20,7 @@ | |||
package org.sonar.server.favorite.ws; | |||
import java.util.function.Consumer; | |||
import org.sonar.api.server.ws.Change; | |||
import org.sonar.api.server.ws.Request; | |||
import org.sonar.api.server.ws.Response; | |||
import org.sonar.api.server.ws.WebService; | |||
@@ -52,10 +53,11 @@ public class RemoveAction implements FavoritesWsAction { | |||
.setDescription("Remove a component (project, directory, file etc.) as favorite for the authenticated user.<br>" + | |||
"Requires authentication.") | |||
.setSince("6.3") | |||
.setChangelog(new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT))) | |||
.setPost(true) | |||
.setHandler(this); | |||
action.createParam("component") | |||
action.createParam(PARAM_COMPONENT) | |||
.setDescription("Component key") | |||
.setRequired(true) | |||
.setExampleValue(KeyExamples.KEY_PROJECT_EXAMPLE_001); |
@@ -73,12 +73,12 @@ import static org.sonar.process.ProcessProperties.Property.SONARCLOUD_ENABLED; | |||
import static org.sonar.server.es.SearchOptions.MAX_LIMIT; | |||
import static org.sonar.server.issue.index.IssueIndex.FACET_ASSIGNED_TO_ME; | |||
import static org.sonar.server.issue.index.IssueIndex.FACET_PROJECTS; | |||
import static org.sonar.server.issue.index.IssueQuery.SORT_BY_ASSIGNEE; | |||
import static org.sonar.server.issue.index.IssueQueryFactory.UNKNOWN; | |||
import static org.sonar.server.issue.index.SecurityStandardHelper.SANS_TOP_25_INSECURE_INTERACTION; | |||
import static org.sonar.server.issue.index.SecurityStandardHelper.SANS_TOP_25_POROUS_DEFENSES; | |||
import static org.sonar.server.issue.index.SecurityStandardHelper.SANS_TOP_25_RISKY_RESOURCE; | |||
import static org.sonar.server.issue.index.SecurityStandardHelper.UNKNOWN_STANDARD; | |||
import static org.sonar.server.issue.index.IssueQuery.SORT_BY_ASSIGNEE; | |||
import static org.sonar.server.issue.index.IssueQueryFactory.UNKNOWN; | |||
import static org.sonar.server.ws.KeyExamples.KEY_BRANCH_EXAMPLE_001; | |||
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; | |||
import static org.sonar.server.ws.KeyExamples.KEY_PULL_REQUEST_EXAMPLE_001; | |||
@@ -190,6 +190,7 @@ public class SearchAction implements IssuesWsAction, Startable { | |||
PARAM_COMPONENT_KEYS, PARAM_COMPONENT_UUIDS, PARAM_COMPONENTS, PARAM_COMPONENT_ROOT_UUIDS, PARAM_COMPONENT_ROOTS) | |||
.setSince("3.6") | |||
.setChangelog( | |||
new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT_KEYS)), | |||
new Change("7.4", "The facet 'projectUuids' is dropped in favour of the new facet 'projects'. " + | |||
"Note that they are not strictly identical, the latter returns the project keys."), | |||
new Change("7.4", format("Parameter '%s' does not accept anymore deprecated value 'debt'", FACET_MODE)), | |||
@@ -340,6 +341,7 @@ public class SearchAction implements IssuesWsAction, Startable { | |||
.setDescription("To retrieve issues associated to a specific list of modules (comma-separated list of module IDs). " + | |||
INTERNAL_PARAMETER_DISCLAIMER) | |||
.setInternal(true) | |||
.setDeprecatedSince("7.6") | |||
.setExampleValue("7d8749e8-3070-4903-9188-bdd82933bb92"); | |||
action.createParam(PARAM_DIRECTORIES) |
@@ -105,6 +105,7 @@ public class ComponentAction implements MeasuresWsAction { | |||
.setResponseExample(getClass().getResource("component-example.json")) | |||
.setSince("5.4") | |||
.setChangelog( | |||
new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT)), | |||
new Change("6.6", "the response field id is deprecated. Use key instead."), | |||
new Change("6.6", "the response field refId is deprecated. Use refKey instead.")) | |||
.setHandler(this); |
@@ -185,6 +185,7 @@ public class ComponentTreeAction implements MeasuresWsAction { | |||
.setHandler(this) | |||
.addPagingParams(100, MAX_SIZE) | |||
.setChangelog( | |||
new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT)), | |||
new Change("7.2", "field 'bestValue' is added to the response"), | |||
new Change("6.3", format("Number of metric keys is limited to %s", MAX_METRIC_KEYS)), | |||
new Change("6.6", "the response field id is deprecated. Use key instead."), |
@@ -27,6 +27,7 @@ import java.util.function.Function; | |||
import java.util.stream.Stream; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import org.sonar.api.server.ws.Change; | |||
import org.sonar.api.server.ws.Request; | |||
import org.sonar.api.server.ws.Response; | |||
import org.sonar.api.server.ws.WebService; | |||
@@ -88,6 +89,7 @@ public class SearchHistoryAction implements MeasuresWsAction { | |||
"Requires the following permission: 'Browse' on the specified component") | |||
.setResponseExample(getClass().getResource("search_history-example.json")) | |||
.setSince("6.3") | |||
.setChangelog(new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT))) | |||
.setHandler(this); | |||
action.createParam(PARAM_COMPONENT) |
@@ -26,6 +26,7 @@ import javax.annotation.Nullable; | |||
import org.sonar.api.config.PropertyDefinition; | |||
import org.sonar.api.config.PropertyDefinitions; | |||
import org.sonar.api.config.PropertyFieldDefinition; | |||
import org.sonar.api.server.ws.Change; | |||
import org.sonar.api.server.ws.Request; | |||
import org.sonar.api.server.ws.Response; | |||
import org.sonar.api.server.ws.WebService; | |||
@@ -71,14 +72,15 @@ public class ListDefinitionsAction implements SettingsWsAction { | |||
.setDescription("List settings definitions.<br>" + | |||
"Requires 'Browse' permission when a component is specified<br/>" + | |||
"To access licensed settings, authentication is required<br/>" + | |||
"To access secured settings, one of the following permissions is required: " + | |||
"<ul>" + | |||
"<li>'Execute Analysis'</li>" + | |||
"<li>'Administer System'</li>" + | |||
"<li>'Administer' rights on the specified component</li>" + | |||
"</ul>") | |||
"To access secured settings, one of the following permissions is required: " + | |||
"<ul>" + | |||
"<li>'Execute Analysis'</li>" + | |||
"<li>'Administer System'</li>" + | |||
"<li>'Administer' rights on the specified component</li>" + | |||
"</ul>") | |||
.setResponseExample(getClass().getResource("list_definitions-example.json")) | |||
.setSince("6.3") | |||
.setChangelog(new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT))) | |||
.setHandler(this); | |||
action.createParam(PARAM_COMPONENT) | |||
.setDescription("Component key") |
@@ -79,7 +79,9 @@ public class ResetAction implements SettingsWsAction { | |||
"<li>'Administer' rights on the specified component</li>" + | |||
"</ul>") | |||
.setSince("6.1") | |||
.setChangelog(new Change("7.1", "The settings defined in config/sonar.properties are read-only and can't be changed")) | |||
.setChangelog( | |||
new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT)), | |||
new Change("7.1", "The settings defined in config/sonar.properties are read-only and can't be changed")) | |||
.setPost(true) | |||
.setHandler(this); | |||
@@ -101,7 +101,7 @@ public class SetAction implements SettingsWsAction { | |||
WebService.NewAction action = context.createAction("set") | |||
.setDescription("Update a setting value.<br>" + | |||
"Either '%s' or '%s' must be provided.<br> " + | |||
"The settings defined in config/sonar.properties are read-only and can't be changed.<br/>" + | |||
"The settings defined in config/sonar.properties are read-only and can't be changed.<br/>" + | |||
"Requires one of the following permissions: " + | |||
"<ul>" + | |||
"<li>'Administer System'</li>" + | |||
@@ -109,7 +109,9 @@ public class SetAction implements SettingsWsAction { | |||
"</ul>", | |||
PARAM_VALUE, PARAM_VALUES) | |||
.setSince("6.1") | |||
.setChangelog(new Change("7.1", "The settings defined in config/sonar.properties are read-only and can't be changed")) | |||
.setChangelog( | |||
new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT)), | |||
new Change("7.1", "The settings defined in config/sonar.properties are read-only and can't be changed")) | |||
.setPost(true) | |||
.setHandler(this); | |||
@@ -112,7 +112,9 @@ public class ValuesAction implements SettingsWsAction { | |||
"</ul>") | |||
.setResponseExample(getClass().getResource("values-example.json")) | |||
.setSince("6.3") | |||
.setChangelog(new Change("7.1", "The settings from conf/sonar.properties are excluded from results.")) | |||
.setChangelog( | |||
new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT)), | |||
new Change("7.1", "The settings from conf/sonar.properties are excluded from results.")) | |||
.setHandler(this); | |||
action.createParam(PARAM_KEYS) | |||
.setDescription("List of setting keys") |
@@ -76,6 +76,7 @@ import static org.sonar.server.user.AbstractUserSession.insufficientPrivilegesEx | |||
import static org.sonar.server.ws.KeyExamples.KEY_BRANCH_EXAMPLE_001; | |||
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; | |||
import static org.sonar.server.ws.KeyExamples.KEY_PULL_REQUEST_EXAMPLE_001; | |||
import static org.sonar.server.ws.WsUtils.checkComponentNotAModuleAndNotADirectory; | |||
public class ComponentAction implements NavigationWsAction { | |||
@@ -121,8 +122,9 @@ public class ComponentAction implements NavigationWsAction { | |||
.setResponseExample(getClass().getResource("component-example.json")) | |||
.setSince("5.2") | |||
.setChangelog( | |||
new Change("6.4", "The 'visibility' field is added"), | |||
new Change("7.3", "The 'almRepoUrl' and 'almId' fields are added")); | |||
new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT)), | |||
new Change("7.3", "The 'almRepoUrl' and 'almId' fields are added"), | |||
new Change("6.4", "The 'visibility' field is added")); | |||
action.createParam(PARAM_COMPONENT) | |||
.setDescription("A component key.") | |||
@@ -132,13 +134,11 @@ public class ComponentAction implements NavigationWsAction { | |||
action | |||
.createParam(PARAM_BRANCH) | |||
.setDescription("Branch key") | |||
.setInternal(true) | |||
.setExampleValue(KEY_BRANCH_EXAMPLE_001); | |||
action | |||
.createParam(PARAM_PULL_REQUEST) | |||
.setDescription("Pull request id") | |||
.setInternal(true) | |||
.setExampleValue(KEY_PULL_REQUEST_EXAMPLE_001); | |||
} | |||
@@ -149,6 +149,7 @@ public class ComponentAction implements NavigationWsAction { | |||
String branch = request.param(PARAM_BRANCH); | |||
String pullRequest = request.param(PARAM_PULL_REQUEST); | |||
ComponentDto component = componentFinder.getByKeyAndOptionalBranchOrPullRequest(session, componentKey, branch, pullRequest); | |||
checkComponentNotAModuleAndNotADirectory(component); | |||
ComponentDto rootProjectOrBranch = getRootProjectOrBranch(component, session); | |||
ComponentDto rootProject = rootProjectOrBranch.getMainBranchProjectUuid() == null ? rootProjectOrBranch | |||
: componentFinder.getByUuid(session, rootProjectOrBranch.getMainBranchProjectUuid()); |
@@ -20,16 +20,20 @@ | |||
package org.sonar.server.ws; | |||
import com.google.common.base.Optional; | |||
import com.google.common.collect.ImmutableSet; | |||
import com.google.protobuf.Message; | |||
import java.io.OutputStream; | |||
import java.io.OutputStreamWriter; | |||
import java.util.List; | |||
import java.util.Set; | |||
import javax.annotation.Nullable; | |||
import org.apache.commons.io.IOUtils; | |||
import org.sonar.api.resources.Qualifiers; | |||
import org.sonar.api.server.ws.Request; | |||
import org.sonar.api.server.ws.Response; | |||
import org.sonar.api.utils.text.JsonWriter; | |||
import org.sonar.core.util.ProtobufJsonFormat; | |||
import org.sonar.db.component.ComponentDto; | |||
import org.sonar.server.exceptions.BadRequestException; | |||
import org.sonar.server.exceptions.NotFoundException; | |||
@@ -40,6 +44,8 @@ import static org.sonarqube.ws.MediaTypes.PROTOBUF; | |||
public class WsUtils { | |||
private static final Set<String> MODULE_OR_DIR_QUALIFIERS = ImmutableSet.of(Qualifiers.MODULE, Qualifiers.DIRECTORY); | |||
private WsUtils() { | |||
// only statics | |||
} | |||
@@ -117,4 +123,8 @@ public class WsUtils { | |||
return value.get(); | |||
} | |||
public static void checkComponentNotAModuleAndNotADirectory(ComponentDto component) { | |||
checkRequest(!MODULE_OR_DIR_QUALIFIERS.contains(component.qualifier()), "Operation not supported for module or directory components"); | |||
} | |||
} |
@@ -2,7 +2,7 @@ | |||
"paging": { | |||
"pageIndex": 1, | |||
"pageSize": 100, | |||
"total": 4 | |||
"total": 3 | |||
}, | |||
"components": [ | |||
{ | |||
@@ -22,14 +22,6 @@ | |||
"language": "java", | |||
"project": "project-key" | |||
}, | |||
{ | |||
"organization": "my-org-1", | |||
"id": "module-uuid", | |||
"key": "module-key", | |||
"qualifier": "BRC", | |||
"name": "Module Name", | |||
"project": "project-key" | |||
}, | |||
{ | |||
"organization": "my-org-1", | |||
"id": "project-uuid", |
@@ -39,11 +39,6 @@ | |||
], | |||
"more": 0 | |||
}, | |||
{ | |||
"q": "BRC", | |||
"items": [], | |||
"more": 0 | |||
}, | |||
{ | |||
"q": "FIL", | |||
"items": [], |
@@ -266,7 +266,7 @@ public class SearchActionTest { | |||
String response = ws.newRequest() | |||
.setMediaType(MediaTypes.JSON) | |||
.setParam(PARAM_ORGANIZATION, organizationDto.getKey()) | |||
.setParam(PARAM_QUALIFIERS, Joiner.on(",").join(PROJECT, MODULE, DIRECTORY, FILE)) | |||
.setParam(PARAM_QUALIFIERS, Joiner.on(",").join(PROJECT, DIRECTORY, FILE)) | |||
.execute().getInput(); | |||
assertJson(response).isSimilarTo(ws.getDef().responseExampleAsString()); | |||
} |
@@ -81,7 +81,8 @@ public class ShowActionTest { | |||
tuple("6.4", "The 'visibility' field is added to the response"), | |||
tuple("6.5", "Leak period date is added to the response"), | |||
tuple("6.6", "'branch' is added to the response"), | |||
tuple("6.6", "'version' is added to the response")); | |||
tuple("6.6", "'version' is added to the response"), | |||
tuple("7.6", "The use of module keys in parameter 'component' is deprecated")); | |||
assertThat(action.params()).extracting(WebService.Param::key).containsExactlyInAnyOrder("component", "componentId", "branch", "pullRequest"); | |||
WebService.Param componentId = action.param(PARAM_COMPONENT_ID); |
@@ -347,7 +347,8 @@ public class SuggestionsActionTest { | |||
assertThat(response.getResultsList()) | |||
.extracting(Category::getQ, Category::getItemsCount) | |||
.containsExactlyInAnyOrder(tuple("VW", 0), tuple("APP", 0), tuple("SVW", 0), tuple("TRK", 1), tuple("BRC", 0), tuple("FIL", 0), tuple("UTS", 0)); | |||
.containsExactlyInAnyOrder(tuple("VW", 0), tuple("APP", 0), tuple("SVW", 0), tuple("TRK", 1), tuple("FIL", 0), tuple("UTS", 0)) | |||
.doesNotContain(tuple("BRC", 0)); | |||
} | |||
@Test | |||
@@ -364,7 +365,7 @@ public class SuggestionsActionTest { | |||
assertThat(response.getResultsList()) | |||
.extracting(Category::getQ) | |||
.containsExactlyInAnyOrder(PROJECT, MODULE, FILE); | |||
.containsExactlyInAnyOrder(PROJECT, FILE).doesNotContain(MODULE); | |||
} | |||
@Test | |||
@@ -503,8 +504,8 @@ public class SuggestionsActionTest { | |||
} | |||
@Test | |||
public void should_contain_project_names() { | |||
ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organization)); | |||
public void should_not_return_modules() { | |||
ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organization).setName("ProjectWithModules")); | |||
db.components().insertComponent(newModuleDto(project).setName("Module1")); | |||
db.components().insertComponent(newModuleDto(project).setName("Module2")); | |||
componentIndexer.indexOnAnalysis(project.projectUuid()); | |||
@@ -517,18 +518,13 @@ public class SuggestionsActionTest { | |||
assertThat(response.getResultsList()) | |||
.flatExtracting(Category::getItemsList) | |||
.extracting(Suggestion::getProject) | |||
.extracting(Suggestion::getKey) | |||
.containsOnly(project.getDbKey()); | |||
assertThat(response.getProjectsList()) | |||
.extracting(Project::getKey, Project::getName) | |||
.containsExactlyInAnyOrder( | |||
tuple(project.getDbKey(), project.longName())); | |||
} | |||
@Test | |||
public void should_mark_recently_browsed_items() { | |||
ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organization)); | |||
ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organization).setName("ProjectModule")); | |||
ComponentDto module1 = newModuleDto(project).setName("Module1"); | |||
db.components().insertComponent(module1); | |||
ComponentDto module2 = newModuleDto(project).setName("Module2"); | |||
@@ -539,36 +535,34 @@ public class SuggestionsActionTest { | |||
SuggestionsWsResponse response = ws.newRequest() | |||
.setMethod("POST") | |||
.setParam(PARAM_QUERY, "Module") | |||
.setParam(PARAM_RECENTLY_BROWSED, Stream.of(module1.getDbKey()).collect(joining(","))) | |||
.setParam(PARAM_RECENTLY_BROWSED, Stream.of(module1.getDbKey(), project.getDbKey()).collect(joining(","))) | |||
.executeProtobuf(SuggestionsWsResponse.class); | |||
assertThat(response.getResultsList()) | |||
.flatExtracting(Category::getItemsList) | |||
.extracting(Suggestion::getIsRecentlyBrowsed) | |||
.containsExactly(true, false); | |||
.containsExactly(true); | |||
} | |||
@Test | |||
public void should_mark_favorite_items() { | |||
ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organization)); | |||
ComponentDto favorite = newModuleDto(project).setName("Module1"); | |||
db.components().insertComponent(favorite); | |||
doReturn(singletonList(favorite)).when(favoriteFinder).list(); | |||
ComponentDto favouriteProject = db.components().insertComponent(newPrivateProjectDto(organization).setName("Project1")); | |||
ComponentDto nonFavouriteProject = db.components().insertComponent(newPublicProjectDto(organization).setName("Project2")); | |||
ComponentDto nonFavorite = newModuleDto(project).setName("Module2"); | |||
db.components().insertComponent(nonFavorite); | |||
componentIndexer.indexOnAnalysis(project.projectUuid()); | |||
authorizationIndexerTester.allowOnlyAnyone(project); | |||
doReturn(singletonList(favouriteProject)).when(favoriteFinder).list(); | |||
componentIndexer.indexOnAnalysis(favouriteProject.projectUuid()); | |||
componentIndexer.indexOnAnalysis(nonFavouriteProject.projectUuid()); | |||
authorizationIndexerTester.allowOnlyAnyone(favouriteProject, nonFavouriteProject); | |||
SuggestionsWsResponse response = ws.newRequest() | |||
.setMethod("POST") | |||
.setParam(PARAM_QUERY, "Module") | |||
.setParam(PARAM_QUERY, "Project") | |||
.executeProtobuf(SuggestionsWsResponse.class); | |||
assertThat(response.getResultsList()) | |||
.flatExtracting(Category::getItemsList) | |||
.extracting(Suggestion::getKey, Suggestion::getIsFavorite) | |||
.containsExactly(tuple(favorite.getDbKey(), true), tuple(nonFavorite.getDbKey(), false)); | |||
.containsExactly(tuple(favouriteProject.getDbKey(), true), tuple(nonFavouriteProject.getDbKey(), false)); | |||
} | |||
@Test | |||
@@ -584,7 +578,7 @@ public class SuggestionsActionTest { | |||
assertThat(response.getResultsList()) | |||
.extracting(Category::getQ, Category::getItemsCount) | |||
.containsExactlyInAnyOrder(tuple("VW", 0), tuple("SVW", 0), tuple("APP", 0), tuple("TRK", 1), tuple("BRC", 0), tuple("FIL", 0), tuple("UTS", 0)); | |||
.containsExactlyInAnyOrder(tuple("VW", 0), tuple("SVW", 0), tuple("APP", 0), tuple("TRK", 1), tuple("FIL", 0), tuple("UTS", 0)); | |||
} | |||
@Test | |||
@@ -615,7 +609,6 @@ public class SuggestionsActionTest { | |||
tuple(SuggestionCategory.VIEW.getName(), false), | |||
tuple(SuggestionCategory.SUBVIEW.getName(), false), | |||
tuple(SuggestionCategory.PROJECT.getName(), false), | |||
tuple(SuggestionCategory.MODULE.getName(), true), | |||
tuple(SuggestionCategory.FILE.getName(), true), | |||
tuple(SuggestionCategory.UNIT_TEST_FILE.getName(), true)); | |||
} | |||
@@ -737,7 +730,7 @@ public class SuggestionsActionTest { | |||
} | |||
private void check_proposal_to_show_more_results(int numberOfProjects, int expectedNumberOfResults, long expectedNumberOfMoreResults, @Nullable SuggestionCategory more, | |||
boolean useQuery) { | |||
boolean useQuery) { | |||
String namePrefix = "MyProject"; | |||
List<ComponentDto> projects = range(0, numberOfProjects) |
@@ -100,7 +100,8 @@ public class TreeActionTest { | |||
assertThat(action.description()).isNotNull(); | |||
assertThat(action.responseExample()).isNotNull(); | |||
assertThat(action.changelog()).extracting(Change::getVersion, Change::getDescription).containsExactlyInAnyOrder( | |||
tuple("6.4", "The field 'id' is deprecated in the response")); | |||
tuple("6.4", "The field 'id' is deprecated in the response"), | |||
tuple("7.6", "The use of module keys in parameter 'component' is deprecated")); | |||
assertThat(action.params()).extracting(Param::key).containsExactlyInAnyOrder("component", "componentId", "branch", "pullRequest", "qualifiers", "strategy", | |||
"q", "s", "p", "asc", "ps"); | |||
@@ -258,7 +259,9 @@ public class TreeActionTest { | |||
.setParam(Param.SORT, "qualifier, name") | |||
.setParam(PARAM_COMPONENT_ID, "project-uuid").executeProtobuf(TreeWsResponse.class); | |||
assertThat(response.getComponentsList()).extracting("id").containsExactly("module-uuid-1", "path/directory/", "file-uuid-1", "file-uuid-2"); | |||
assertThat(response.getComponentsList()).extracting("id") | |||
.containsExactly("path/directory/", "file-uuid-1", "file-uuid-2") | |||
.doesNotContain("module-uuid-1"); | |||
} | |||
@Test |
@@ -45,7 +45,6 @@ import org.sonar.db.alm.ALM; | |||
import org.sonar.db.component.BranchType; | |||
import org.sonar.db.component.ComponentDbTester; | |||
import org.sonar.db.component.ComponentDto; | |||
import org.sonar.db.component.ComponentTesting; | |||
import org.sonar.db.component.SnapshotDto; | |||
import org.sonar.db.metric.MetricDto; | |||
import org.sonar.db.organization.OrganizationDto; | |||
@@ -56,6 +55,7 @@ import org.sonar.db.qualitygate.QualityGateDto; | |||
import org.sonar.db.qualityprofile.QProfileDto; | |||
import org.sonar.db.user.UserDto; | |||
import org.sonar.server.component.ComponentFinder; | |||
import org.sonar.server.exceptions.BadRequestException; | |||
import org.sonar.server.exceptions.ForbiddenException; | |||
import org.sonar.server.exceptions.NotFoundException; | |||
import org.sonar.server.organization.BillingValidations; | |||
@@ -386,18 +386,6 @@ public class ComponentActionTest { | |||
executeAndVerify(project.getDbKey(), "return_configuration_with_all_properties.json"); | |||
} | |||
@Test | |||
public void return_breadcrumbs_on_module() { | |||
ComponentDto project = insertOrganizationAndProject(); | |||
ComponentDto module = componentDbTester.insertComponent(newModuleDto("bcde", project).setDbKey("palap").setName("Palap")); | |||
userSession.anonymous() | |||
.addProjectPermission(UserRole.USER, project) | |||
.addProjectPermission(UserRole.ADMIN, project); | |||
init(); | |||
executeAndVerify(module.getDbKey(), "return_breadcrumbs_on_module.json"); | |||
} | |||
@Test | |||
public void return_configuration_for_quality_profile_admin() { | |||
ComponentDto project = insertOrganizationAndProject(); | |||
@@ -469,21 +457,6 @@ public class ComponentActionTest { | |||
assertJson(execute(project.getDbKey())).isSimilarTo("{\"visibility\": \"public\"}"); | |||
} | |||
@Test | |||
public void should_not_return_private_flag_for_module() { | |||
OrganizationDto org = db.organizations().insert(); | |||
db.qualityGates().createDefaultQualityGate(org); | |||
ComponentDto project = db.components().insertPrivateProject(org); | |||
ComponentDto module = db.components().insertComponent(ComponentTesting.newModuleDto(project)); | |||
init(); | |||
userSession.logIn() | |||
.addProjectPermission(UserRole.ADMIN, project) | |||
.addPermission(OrganizationPermission.ADMINISTER, org); | |||
String json = execute(module.getDbKey()); | |||
assertThat(json).doesNotContain("visibility"); | |||
} | |||
@Test | |||
public void canApplyPermissionTemplate_is_true_if_logged_in_as_organization_administrator() { | |||
OrganizationDto org = db.organizations().insert(); | |||
@@ -588,7 +561,8 @@ public class ComponentActionTest { | |||
assertThat(action.responseExample()).isNotNull(); | |||
assertThat(action.changelog()).extracting(Change::getVersion, Change::getDescription).containsExactlyInAnyOrder( | |||
tuple("6.4", "The 'visibility' field is added"), | |||
tuple("7.3", "The 'almRepoUrl' and 'almId' fields are added")); | |||
tuple("7.3", "The 'almRepoUrl' and 'almId' fields are added"), | |||
tuple("7.6", "The use of module keys in parameter 'component' is deprecated")); | |||
WebService.Param componentId = action.param(PARAM_COMPONENT); | |||
assertThat(componentId.isRequired()).isFalse(); | |||
@@ -621,27 +595,24 @@ public class ComponentActionTest { | |||
"}\n"); | |||
} | |||
@Test | |||
public void return_alm_info_on_module() { | |||
@Test(expected = BadRequestException.class) | |||
public void fail_on_module_key_as_param() { | |||
ComponentDto project = insertOrganizationAndProject(); | |||
ComponentDto module = componentDbTester.insertComponent(newModuleDto("bcde", project).setDbKey("palap").setName("Palap")); | |||
dbClient.projectAlmBindingsDao().insertOrUpdate(db.getSession(), ALM.BITBUCKETCLOUD, "{123456789}", project.uuid(), null, "http://bitbucket.org/foo/bar"); | |||
db.getSession().commit(); | |||
userSession.addProjectPermission(UserRole.USER, project); | |||
init(); | |||
String json = execute(module.getKey()); | |||
execute(module.getKey()); | |||
} | |||
assertJson(json).isSimilarTo("{\n" + | |||
" \"organization\": \"my-org\",\n" + | |||
" \"key\": \"palap\",\n" + | |||
" \"id\": \"bcde\",\n" + | |||
" \"name\": \"Palap\",\n" + | |||
" \"alm\": {\n" + | |||
" \"key\": \"bitbucketcloud\",\n" + | |||
" \"url\": \"http://bitbucket.org/foo/bar\"\n" + | |||
" }\n" + | |||
"}\n"); | |||
@Test(expected = BadRequestException.class) | |||
public void fail_on_directory_key_as_param() { | |||
ComponentDto project = insertOrganizationAndProject(); | |||
ComponentDto module = componentDbTester.insertComponent(newModuleDto("bcde", project).setDbKey("palap").setName("Palap")); | |||
ComponentDto directory = componentDbTester.insertComponent(newDirectory(module, "src/main/xoo")); | |||
userSession.addProjectPermission(UserRole.USER, project); | |||
init(); | |||
execute(directory.getDbKey()); | |||
} | |||
@Test |
@@ -1,14 +0,0 @@ | |||
{ | |||
"breadcrumbs": [ | |||
{ | |||
"key": "polop", | |||
"name": "Polop", | |||
"qualifier": "TRK" | |||
}, | |||
{ | |||
"key": "palap", | |||
"name": "Palap", | |||
"qualifier": "BRC" | |||
} | |||
] | |||
} |
@@ -19,7 +19,6 @@ | |||
*/ | |||
package org.sonarqube.ws.client.navigation; | |||
import java.util.List; | |||
import javax.annotation.Generated; | |||
/** |