aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws/src/main/java/org/sonarqube/ws
diff options
context:
space:
mode:
authorDaniel Schwarz <daniel.schwarz@sonarsource.com>2017-12-04 18:34:00 +0100
committerDaniel Schwarz <bartfastiel@users.noreply.github.com>2017-12-06 14:40:17 +0100
commitcbd194df13134b0548d6ab476a78f0953c44da3d (patch)
tree1aaeaec4cbf47988393fb7b41112e4e9614b41cc /sonar-ws/src/main/java/org/sonarqube/ws
parent9bd3b8f3857e1434b97b73f39b9ffd88bdd703cc (diff)
downloadsonarqube-cbd194df13134b0548d6ab476a78f0953c44da3d.tar.gz
sonarqube-cbd194df13134b0548d6ab476a78f0953c44da3d.zip
Remove legacy sonar-ws code for users
Diffstat (limited to 'sonar-ws/src/main/java/org/sonarqube/ws')
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/user/CreateRequest.java130
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/user/GroupsRequest.java128
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/user/SearchRequest.java100
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/user/UpdateRequest.java101
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/user/UsersService.java113
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/users/CreateRequest.java12
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/users/UsersService.java6
7 files changed, 9 insertions, 581 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/user/CreateRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/user/CreateRequest.java
deleted file mode 100644
index c2a71a4539a..00000000000
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/user/CreateRequest.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.user;
-
-import java.util.List;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.Immutable;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Strings.isNullOrEmpty;
-import static java.util.Collections.emptyList;
-
-@Immutable
-public class CreateRequest {
-
- private final String login;
- private final String password;
- private final String name;
- private final String email;
- private final List<String> scmAccounts;
- private final boolean local;
-
- private CreateRequest(Builder builder) {
- this.login = builder.login;
- this.password = builder.password;
- this.name = builder.name;
- this.email = builder.email;
- this.scmAccounts = builder.scmAccounts;
- this.local = builder.local;
- }
-
- public String getLogin() {
- return login;
- }
-
- @CheckForNull
- public String getPassword() {
- return password;
- }
-
- public String getName() {
- return name;
- }
-
- @CheckForNull
- public String getEmail() {
- return email;
- }
-
- public List<String> getScmAccounts() {
- return scmAccounts;
- }
-
- public boolean isLocal() {
- return local;
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private String login;
- private String password;
- private String name;
- private String email;
- private List<String> scmAccounts = emptyList();
- private boolean local = true;
-
- private Builder() {
- // enforce factory method use
- }
-
- public Builder setLogin(String login) {
- this.login = login;
- return this;
- }
-
- public Builder setPassword(@Nullable String password) {
- this.password = password;
- return this;
- }
-
- public Builder setName(String name) {
- this.name = name;
- return this;
- }
-
- public Builder setEmail(@Nullable String email) {
- this.email = email;
- return this;
- }
-
- public Builder setScmAccounts(List<String> scmAccounts) {
- this.scmAccounts = scmAccounts;
- return this;
- }
-
- public Builder setLocal(boolean local) {
- this.local = local;
- return this;
- }
-
- public CreateRequest build() {
- checkArgument(!isNullOrEmpty(login), "Login is mandatory and must not be empty");
- checkArgument(!isNullOrEmpty(name), "Name is mandatory and must not be empty");
- checkArgument(!local || !isNullOrEmpty(password), "Password is mandatory and must not be empty");
- checkArgument(local || isNullOrEmpty(password), "Password should only be set on local user");
- return new CreateRequest(this);
- }
- }
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/user/GroupsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/user/GroupsRequest.java
deleted file mode 100644
index 161a388e385..00000000000
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/user/GroupsRequest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.user;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.Immutable;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Strings.isNullOrEmpty;
-
-@Immutable
-public class GroupsRequest {
-
- private final String login;
- private final String organization;
- private final String query;
- private final String selected;
- private final Integer page;
- private final Integer pageSize;
-
- private GroupsRequest(Builder builder) {
- this.login = builder.login;
- this.organization = builder.organization;
- this.query = builder.query;
- this.selected = builder.selected;
- this.page = builder.page;
- this.pageSize = builder.pageSize;
- }
-
- public String getLogin() {
- return login;
- }
-
- @CheckForNull
- public String getOrganization() {
- return organization;
- }
-
- @CheckForNull
- public String getQuery() {
- return query;
- }
-
- @CheckForNull
- public String getSelected() {
- return selected;
- }
-
- @CheckForNull
- public Integer getPage() {
- return page;
- }
-
- @CheckForNull
- public Integer getPageSize() {
- return pageSize;
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private String login;
- private String organization;
- private String query;
- private String selected;
- private Integer page;
- private Integer pageSize;
-
- private Builder() {
- // enforce factory method use
- }
-
- public Builder setLogin(String login) {
- this.login = login;
- return this;
- }
-
- public Builder setOrganization(@Nullable String organization) {
- this.organization = organization;
- return this;
- }
-
- public Builder setQuery(@Nullable String query) {
- this.query = query;
- return this;
- }
-
- public Builder setSelected(@Nullable String selected) {
- this.selected = selected;
- return this;
- }
-
- public Builder setPage(@Nullable Integer page) {
- this.page = page;
- return this;
- }
-
- public Builder setPageSize(@Nullable Integer pageSize) {
- this.pageSize = pageSize;
- return this;
- }
-
- public GroupsRequest build() {
- checkArgument(!isNullOrEmpty(login), "Login is mandatory and must not be empty");
- return new GroupsRequest(this);
- }
- }
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/user/SearchRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/user/SearchRequest.java
deleted file mode 100644
index 52e19f34607..00000000000
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/user/SearchRequest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.user;
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import javax.annotation.concurrent.Immutable;
-
-@Immutable
-public class SearchRequest {
-
- private final Integer page;
- private final Integer pageSize;
- private final String query;
- private final List<String> possibleFields;
-
- private SearchRequest(Builder builder) {
- this.page = builder.page;
- this.pageSize = builder.pageSize;
- this.query = builder.query;
- this.possibleFields = builder.additionalFields;
- }
-
- @CheckForNull
- public Integer getPage() {
- return page;
- }
-
- @CheckForNull
- public Integer getPageSize() {
- return pageSize;
- }
-
- @CheckForNull
- public String getQuery() {
- return query;
- }
-
- public List<String> getPossibleFields() {
- return possibleFields;
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private Integer page;
- private Integer pageSize;
- private String query;
- private List<String> additionalFields = new ArrayList<>();
-
- private Builder() {
- // enforce factory method use
- }
-
- public Builder setPage(@Nullable Integer page) {
- this.page = page;
- return this;
- }
-
- public Builder setPageSize(@Nullable Integer pageSize) {
- this.pageSize = pageSize;
- return this;
- }
-
- public Builder setQuery(@Nullable String query) {
- this.query = query;
- return this;
- }
-
- public Builder setPossibleFields(List<String> possibleFields) {
- this.additionalFields = possibleFields;
- return this;
- }
-
- public SearchRequest build() {
- return new SearchRequest(this);
- }
- }
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/user/UpdateRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/user/UpdateRequest.java
deleted file mode 100644
index 40d5fbd6455..00000000000
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/user/UpdateRequest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.user;
-
-import java.util.List;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Strings.isNullOrEmpty;
-import static java.util.Collections.emptyList;
-
-public class UpdateRequest {
-
- private final String login;
- private final String name;
- private final String email;
- private final List<String> scmAccounts;
-
- private UpdateRequest(Builder builder) {
- this.login = builder.login;
- this.name = builder.name;
- this.email = builder.email;
- this.scmAccounts = builder.scmAccounts;
- }
-
- public String getLogin() {
- return login;
- }
-
- @CheckForNull
- public String getName() {
- return name;
- }
-
- @CheckForNull
- public String getEmail() {
- return email;
- }
-
- public List<String> getScmAccounts() {
- return scmAccounts;
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private String login;
- private String name;
- private String email;
- private List<String> scmAccounts = emptyList();
-
- private Builder() {
- // enforce factory method use
- }
-
- public Builder setLogin(String login) {
- this.login = login;
- return this;
- }
-
- public Builder setName(@Nullable String name) {
- this.name = name;
- return this;
- }
-
- public Builder setEmail(@Nullable String email) {
- this.email = email;
- return this;
- }
-
- public Builder setScmAccounts(List<String> scmAccounts) {
- this.scmAccounts = scmAccounts;
- return this;
- }
-
- public UpdateRequest build() {
- checkArgument(!isNullOrEmpty(login), "Login is mandatory and must not be empty");
- return new UpdateRequest(this);
- }
- }
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/user/UsersService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/user/UsersService.java
deleted file mode 100644
index 9f2cb3f06a0..00000000000
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/user/UsersService.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonarqube.ws.client.user;
-
-import java.util.List;
-import org.sonarqube.ws.Users.CreateWsResponse;
-import org.sonarqube.ws.Users.CurrentWsResponse;
-import org.sonarqube.ws.Users.GroupsWsResponse;
-import org.sonarqube.ws.Users.SearchWsResponse;
-import org.sonarqube.ws.client.BaseService;
-import org.sonarqube.ws.client.GetRequest;
-import org.sonarqube.ws.client.PostRequest;
-import org.sonarqube.ws.client.WsConnector;
-import org.sonarqube.ws.client.WsResponse;
-
-import static org.sonar.api.server.ws.WebService.Param.FIELDS;
-import static org.sonar.api.server.ws.WebService.Param.PAGE;
-import static org.sonar.api.server.ws.WebService.Param.PAGE_SIZE;
-import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY;
-import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_CREATE;
-import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_CURRENT;
-import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_DEACTIVATE;
-import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_GROUPS;
-import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_SEARCH;
-import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_SKIP_ONBOARDING_TUTORIAL;
-import static org.sonarqube.ws.client.user.UsersWsParameters.ACTION_UPDATE;
-import static org.sonarqube.ws.client.user.UsersWsParameters.CONTROLLER_USERS;
-import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_EMAIL;
-import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_LOCAL;
-import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_LOGIN;
-import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_NAME;
-import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_ORGANIZATION;
-import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_PASSWORD;
-import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_SCM_ACCOUNT;
-import static org.sonarqube.ws.client.user.UsersWsParameters.PARAM_SELECTED;
-
-public class UsersService extends BaseService {
-
- public UsersService(WsConnector wsConnector) {
- super(wsConnector, CONTROLLER_USERS);
- }
-
- public SearchWsResponse search(SearchRequest request) {
- List<String> additionalFields = request.getPossibleFields();
- return call(new GetRequest(path(ACTION_SEARCH))
- .setParam(PAGE, request.getPage())
- .setParam(PAGE_SIZE, request.getPageSize())
- .setParam(TEXT_QUERY, request.getQuery())
- .setParam(FIELDS, !additionalFields.isEmpty() ? inlineMultipleParamValue(additionalFields) : null),
- SearchWsResponse.parser());
- }
-
- public CreateWsResponse create(CreateRequest request) {
- return call(new PostRequest(path(ACTION_CREATE))
- .setParam(PARAM_LOGIN, request.getLogin())
- .setParam(PARAM_PASSWORD, request.getPassword())
- .setParam(PARAM_NAME, request.getName())
- .setParam(PARAM_EMAIL, request.getEmail())
- .setParam(PARAM_SCM_ACCOUNT, request.getScmAccounts())
- .setParam(PARAM_LOCAL, request.isLocal()),
- CreateWsResponse.parser());
- }
-
- public void update(UpdateRequest request) {
- call(new PostRequest(path(ACTION_UPDATE))
- .setParam(PARAM_LOGIN, request.getLogin())
- .setParam(PARAM_NAME, request.getName())
- .setParam(PARAM_EMAIL, request.getEmail())
- .setParam(PARAM_SCM_ACCOUNT, request.getScmAccounts()));
- }
-
- public GroupsWsResponse groups(GroupsRequest request) {
- return call(new GetRequest(path(ACTION_GROUPS))
- .setParam(PARAM_LOGIN, request.getLogin())
- .setParam(PARAM_ORGANIZATION, request.getOrganization())
- .setParam(PARAM_SELECTED, request.getSelected())
- .setParam(TEXT_QUERY, request.getQuery())
- .setParam(PAGE, request.getPage())
- .setParam(PAGE_SIZE, request.getPageSize()),
- GroupsWsResponse.parser());
- }
-
- public CurrentWsResponse current() {
- return call(new GetRequest(path(ACTION_CURRENT)), CurrentWsResponse.parser());
- }
-
- public WsResponse skipOnboardingTutorial() {
- return call(new PostRequest(path(ACTION_SKIP_ONBOARDING_TUTORIAL)));
- }
-
- public void deactivate(String login) {
- call(new PostRequest(path(ACTION_DEACTIVATE))
- .setParam(PARAM_LOGIN, login));
- }
-
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/users/CreateRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/users/CreateRequest.java
index 7852c6846c8..5fc4b9ece4b 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/users/CreateRequest.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/users/CreateRequest.java
@@ -36,8 +36,8 @@ public class CreateRequest {
private String login;
private String name;
private String password;
- private String scmAccount;
- private String scmAccounts;
+ private List<String> scmAccount;
+ private List<String> scmAccounts;
/**
* Example value: "myname@email.com"
@@ -110,12 +110,12 @@ public class CreateRequest {
/**
* Example value: "scmAccount=firstValue&scmAccount=secondValue&scmAccount=thirdValue"
*/
- public CreateRequest setScmAccount(String scmAccount) {
+ public CreateRequest setScmAccount(List<String> scmAccount) {
this.scmAccount = scmAccount;
return this;
}
- public String getScmAccount() {
+ public List<String> getScmAccount() {
return scmAccount;
}
@@ -124,12 +124,12 @@ public class CreateRequest {
* @deprecated since 6.1
*/
@Deprecated
- public CreateRequest setScmAccounts(String scmAccounts) {
+ public CreateRequest setScmAccounts(List<String> scmAccounts) {
this.scmAccounts = scmAccounts;
return this;
}
- public String getScmAccounts() {
+ public List<String> getScmAccounts() {
return scmAccounts;
}
}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/users/UsersService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/users/UsersService.java
index f456762369b..b1ba17efd69 100644
--- a/sonar-ws/src/main/java/org/sonarqube/ws/client/users/UsersService.java
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/users/UsersService.java
@@ -66,8 +66,8 @@ public class UsersService extends BaseService {
* @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/users/create">Further information about this action online (including a response example)</a>
* @since 3.7
*/
- public void create(CreateRequest request) {
- call(
+ public CreateWsResponse create(CreateRequest request) {
+ return call(
new PostRequest(path("create"))
.setParam("email", request.getEmail())
.setParam("local", request.getLocal())
@@ -75,7 +75,7 @@ public class UsersService extends BaseService {
.setParam("name", request.getName())
.setParam("password", request.getPassword())
.setParam("scmAccount", request.getScmAccount())
- .setParam("scmAccounts", request.getScmAccounts()),
+ .setParam("scmAccounts", request.getScmAccounts() == null ? null : request.getScmAccounts().stream().collect(Collectors.joining(","))),
CreateWsResponse.parser());
}