aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-webapi/src
diff options
context:
space:
mode:
authorMichal Duda <michal.duda@sonarsource.com>2020-12-15 13:36:18 +0100
committersonartech <sonartech@sonarsource.com>2020-12-22 20:09:37 +0000
commit845542d4912f32222abe15a010a38e16622c158b (patch)
treeb5d20a8fea38862790c31b2c2e51723f1f087e49 /server/sonar-webserver-webapi/src
parente88bf5b78cf19d5fd42bf12189499d5743d19367 (diff)
downloadsonarqube-845542d4912f32222abe15a010a38e16622c158b.tar.gz
sonarqube-845542d4912f32222abe15a010a38e16622c158b.zip
SONAR-13999 remove some organization WS
Diffstat (limited to 'server/sonar-webserver-webapi/src')
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/AddMemberAction.java120
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/CreateAction.java185
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/EnableSupportAction.java71
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/OrganizationsWsModule.java21
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/PreventUserDeletionAction.java87
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/RemoveMemberAction.java94
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/UpdateAction.java167
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/OrganizationDeleterTest.java0
8 files changed, 2 insertions, 743 deletions
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/AddMemberAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/AddMemberAction.java
deleted file mode 100644
index c044754a4a0..00000000000
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/AddMemberAction.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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.sonar.server.organization.ws;
-
-import org.sonar.api.server.ws.Request;
-import org.sonar.api.server.ws.Response;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.api.server.ws.WebService.NewController;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbSession;
-import org.sonar.db.organization.OrganizationDto;
-import org.sonar.db.permission.GlobalPermission;
-import org.sonar.db.user.GroupMembershipQuery;
-import org.sonar.db.user.UserDto;
-import org.sonar.server.issue.AvatarResolver;
-import org.sonar.server.organization.MemberUpdater;
-import org.sonar.server.user.UserSession;
-import org.sonarqube.ws.Organizations.AddMemberWsResponse;
-import org.sonarqube.ws.Organizations.User;
-
-import static com.google.common.base.Strings.emptyToNull;
-import static java.util.Optional.ofNullable;
-import static org.sonar.db.user.GroupMembershipQuery.IN;
-import static org.sonar.server.exceptions.NotFoundException.checkFound;
-import static org.sonar.server.exceptions.NotFoundException.checkFoundWithOptional;
-import static org.sonar.server.organization.ws.OrganizationsWsSupport.PARAM_LOGIN;
-import static org.sonar.server.organization.ws.OrganizationsWsSupport.PARAM_ORGANIZATION;
-import static org.sonar.server.ws.KeyExamples.KEY_ORG_EXAMPLE_001;
-import static org.sonar.server.ws.WsUtils.writeProtobuf;
-
-//TODO remove when getting rid of organizations
-@Deprecated
-public class AddMemberAction implements OrganizationsWsAction {
- private final DbClient dbClient;
- private final UserSession userSession;
- private final AvatarResolver avatarResolver;
- private final OrganizationsWsSupport wsSupport;
- private final MemberUpdater memberUpdater;
-
- public AddMemberAction(DbClient dbClient, UserSession userSession, AvatarResolver avatarResolver, OrganizationsWsSupport wsSupport,
- MemberUpdater memberUpdater) {
- this.dbClient = dbClient;
- this.userSession = userSession;
- this.avatarResolver = avatarResolver;
- this.wsSupport = wsSupport;
- this.memberUpdater = memberUpdater;
- }
-
- @Override
- public void define(NewController context) {
- WebService.NewAction action = context.createAction("add_member")
- .setDescription("Add a user as a member of an organization.<br>" +
- "Requires 'Administer System' permission on the specified organization.")
- .setSince("6.4")
- .setPost(true)
- .setInternal(true)
- .setResponseExample(getClass().getResource("add_member-example.json"))
- .setHandler(this);
-
- action
- .createParam(PARAM_ORGANIZATION)
- .setDescription("Organization key")
- .setRequired(true)
- .setExampleValue(KEY_ORG_EXAMPLE_001);
-
- action
- .createParam(PARAM_LOGIN)
- .setDescription("User login")
- .setRequired(true)
- .setExampleValue("ray.bradbury");
- }
-
- @Override
- public void handle(Request request, Response response) throws Exception {
- String organizationKey = request.mandatoryParam(PARAM_ORGANIZATION);
- String login = request.mandatoryParam(PARAM_LOGIN);
-
- try (DbSession dbSession = dbClient.openSession(false)) {
- OrganizationDto organization = checkFoundWithOptional(dbClient.organizationDao().selectByKey(dbSession, organizationKey), "Organization '%s' is not found",
- organizationKey);
- userSession.checkPermission(GlobalPermission.ADMINISTER);
- wsSupport.checkMemberSyncIsDisabled(dbSession, organization);
- UserDto user = checkFound(dbClient.userDao().selectByLogin(dbSession, login), "User '%s' is not found", login);
- memberUpdater.addMember(dbSession, user);
-
- int groups = dbClient.groupMembershipDao().countGroups(dbSession, GroupMembershipQuery.builder().membership(IN).build(), user.getUuid());
- AddMemberWsResponse wsResponse = buildResponse(user, groups);
- writeProtobuf(wsResponse, request, response);
- }
- }
-
- private AddMemberWsResponse buildResponse(UserDto user, int groups) {
- AddMemberWsResponse.Builder response = AddMemberWsResponse.newBuilder();
- User.Builder wsUser = User.newBuilder()
- .setLogin(user.getLogin())
- .setGroupCount(groups);
- ofNullable(emptyToNull(user.getEmail())).ifPresent(text -> wsUser.setAvatar(avatarResolver.create(user)));
- ofNullable(user.getName()).ifPresent(wsUser::setName);
- response.setUser(wsUser);
- return response.build();
- }
-
-}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/CreateAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/CreateAction.java
deleted file mode 100644
index 6b971a01ac7..00000000000
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/CreateAction.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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.sonar.server.organization.ws;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import org.sonar.api.config.Configuration;
-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;
-import org.sonar.core.config.CorePropertyDefinitions;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbSession;
-import org.sonar.db.organization.OrganizationDto;
-import org.sonar.db.user.UserDto;
-import org.sonar.server.organization.OrganizationAlmBinding;
-import org.sonar.server.organization.OrganizationFlags;
-import org.sonar.server.organization.OrganizationUpdater;
-import org.sonar.server.organization.OrganizationValidation;
-import org.sonar.server.user.UserSession;
-import org.sonarqube.ws.Organizations.CreateWsResponse;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static java.util.Objects.requireNonNull;
-import static org.sonar.server.organization.OrganizationUpdater.NewOrganization.newOrganizationBuilder;
-import static org.sonar.server.organization.OrganizationValidation.KEY_MAX_LENGTH;
-import static org.sonar.server.organization.OrganizationValidation.KEY_MIN_LENGTH;
-import static org.sonar.server.organization.ws.OrganizationsWsSupport.PARAM_KEY;
-import static org.sonar.server.ws.WsUtils.writeProtobuf;
-
-public class CreateAction implements OrganizationsWsAction {
-
- private static final String ACTION = "create";
- private static final String PARAM_INSTALLATION_ID = "installationId";
-
- private final Configuration config;
- private final UserSession userSession;
- private final DbClient dbClient;
- private final OrganizationsWsSupport wsSupport;
- private final OrganizationValidation organizationValidation;
- private final OrganizationUpdater organizationUpdater;
- private final OrganizationFlags organizationFlags;
- @CheckForNull
- private final OrganizationAlmBinding organizationAlmBinding;
-
- public CreateAction(Configuration config, UserSession userSession, DbClient dbClient, OrganizationsWsSupport wsSupport,
- OrganizationValidation organizationValidation, OrganizationUpdater organizationUpdater, OrganizationFlags organizationFlags,
- @Nullable OrganizationAlmBinding organizationAlmBinding) {
- this.config = config;
- this.userSession = userSession;
- this.dbClient = dbClient;
- this.wsSupport = wsSupport;
- this.organizationValidation = organizationValidation;
- this.organizationUpdater = organizationUpdater;
- this.organizationFlags = organizationFlags;
- this.organizationAlmBinding = organizationAlmBinding;
- }
-
- public CreateAction(Configuration config, UserSession userSession, DbClient dbClient, OrganizationsWsSupport wsSupport,
- OrganizationValidation organizationValidation, OrganizationUpdater organizationUpdater, OrganizationFlags organizationFlags) {
- this(config, userSession, dbClient, wsSupport, organizationValidation, organizationUpdater, organizationFlags, null);
- }
-
- @Override
- public void define(WebService.NewController context) {
- WebService.NewAction action = context.createAction(ACTION)
- .setPost(true)
- .setDescription("Create an organization.<br />" +
- "Requires 'Administer System' permission unless any logged in user is allowed to create an organization (see appropriate setting). Organization support must be enabled.")
- .setResponseExample(getClass().getResource("create-example.json"))
- .setInternal(true)
- .setSince("6.2")
- .setChangelog(
- new Change("7.4", "Maximal number of character of name and key is 300 characters"),
- new Change("7.2", "Minimal number of character of name and key is one character"))
- .setHandler(this);
-
- action.createParam(PARAM_KEY)
- .setRequired(false)
- .setMinimumLength(KEY_MIN_LENGTH)
- .setMaximumLength(KEY_MAX_LENGTH)
- .setDescription("Key of the organization. <br />" +
- "The key is unique to the whole SonarQube. <br/>" +
- "When not specified, the key is computed from the name. <br />" +
- "All chars must be lower-case letters (a to z), digits or dash (but dash can neither be trailing nor heading)")
- .setExampleValue("foo-company");
- action.createParam(PARAM_INSTALLATION_ID)
- .setRequired(false)
- .setInternal(true)
- .setDescription("Installation ID of the GitHub/Bitbucket application")
- .setExampleValue("387133");
-
- wsSupport.addOrganizationDetailsParams(action, true);
- }
-
- @Override
- public void handle(Request request, Response response) throws Exception {
- if (config.getBoolean(CorePropertyDefinitions.ORGANIZATIONS_ANYONE_CAN_CREATE).orElse(false)) {
- userSession.checkLoggedIn();
- } else {
- userSession.checkIsSystemAdministrator();
- }
-
- String name = wsSupport.getAndCheckMandatoryName(request);
- String requestKey = getAndCheckKey(request);
- String key = useOrGenerateKey(requestKey, name);
- String description = wsSupport.getAndCheckDescription(request);
- String url = wsSupport.getAndCheckUrl(request);
- String avatar = wsSupport.getAndCheckAvatar(request);
-
- try (DbSession dbSession = dbClient.openSession(false)) {
- organizationFlags.checkEnabled(dbSession);
- UserDto currentUser = requireNonNull(dbClient.userDao().selectActiveUserByLogin(dbSession, requireNonNull(userSession.getLogin())));
- OrganizationDto organization = organizationUpdater.create(
- dbSession,
- currentUser,
- newOrganizationBuilder()
- .setName(name)
- .setKey(key)
- .setDescription(description)
- .setUrl(url)
- .setAvatarUrl(avatar)
- .build(),
- o -> bindOrganization(request, dbSession, o));
-
- writeResponse(request, response, organization);
- } catch (OrganizationUpdater.KeyConflictException e) {
- checkArgument(requestKey == null, "Key '%s' is already used. Specify another one.", key);
- checkArgument(requestKey != null, "Key '%s' generated from name '%s' is already used. Specify one.", key, name);
- }
- }
-
- private void bindOrganization(Request request, DbSession dbSession, OrganizationDto organization) {
- if (organizationAlmBinding == null) {
- return;
- }
- String installationId = request.param(PARAM_INSTALLATION_ID);
- if (installationId == null) {
- return;
- }
- organizationAlmBinding.bindOrganization(dbSession, organization, installationId, true);
- }
-
- @CheckForNull
- private String getAndCheckKey(Request request) {
- String rqstKey = request.param(PARAM_KEY);
- if (rqstKey != null) {
- return organizationValidation.checkKey(rqstKey);
- }
- return rqstKey;
- }
-
- private String useOrGenerateKey(@Nullable String key, String name) {
- if (key == null) {
- return organizationValidation.generateKeyFrom(name);
- }
- return key;
- }
-
- private void writeResponse(Request request, Response response, OrganizationDto dto) {
- writeProtobuf(
- CreateWsResponse.newBuilder().setOrganization(wsSupport.toOrganization(dto)).build(),
- request,
- response);
- }
-
-}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/EnableSupportAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/EnableSupportAction.java
deleted file mode 100644
index dc8a5708654..00000000000
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/EnableSupportAction.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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.sonar.server.organization.ws;
-
-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;
-import org.sonar.db.permission.GlobalPermission;
-import org.sonar.server.organization.DefaultOrganizationProvider;
-import org.sonar.server.organization.OrganisationSupport;
-import org.sonar.server.user.UserSession;
-
-import static java.util.Objects.requireNonNull;
-
-public class EnableSupportAction implements OrganizationsWsAction {
- private static final String ACTION = "enable_support";
-
- private final UserSession userSession;
- private final DefaultOrganizationProvider defaultOrganizationProvider;
- private final OrganisationSupport organisationSupport;
-
- public EnableSupportAction(UserSession userSession, DefaultOrganizationProvider defaultOrganizationProvider, OrganisationSupport organisationSupport) {
- this.userSession = userSession;
- this.defaultOrganizationProvider = defaultOrganizationProvider;
- this.organisationSupport = organisationSupport;
- }
-
- @Override
- public void define(WebService.NewController context) {
- context.createAction(ACTION)
- .setPost(true)
- .setDescription("Enable support of organizations.<br />" +
- "'Administer System' permission is required. The logged-in user will be flagged as root and will be able to manage organizations and other root users.")
- .setInternal(true)
- .setPost(true)
- .setSince("6.3")
- .setChangelog(new Change("6.4", "Create default 'Members' group"))
- .setHandler(this);
- }
-
- @Override
- public void handle(Request request, Response response) throws Exception {
- verifySystemAdministrator();
-
- organisationSupport.enable(requireNonNull(userSession.getLogin()));
- response.noContent();
- }
-
- private void verifySystemAdministrator() {
- userSession.checkLoggedIn().checkPermission(GlobalPermission.ADMINISTER);
- }
-
-}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/OrganizationsWsModule.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/OrganizationsWsModule.java
index 26e0ffd2704..4a9a0526467 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/OrganizationsWsModule.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/OrganizationsWsModule.java
@@ -19,19 +19,13 @@
*/
package org.sonar.server.organization.ws;
-import org.sonar.api.config.Configuration;
import org.sonar.core.platform.Module;
import org.sonar.server.organization.MemberUpdater;
-import org.sonar.server.organization.OrganisationSupport;
-
-import static org.sonar.process.ProcessProperties.Property.SONARCLOUD_ENABLED;
public class OrganizationsWsModule extends Module {
- private final Configuration config;
-
- public OrganizationsWsModule(Configuration config) {
- this.config = config;
+ public OrganizationsWsModule() {
+ // nothing to do here
}
@Override
@@ -43,17 +37,6 @@ public class OrganizationsWsModule extends Module {
// actions
SearchAction.class,
SearchMembersAction.class);
-
- if (config.getBoolean(SONARCLOUD_ENABLED.getKey()).orElse(false)) {
- add(
- OrganisationSupport.class,
- EnableSupportAction.class,
- AddMemberAction.class,
- CreateAction.class,
- RemoveMemberAction.class,
- UpdateAction.class,
- PreventUserDeletionAction.class);
- }
}
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/PreventUserDeletionAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/PreventUserDeletionAction.java
deleted file mode 100644
index b2219307580..00000000000
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/PreventUserDeletionAction.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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.sonar.server.organization.ws;
-
-import java.util.List;
-import org.sonar.api.server.ws.Request;
-import org.sonar.api.server.ws.Response;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbSession;
-import org.sonar.db.organization.OrganizationDto;
-import org.sonar.db.organization.OrganizationHelper;
-import org.sonar.server.user.UserSession;
-import org.sonarqube.ws.Organizations;
-
-import static org.sonar.server.ws.WsUtils.writeProtobuf;
-
-public class PreventUserDeletionAction implements OrganizationsWsAction {
-
- private static final String ACTION = "prevent_user_deletion";
-
- private final DbClient dbClient;
- private final UserSession userSession;
-
- public PreventUserDeletionAction(DbClient dbClient, UserSession userSession) {
- this.dbClient = dbClient;
- this.userSession = userSession;
- }
-
- @Override
- public void define(WebService.NewController context) {
- context.createAction(ACTION)
- .setPost(false)
- .setDescription("List organizations that prevent the deletion of the authenticated user.")
- .setResponseExample(getClass().getResource("prevent_user_deletion-example.json"))
- .setInternal(true)
- .setSince("7.9")
- .setHandler(this);
- }
-
- @Override
- public void handle(Request request, Response response) throws Exception {
- userSession.checkLoggedIn();
-
- try (DbSession dbSession = dbClient.openSession(false)) {
- String userUuid = userSession.getUuid();
- List<OrganizationDto> organizationsThatPreventUserDeletion = new OrganizationHelper(dbClient).selectOrganizationsWithLastAdmin(dbSession, userUuid);
-
- Organizations.PreventUserDeletionWsResponse wsResponse = buildResponse(organizationsThatPreventUserDeletion);
- writeProtobuf(wsResponse, request, response);
- }
- }
-
- private static Organizations.PreventUserDeletionWsResponse buildResponse(List<OrganizationDto> organizations) {
- Organizations.PreventUserDeletionWsResponse.Builder response = Organizations.PreventUserDeletionWsResponse.newBuilder();
- Organizations.PreventUserDeletionWsResponse.Organization.Builder wsOrganization = Organizations.PreventUserDeletionWsResponse.Organization.newBuilder();
- organizations.forEach(o -> {
- wsOrganization.clear();
- response.addOrganizations(toOrganization(wsOrganization, o));
- });
- return response.build();
- }
-
- private static Organizations.PreventUserDeletionWsResponse.Organization.Builder toOrganization(
- Organizations.PreventUserDeletionWsResponse.Organization.Builder builder, OrganizationDto organization) {
- return builder
- .setName(organization.getName())
- .setKey(organization.getKey());
- }
-}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/RemoveMemberAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/RemoveMemberAction.java
deleted file mode 100644
index 78e80b6f0b3..00000000000
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/RemoveMemberAction.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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.sonar.server.organization.ws;
-
-import org.sonar.api.server.ws.Request;
-import org.sonar.api.server.ws.Response;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.api.server.ws.WebService.NewController;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbSession;
-import org.sonar.db.organization.OrganizationDto;
-import org.sonar.db.user.UserDto;
-import org.sonar.server.organization.MemberUpdater;
-import org.sonar.server.user.UserSession;
-
-import static org.sonar.db.permission.GlobalPermission.ADMINISTER;
-import static org.sonar.server.exceptions.NotFoundException.checkFound;
-import static org.sonar.server.exceptions.NotFoundException.checkFoundWithOptional;
-import static org.sonar.server.organization.ws.OrganizationsWsSupport.PARAM_LOGIN;
-import static org.sonar.server.organization.ws.OrganizationsWsSupport.PARAM_ORGANIZATION;
-import static org.sonar.server.ws.KeyExamples.KEY_ORG_EXAMPLE_001;
-
-public class RemoveMemberAction implements OrganizationsWsAction {
- private final DbClient dbClient;
- private final UserSession userSession;
- private final OrganizationsWsSupport wsSupport;
- private final MemberUpdater memberUpdater;
-
- public RemoveMemberAction(DbClient dbClient, UserSession userSession, OrganizationsWsSupport wsSupport,
- MemberUpdater memberUpdater) {
- this.dbClient = dbClient;
- this.userSession = userSession;
- this.wsSupport = wsSupport;
- this.memberUpdater = memberUpdater;
- }
-
- @Override
- public void define(NewController context) {
- WebService.NewAction action = context.createAction("remove_member")
- .setDescription("Remove a member from an organization.<br>" +
- "Requires 'Administer System' permission on the specified organization.")
- .setSince("6.4")
- .setPost(true)
- .setInternal(true)
- .setHandler(this);
-
- action
- .createParam(PARAM_ORGANIZATION)
- .setDescription("Organization key")
- .setRequired(true)
- .setExampleValue(KEY_ORG_EXAMPLE_001);
-
- action
- .createParam(PARAM_LOGIN)
- .setDescription("User login")
- .setRequired(true)
- .setExampleValue("ray.bradbury");
- }
-
- @Override
- public void handle(Request request, Response response) throws Exception {
- String organizationKey = request.mandatoryParam(PARAM_ORGANIZATION);
- String login = request.mandatoryParam(PARAM_LOGIN);
-
- try (DbSession dbSession = dbClient.openSession(false)) {
- OrganizationDto organization = checkFoundWithOptional(dbClient.organizationDao().selectByKey(dbSession, organizationKey),
- "Organization '%s' is not found", organizationKey);
- userSession.checkPermission(ADMINISTER);
- wsSupport.checkMemberSyncIsDisabled(dbSession, organization);
-
- UserDto user = checkFound(dbClient.userDao().selectActiveUserByLogin(dbSession, login), "User '%s' is not found", login);
- memberUpdater.removeMember(dbSession, user);
- }
- response.noContent();
- }
-
-}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/UpdateAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/UpdateAction.java
deleted file mode 100644
index 2377a99aa52..00000000000
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/organization/ws/UpdateAction.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2020 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.sonar.server.organization.ws;
-
-import java.util.Optional;
-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;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbSession;
-import org.sonar.db.organization.OrganizationDto;
-import org.sonar.server.exceptions.NotFoundException;
-import org.sonar.server.organization.OrganizationFlags;
-import org.sonar.server.user.UserSession;
-import org.sonarqube.ws.Organizations;
-
-import static java.lang.String.format;
-import static org.sonar.db.permission.GlobalPermission.ADMINISTER;
-import static org.sonar.server.organization.ws.OrganizationsWsSupport.PARAM_AVATAR_URL;
-import static org.sonar.server.organization.ws.OrganizationsWsSupport.PARAM_DESCRIPTION;
-import static org.sonar.server.organization.ws.OrganizationsWsSupport.PARAM_KEY;
-import static org.sonar.server.organization.ws.OrganizationsWsSupport.PARAM_NAME;
-import static org.sonar.server.organization.ws.OrganizationsWsSupport.PARAM_URL;
-import static org.sonar.server.ws.WsUtils.writeProtobuf;
-
-public class UpdateAction implements OrganizationsWsAction {
- private static final String ACTION = "update";
-
- private final UserSession userSession;
- private final OrganizationsWsSupport wsSupport;
- private final DbClient dbClient;
- private final OrganizationFlags organizationFlags;
-
- public UpdateAction(UserSession userSession, OrganizationsWsSupport wsSupport, DbClient dbClient,
- OrganizationFlags organizationFlags) {
- this.userSession = userSession;
- this.wsSupport = wsSupport;
- this.dbClient = dbClient;
- this.organizationFlags = organizationFlags;
- }
-
- @Override
- public void define(WebService.NewController context) {
- WebService.NewAction action = context.createAction(ACTION)
- .setPost(true)
- .setDescription("Update an organization.<br/>" +
- "Require 'Administer System' permission. Organization support must be enabled.")
- .setInternal(true)
- .setSince("6.2")
- .setChangelog(new Change("7.4", "Maximal number of character of name is 300 characters"))
- .setHandler(this);
-
- action.createParam(PARAM_KEY)
- .setRequired(true)
- .setDescription("Organization key")
- .setExampleValue("foo-company");
-
- wsSupport.addOrganizationDetailsParams(action, false);
- }
-
- @Override
- public void handle(Request request, Response response) throws Exception {
- userSession.checkLoggedIn();
-
- try (DbSession dbSession = dbClient.openSession(false)) {
- organizationFlags.checkEnabled(dbSession);
-
- String key = request.mandatoryParam(PARAM_KEY);
-
- UpdateOrganizationRequest updateRequest = new UpdateOrganizationRequest(
- request.getParam(PARAM_NAME, (rqt, paramKey) -> wsSupport.getAndCheckName(rqt)),
- request.getParam(PARAM_DESCRIPTION, (rqt, paramKey) -> emptyAsNull(wsSupport.getAndCheckDescription(rqt))),
- request.getParam(PARAM_URL, (rqt, paramKey) -> emptyAsNull(wsSupport.getAndCheckUrl(rqt))),
- request.getParam(PARAM_AVATAR_URL, (rqt, paramKey) -> emptyAsNull(wsSupport.getAndCheckAvatar(rqt))));
-
- OrganizationDto dto = getDto(dbSession, key);
-
- userSession.checkPermission(ADMINISTER);
-
- dto.setName(updateRequest.getName().or(dto::getName))
- .setDescription(updateRequest.getDescription().or(dto::getDescription))
- .setUrl(updateRequest.getUrl().or(dto::getUrl))
- .setAvatarUrl(updateRequest.getAvatar().or(dto::getAvatarUrl));
- dbClient.organizationDao().update(dbSession, dto);
- dbSession.commit();
-
- writeResponse(request, response, dto);
- }
- }
-
- @CheckForNull
- private static String emptyAsNull(@Nullable String value) {
- if (value == null || value.isEmpty()) {
- return null;
- }
- return value;
- }
-
- private OrganizationDto getDto(DbSession dbSession, String key) {
- Optional<OrganizationDto> organizationDto = dbClient.organizationDao().selectByKey(dbSession, key);
- if (!organizationDto.isPresent()) {
- throw new NotFoundException(format("Organization not found for key '%s'", key));
- }
- return organizationDto.get();
- }
-
- private void writeResponse(Request request, Response response, OrganizationDto dto) {
- writeProtobuf(
- Organizations.UpdateWsResponse.newBuilder().setOrganization(wsSupport.toOrganization(dto)).build(),
- request,
- response);
- }
-
- private static final class UpdateOrganizationRequest {
- private final Request.Param<String> name;
- private final Request.Param<String> description;
- private final Request.Param<String> url;
- private final Request.Param<String> avatar;
-
- private UpdateOrganizationRequest(Request.Param<String> name,
- Request.Param<String> description,
- Request.Param<String> url,
- Request.Param<String> avatar) {
- this.name = name;
- this.description = description;
- this.url = url;
- this.avatar = avatar;
- }
-
- public Request.Param<String> getName() {
- return name;
- }
-
- public Request.Param<String> getDescription() {
- return description;
- }
-
- public Request.Param<String> getUrl() {
- return url;
- }
-
- public Request.Param<String> getAvatar() {
- return avatar;
- }
- }
-
-}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/OrganizationDeleterTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/OrganizationDeleterTest.java
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/OrganizationDeleterTest.java
+++ /dev/null