]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-13848 remove deprecated web services
authorMichal Duda <michal.duda@sonarsource.com>
Thu, 25 Feb 2021 11:03:47 +0000 (12:03 +0100)
committersonartech <sonartech@sonarsource.com>
Fri, 26 Feb 2021 20:07:41 +0000 (20:07 +0000)
13 files changed:
server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/PermissionsWsModule.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/SearchProjectPermissionsAction.java [deleted file]
server/sonar-webserver-webapi/src/main/java/org/sonar/server/updatecenter/ws/InstalledPluginsAction.java [deleted file]
server/sonar-webserver-webapi/src/main/java/org/sonar/server/updatecenter/ws/UpdateCenterWs.java [deleted file]
server/sonar-webserver-webapi/src/main/java/org/sonar/server/updatecenter/ws/UpdateCenterWsAction.java [deleted file]
server/sonar-webserver-webapi/src/main/java/org/sonar/server/updatecenter/ws/UpdateCenterWsModule.java [deleted file]
server/sonar-webserver-webapi/src/main/java/org/sonar/server/updatecenter/ws/package-info.java [deleted file]
server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/PermissionsWsModuleTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest.java [deleted file]
server/sonar-webserver-webapi/src/test/java/org/sonar/server/updatecenter/ws/PluginsActionTestFilesAndMD5.java [deleted file]
server/sonar-webserver-webapi/src/test/java/org/sonar/server/updatecenter/ws/UpdateCenterWsModuleTest.java [deleted file]
server/sonar-webserver-webapi/src/test/java/org/sonar/server/updatecenter/ws/UpdateCenterWsTest.java [deleted file]
server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java

index e579d4c80ce60a3348a55957e17b671b2e9353d2..3f1a11cc633c549a5d5c993e9d546d67302235bf 100644 (file)
@@ -51,7 +51,6 @@ public class PermissionsWsModule extends Module {
       UsersAction.class,
       GroupsAction.class,
       SearchGlobalPermissionsAction.class,
-      SearchProjectPermissionsAction.class,
       RemoveUserFromTemplateAction.class,
       AddUserToTemplateAction.class,
       AddGroupToTemplateAction.class,
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/SearchProjectPermissionsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/SearchProjectPermissionsAction.java
deleted file mode 100644 (file)
index d9379c4..0000000
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2021 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.permission.ws;
-
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Table;
-import com.google.common.collect.TreeBasedTable;
-import java.util.List;
-import java.util.Locale;
-import java.util.Optional;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-import org.sonar.api.resources.ResourceType;
-import org.sonar.api.resources.ResourceTypes;
-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.Param;
-import org.sonar.api.utils.Paging;
-import org.sonar.core.i18n.I18n;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbSession;
-import org.sonar.db.component.ComponentDto;
-import org.sonar.db.component.ComponentQuery;
-import org.sonar.db.permission.CountPerProjectPermission;
-import org.sonar.server.permission.PermissionService;
-import org.sonar.server.permission.RequestValidator;
-import org.sonar.server.user.UserSession;
-import org.sonarqube.ws.Common;
-import org.sonarqube.ws.Permissions.Permission;
-import org.sonarqube.ws.Permissions.SearchProjectPermissionsWsResponse;
-import org.sonarqube.ws.Permissions.SearchProjectPermissionsWsResponse.Project;
-
-import static java.util.Collections.singletonList;
-import static org.sonar.api.utils.Paging.forPageIndex;
-import static org.sonar.server.permission.ws.ProjectWsRef.newOptionalWsProjectRef;
-import static org.sonar.server.permission.ws.SearchProjectPermissionsData.newBuilder;
-import static org.sonar.server.permission.ws.WsParameters.createProjectParameters;
-import static org.sonar.server.ws.WsParameterBuilder.QualifierParameterContext.newQualifierParameterContext;
-import static org.sonar.server.ws.WsParameterBuilder.createRootQualifierParameter;
-import static org.sonar.server.ws.WsUtils.writeProtobuf;
-import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PROJECT_ID;
-import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PROJECT_KEY;
-import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_QUALIFIER;
-
-public class SearchProjectPermissionsAction implements PermissionsWsAction {
-  private static final String PROPERTY_PREFIX = "projects_role.";
-  private static final String DESCRIPTION_SUFFIX = ".desc";
-
-  private final DbClient dbClient;
-  private final UserSession userSession;
-  private final I18n i18n;
-  private final ResourceTypes resourceTypes;
-  private final PermissionWsSupport wsSupport;
-  private final String[] rootQualifiers;
-  private final PermissionService permissionService;
-
-  public SearchProjectPermissionsAction(DbClient dbClient, UserSession userSession, I18n i18n, ResourceTypes resourceTypes,
-                                        PermissionWsSupport wsSupport, PermissionService permissionService) {
-    this.dbClient = dbClient;
-    this.userSession = userSession;
-    this.i18n = i18n;
-    this.resourceTypes = resourceTypes;
-    this.wsSupport = wsSupport;
-    this.rootQualifiers = Collections2.transform(resourceTypes.getRoots(), ResourceType::getQualifier).toArray(new String[resourceTypes.getRoots().size()]);
-    this.permissionService = permissionService;
-  }
-
-  @Override
-  public void define(WebService.NewController context) {
-    WebService.NewAction action = context.createAction("search_project_permissions")
-      .setDescription("List project permissions. A project can be a technical project, a view or a developer.<br />" +
-        "Requires one of the following permissions:" +
-        "<ul>" +
-        "<li>'Administer System'</li>" +
-        "<li>'Administer' rights on the specified project</li>" +
-        "</ul>")
-      .setResponseExample(getClass().getResource("search_project_permissions-example.json"))
-      .setSince("5.2")
-      .setDeprecatedSince("6.5")
-      .addPagingParams(25)
-      .setHandler(this);
-
-    action.createParam(Param.TEXT_QUERY)
-      .setDescription("Limit search to: <ul>" +
-        "<li>project names that contain the supplied string</li>" +
-        "<li>project keys that are exactly the same as the supplied string</li>" +
-        "</ul>")
-      .setExampleValue("apac");
-    createProjectParameters(action);
-    createRootQualifierParameter(action, newQualifierParameterContext(i18n, resourceTypes))
-      .setSince("5.3");
-  }
-
-  @Override
-  public void handle(Request wsRequest, Response wsResponse) throws Exception {
-    SearchProjectPermissionsWsResponse searchProjectPermissionsWsResponse = doHandle(toSearchProjectPermissionsWsRequest(wsRequest));
-    writeProtobuf(searchProjectPermissionsWsResponse, wsRequest, wsResponse);
-  }
-
-  private SearchProjectPermissionsWsResponse doHandle(SearchProjectPermissionsRequest request) {
-    try (DbSession dbSession = dbClient.openSession(false)) {
-      checkAuthorized(dbSession, request);
-      RequestValidator.validateQualifier(request.getQualifier(), resourceTypes);
-      SearchProjectPermissionsData data = load(dbSession, request);
-      return buildResponse(data);
-    }
-  }
-
-  private static SearchProjectPermissionsRequest toSearchProjectPermissionsWsRequest(Request request) {
-    return new SearchProjectPermissionsRequest()
-      .setProjectId(request.param(PARAM_PROJECT_ID))
-      .setProjectKey(request.param(PARAM_PROJECT_KEY))
-      .setQualifier(request.param(PARAM_QUALIFIER))
-      .setPage(request.mandatoryParamAsInt(Param.PAGE))
-      .setPageSize(request.mandatoryParamAsInt(Param.PAGE_SIZE))
-      .setQuery(request.param(Param.TEXT_QUERY));
-  }
-
-  private void checkAuthorized(DbSession dbSession, SearchProjectPermissionsRequest request) {
-    Optional<ProjectWsRef> projectRef = newOptionalWsProjectRef(request.getProjectId(), request.getProjectKey());
-    if (projectRef.isPresent()) {
-      ComponentDto project = wsSupport.getRootComponentOrModule(dbSession, projectRef.get());
-      wsSupport.checkPermissionManagementAccess(userSession, project);
-    } else {
-      userSession.checkLoggedIn().checkIsSystemAdministrator();
-    }
-  }
-
-  private SearchProjectPermissionsWsResponse buildResponse(SearchProjectPermissionsData data) {
-    SearchProjectPermissionsWsResponse.Builder response = SearchProjectPermissionsWsResponse.newBuilder();
-    Permission.Builder permissionResponse = Permission.newBuilder();
-
-    Project.Builder rootComponentBuilder = Project.newBuilder();
-    for (ComponentDto rootComponent : data.rootComponents()) {
-      rootComponentBuilder
-        .clear()
-        .setId(rootComponent.uuid())
-        .setKey(rootComponent.getDbKey())
-        .setQualifier(rootComponent.qualifier())
-        .setName(rootComponent.name());
-      for (String permission : data.permissions(rootComponent.uuid())) {
-        rootComponentBuilder.addPermissions(
-          permissionResponse
-            .clear()
-            .setKey(permission)
-            .setUsersCount(data.userCount(rootComponent.uuid(), permission))
-            .setGroupsCount(data.groupCount(rootComponent.uuid(), permission)));
-      }
-      response.addProjects(rootComponentBuilder);
-    }
-
-    for (String permissionKey : permissionService.getAllProjectPermissions()) {
-      response.addPermissions(
-        permissionResponse
-          .clear()
-          .setKey(permissionKey)
-          .setName(i18nName(permissionKey))
-          .setDescription(i18nDescriptionMessage(permissionKey)));
-    }
-
-    Paging paging = data.paging();
-    response.setPaging(
-      Common.Paging.newBuilder()
-        .setPageIndex(paging.pageIndex())
-        .setPageSize(paging.pageSize())
-        .setTotal(paging.total()));
-
-    return response.build();
-  }
-
-  private String i18nDescriptionMessage(String permissionKey) {
-    return i18n.message(Locale.ENGLISH, PROPERTY_PREFIX + permissionKey + DESCRIPTION_SUFFIX, "");
-  }
-
-  private String i18nName(String permissionKey) {
-    return i18n.message(Locale.ENGLISH, PROPERTY_PREFIX + permissionKey, permissionKey);
-  }
-
-  private SearchProjectPermissionsData load(DbSession dbSession, SearchProjectPermissionsRequest request) {
-    SearchProjectPermissionsData.Builder data = newBuilder();
-    int countRootComponents = countRootComponents(dbSession, request);
-    List<ComponentDto> rootComponents = searchRootComponents(dbSession, request, paging(request, countRootComponents));
-    List<String> rootComponentUuids = Lists.transform(rootComponents, ComponentDto::uuid);
-
-    data.rootComponents(rootComponents)
-      .paging(paging(request, countRootComponents))
-      .userCountByProjectIdAndPermission(userCountByRootComponentUuidAndPermission(dbSession, rootComponentUuids))
-      .groupCountByProjectIdAndPermission(groupCountByRootComponentIdAndPermission(dbSession, rootComponentUuids));
-
-    return data.build();
-  }
-
-  private static Paging paging(SearchProjectPermissionsRequest request, int total) {
-    return forPageIndex(request.getPage())
-      .withPageSize(request.getPageSize())
-      .andTotal(total);
-  }
-
-  private int countRootComponents(DbSession dbSession, SearchProjectPermissionsRequest request) {
-    return dbClient.componentDao().countByQuery(dbSession, toDbQuery(request));
-  }
-
-  private List<ComponentDto> searchRootComponents(DbSession dbSession, SearchProjectPermissionsRequest request, Paging paging) {
-    Optional<ProjectWsRef> project = newOptionalWsProjectRef(request.getProjectId(), request.getProjectKey());
-
-    if (project.isPresent()) {
-      return singletonList(wsSupport.getRootComponentOrModule(dbSession, project.get()));
-    }
-
-    return dbClient.componentDao().selectByQuery(dbSession, toDbQuery(request), paging.offset(), paging.pageSize());
-  }
-
-  private ComponentQuery toDbQuery(SearchProjectPermissionsRequest wsRequest) {
-    return ComponentQuery.builder()
-      .setQualifiers(qualifiers(wsRequest.getQualifier()))
-      .setNameOrKeyQuery(wsRequest.getQuery())
-      .build();
-  }
-
-  private String[] qualifiers(@Nullable String requestQualifier) {
-    return requestQualifier == null
-      ? rootQualifiers
-      : (new String[]{requestQualifier});
-  }
-
-  private Table<String, String, Integer> userCountByRootComponentUuidAndPermission(DbSession dbSession, List<String> rootComponentUuids) {
-    final Table<String, String, Integer> userCountByRootComponentUuidAndPermission = TreeBasedTable.create();
-
-    dbClient.userPermissionDao().countUsersByProjectPermission(dbSession, rootComponentUuids).forEach(
-      row -> userCountByRootComponentUuidAndPermission.put(row.getComponentUuid(), row.getPermission(), row.getCount()));
-
-    return userCountByRootComponentUuidAndPermission;
-  }
-
-  private Table<String, String, Integer> groupCountByRootComponentIdAndPermission(DbSession dbSession, List<String> rootComponentUuids) {
-    final Table<String, String, Integer> userCountByRootComponentUuidAndPermission = TreeBasedTable.create();
-
-    dbClient.groupPermissionDao().groupsCountByComponentUuidAndPermission(dbSession, rootComponentUuids, context -> {
-      CountPerProjectPermission row = context.getResultObject();
-      userCountByRootComponentUuidAndPermission.put(row.getComponentUuid(), row.getPermission(), row.getCount());
-    });
-
-    return userCountByRootComponentUuidAndPermission;
-  }
-
-  private static class SearchProjectPermissionsRequest {
-    private String projectId;
-    private String projectKey;
-    private String qualifier;
-    private Integer page;
-    private Integer pageSize;
-    private String query;
-
-    @CheckForNull
-    public String getProjectId() {
-      return projectId;
-    }
-
-    public SearchProjectPermissionsRequest setProjectId(@Nullable String projectId) {
-      this.projectId = projectId;
-      return this;
-    }
-
-    @CheckForNull
-    public String getProjectKey() {
-      return projectKey;
-    }
-
-    public SearchProjectPermissionsRequest setProjectKey(@Nullable String projectKey) {
-      this.projectKey = projectKey;
-      return this;
-    }
-
-    @CheckForNull
-    public Integer getPage() {
-      return page;
-    }
-
-    public SearchProjectPermissionsRequest setPage(int page) {
-      this.page = page;
-      return this;
-    }
-
-    @CheckForNull
-    public Integer getPageSize() {
-      return pageSize;
-    }
-
-    public SearchProjectPermissionsRequest setPageSize(int pageSize) {
-      this.pageSize = pageSize;
-      return this;
-    }
-
-    @CheckForNull
-    public String getQuery() {
-      return query;
-    }
-
-    public SearchProjectPermissionsRequest setQuery(@Nullable String query) {
-      this.query = query;
-      return this;
-    }
-
-    @CheckForNull
-    public String getQualifier() {
-      return qualifier;
-    }
-
-    public SearchProjectPermissionsRequest setQualifier(@Nullable String qualifier) {
-      this.qualifier = qualifier;
-      return this;
-    }
-  }
-}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/updatecenter/ws/InstalledPluginsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/updatecenter/ws/InstalledPluginsAction.java
deleted file mode 100644 (file)
index 7395e43..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2021 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.updatecenter.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.utils.text.JsonWriter;
-import org.sonar.core.platform.PluginInfo;
-import org.sonar.server.plugins.ServerPluginRepository;
-import org.sonar.updatecenter.common.Version;
-
-/**
- * This web service is used by SonarLint and SonarRunner.
- */
-public class InstalledPluginsAction implements UpdateCenterWsAction {
-
-  private final ServerPluginRepository pluginRepository;
-
-  public InstalledPluginsAction(ServerPluginRepository pluginRepository) {
-    this.pluginRepository = pluginRepository;
-  }
-
-  @Override
-  public void define(WebService.NewController context) {
-    WebService.NewAction action = context.createAction("installed_plugins")
-      .setDescription("Get the list of all the plugins installed on the SonarQube instance")
-      .setSince("2.10")
-      .setDeprecatedSince("6.3")
-      .setInternal(true)
-      .setResponseExample(getClass().getResource("installed_plugins-example.json"))
-      .setHandler(this);
-    action.createParam("format")
-      .setDescription("Only json response format is available")
-      .setPossibleValues("json");
-  }
-
-  @Override
-  public void handle(Request request, Response response) throws Exception {
-    try (JsonWriter json = response.newJsonWriter()) {
-      json.beginArray();
-      for (PluginInfo pluginInfo : pluginRepository.getPluginInfos()) {
-        Version version = pluginInfo.getVersion();
-        json.beginObject()
-          .prop("key", pluginInfo.getKey())
-          .prop("name", pluginInfo.getName());
-        if (version != null) {
-          json.prop("version", version.getName());
-        }
-        json.endObject();
-      }
-      json.endArray().close();
-    }
-  }
-}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/updatecenter/ws/UpdateCenterWs.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/updatecenter/ws/UpdateCenterWs.java
deleted file mode 100644 (file)
index e7433d3..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2021 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.updatecenter.ws;
-
-import java.util.Arrays;
-import org.sonar.api.server.ws.WebService;
-
-public class UpdateCenterWs implements WebService {
-
-  private final UpdateCenterWsAction[] actions;
-
-  public UpdateCenterWs(UpdateCenterWsAction... actions) {
-    this.actions = actions;
-  }
-
-  @Override
-  public void define(Context context) {
-    NewController controller = context.createController("api/updatecenter")
-      .setDescription("Get list of installed plugins")
-      .setSince("2.10");
-    Arrays.stream(actions).forEach(action -> action.define(controller));
-    controller.done();
-  }
-}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/updatecenter/ws/UpdateCenterWsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/updatecenter/ws/UpdateCenterWsAction.java
deleted file mode 100644 (file)
index 6587232..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2021 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.updatecenter.ws;
-
-import org.sonar.server.ws.WsAction;
-
-interface UpdateCenterWsAction extends WsAction {
-  // Marker interface
-}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/updatecenter/ws/UpdateCenterWsModule.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/updatecenter/ws/UpdateCenterWsModule.java
deleted file mode 100644 (file)
index 6c866fa..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2021 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.updatecenter.ws;
-
-import org.sonar.core.platform.Module;
-
-public class UpdateCenterWsModule extends Module {
-  @Override
-  protected void configureModule() {
-    add(
-      InstalledPluginsAction.class,
-      UpdateCenterWs.class
-
-    );
-  }
-}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/updatecenter/ws/package-info.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/updatecenter/ws/package-info.java
deleted file mode 100644 (file)
index 7969dcc..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2021 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.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.server.updatecenter.ws;
-
-import javax.annotation.ParametersAreNonnullByDefault;
index 559ac00d45d9fee3385d3374068fd371e66f9130..35dff200ab1072768861cdd5b4396d2ad33ac955 100644 (file)
@@ -30,6 +30,6 @@ public class PermissionsWsModuleTest {
   public void verify_count_of_added_components() {
     ComponentContainer container = new ComponentContainer();
     new PermissionsWsModule().configure(container);
-    assertThat(container.size()).isEqualTo(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 28);
+    assertThat(container.size()).isEqualTo(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 27);
   }
 }
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest.java
deleted file mode 100644 (file)
index 250a314..0000000
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2021 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.permission.ws;
-
-import java.util.stream.IntStream;
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.resources.Qualifiers;
-import org.sonar.api.resources.ResourceTypes;
-import org.sonar.api.web.UserRole;
-import org.sonar.db.component.ComponentDto;
-import org.sonar.db.component.ComponentTesting;
-import org.sonar.db.component.ResourceTypesRule;
-import org.sonar.db.user.GroupDto;
-import org.sonar.db.user.UserDto;
-import org.sonar.server.exceptions.ForbiddenException;
-import org.sonar.server.exceptions.NotFoundException;
-import org.sonar.server.exceptions.UnauthorizedException;
-import org.sonar.server.l18n.I18nRule;
-import org.sonar.server.permission.PermissionService;
-import org.sonar.server.permission.PermissionServiceImpl;
-import org.sonarqube.ws.Permissions;
-
-import static java.lang.String.format;
-import static org.assertj.core.api.Assertions.assertThat;
-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.sonar.db.component.ComponentTesting.newPrivateProjectDto;
-import static org.sonar.db.component.ComponentTesting.newProjectCopy;
-import static org.sonar.db.component.ComponentTesting.newView;
-import static org.sonar.db.permission.GlobalPermission.ADMINISTER;
-import static org.sonar.test.JsonAssert.assertJson;
-import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PROJECT_ID;
-import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PROJECT_KEY;
-import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_QUALIFIER;
-
-public class SearchProjectPermissionsActionTest extends BasePermissionWsTest<SearchProjectPermissionsAction> {
-
-  private final I18nRule i18n = new I18nRule();
-  private final ResourceTypes resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT);
-  private final PermissionService permissionService = new PermissionServiceImpl(resourceTypes);
-
-  @Before
-  public void setUp() {
-    i18n.setProjectPermissions();
-    userSession.logIn().setSystemAdministrator();
-  }
-
-  @Override
-  protected SearchProjectPermissionsAction buildWsAction() {
-    i18n.setProjectPermissions();
-    ResourceTypesRule rootResourceTypes = newRootResourceTypes();
-    PermissionWsSupport wsSupport = newPermissionWsSupport();
-    return new SearchProjectPermissionsAction(db.getDbClient(), userSession, i18n, rootResourceTypes, wsSupport, permissionService);
-  }
-
-  @Test
-  public void search_project_permissions_counts_0_users_and_0_groups_on_public_project_without_any_specified_permission_in_DB() {
-    ComponentDto project = db.components().insertPublicProject();
-
-    String result = newRequest().execute().getInput();
-
-    assertJson(result)
-      .ignoreFields("permissions")
-      .isSimilarTo("{" +
-        "  \"paging\": {" +
-        "    \"pageIndex\": 1," +
-        "    \"pageSize\": 25," +
-        "    \"total\": 1" +
-        "  }," +
-        "  \"projects\": [" +
-        "    {" +
-        "      \"id\": \"" + project.uuid() + "\"," +
-        "      \"key\": \"" + project.getDbKey() + "\"," +
-        "      \"name\": \"" + project.name() + "\"," +
-        "      \"qualifier\": \"TRK\"," +
-        "      \"permissions\": []" +
-        "    }" +
-        "  ]" +
-        "}");
-  }
-
-  @Test
-  public void search_project_permissions_counts_0_users_and_0_groups_on_private_project_without_any_specified_permission_in_DB() {
-    ComponentDto project = db.components().insertPrivateProject();
-
-    String result = newRequest().execute().getInput();
-
-    assertJson(result)
-      .ignoreFields("permissions")
-      .isSimilarTo("{" +
-        "  \"paging\": {" +
-        "    \"pageIndex\": 1," +
-        "    \"pageSize\": 25," +
-        "    \"total\": 1" +
-        "  }," +
-        "  \"projects\": [" +
-        "    {" +
-        "      \"id\": \"" + project.uuid() + "\"," +
-        "      \"key\": \"" + project.getDbKey() + "\"," +
-        "      \"name\": \"" + project.name() + "\"," +
-        "      \"qualifier\": \"TRK\"," +
-        "      \"permissions\": []" +
-        "    }" +
-        "  ]" +
-        "}");
-  }
-
-  @Test
-  public void search_project_permissions() {
-    UserDto user1 = db.users().insertUser();
-    UserDto user2 = db.users().insertUser();
-    UserDto user3 = db.users().insertUser();
-
-    ComponentDto jdk7 = insertJdk7();
-    ComponentDto project2 = insertClang();
-    ComponentDto view = insertView();
-    insertProjectInView(jdk7, view);
-
-    db.users().insertProjectPermissionOnUser(user1, UserRole.ISSUE_ADMIN, jdk7);
-    db.users().insertProjectPermissionOnUser(user1, UserRole.ADMIN, jdk7);
-    db.users().insertProjectPermissionOnUser(user2, UserRole.ADMIN, jdk7);
-    db.users().insertProjectPermissionOnUser(user3, UserRole.ADMIN, jdk7);
-    db.users().insertProjectPermissionOnUser(user1, UserRole.ISSUE_ADMIN, project2);
-    db.users().insertProjectPermissionOnUser(user1, UserRole.ISSUE_ADMIN, view);
-    // global permission
-    db.users().insertPermissionOnUser(user1, ADMINISTER);
-
-    GroupDto group1 = db.users().insertGroup();
-    GroupDto group2 = db.users().insertGroup();
-    GroupDto group3 = db.users().insertGroup();
-
-    db.users().insertProjectPermissionOnAnyone(UserRole.ADMIN, jdk7);
-    db.users().insertProjectPermissionOnGroup(group1, UserRole.ADMIN, jdk7);
-    db.users().insertProjectPermissionOnGroup(group2, UserRole.ADMIN, jdk7);
-    db.users().insertProjectPermissionOnGroup(group3, UserRole.ADMIN, jdk7);
-    db.users().insertProjectPermissionOnGroup(group2, UserRole.ADMIN, view);
-
-    db.commit();
-
-    String result = newRequest().execute().getInput();
-
-    assertJson(result)
-      .ignoreFields("permissions")
-      .isSimilarTo(getClass().getResource("search_project_permissions-example.json"));
-  }
-
-  @Test
-  public void empty_result() {
-    String result = newRequest().execute().getInput();
-
-    assertJson(result)
-      .ignoreFields("permissions")
-      .isSimilarTo(getClass().getResource("SearchProjectPermissionsActionTest/empty.json"));
-  }
-
-  @Test
-  public void search_project_permissions_with_project_permission() {
-    ComponentDto project = db.components().insertComponent(newPrivateProjectDto("project-uuid"));
-    userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
-
-    String result = newRequest()
-      .setParam(PARAM_PROJECT_ID, "project-uuid")
-      .execute().getInput();
-
-    assertThat(result).contains("project-uuid");
-  }
-
-  @Test
-  public void has_projects_ordered_by_name() {
-    IntStream.rangeClosed(1, 9).forEach(i -> db.components().insertPrivateProject(p -> p.setName("project-name-" + i)));
-
-    String result = newRequest()
-      .setParam(PAGE, "1")
-      .setParam(PAGE_SIZE, "3")
-      .execute().getInput();
-
-    assertThat(result)
-      .contains("project-name-1", "project-name-2", "project-name-3")
-      .doesNotContain("project-name-4");
-  }
-
-  @Test
-  public void search_by_query_on_name() {
-    db.components().insertPrivateProject(p -> p.setName("project-name"));
-    db.components().insertPrivateProject(p -> p.setName("another-name"));
-
-    String result = newRequest()
-      .setParam(TEXT_QUERY, "project")
-      .execute().getInput();
-
-    assertThat(result).contains("project-name")
-      .doesNotContain("another-name");
-  }
-
-  @Test
-  public void search_by_query_on_key_must_match_exactly() {
-    db.components().insertPrivateProject(p -> p.setDbKey("project-key"));
-    db.components().insertPrivateProject(p -> p.setDbKey("another-key"));
-
-    String result = newRequest()
-      .setParam(TEXT_QUERY, "project-key")
-      .execute()
-      .getInput();
-
-    assertThat(result).contains("project-key")
-      .doesNotContain("another-key");
-  }
-
-  @Test
-  public void handle_more_than_1000_projects() {
-    IntStream.rangeClosed(1, 1001).forEach(i -> db.components().insertPrivateProject("project-uuid-" + i));
-
-    String result = newRequest()
-      .setParam(TEXT_QUERY, "project")
-      .setParam(PAGE_SIZE, "1001")
-      .execute()
-      .getInput();
-
-    assertThat(result).contains("project-uuid-1", "project-uuid-999", "project-uuid-1001");
-  }
-
-  @Test
-  public void filter_by_qualifier() {
-    ComponentDto portfolio = db.components().insertPrivatePortfolio();
-    ComponentDto project = db.components().insertPrivateProject();
-
-    Permissions.SearchProjectPermissionsWsResponse result = newRequest()
-      .setParam(PARAM_QUALIFIER, Qualifiers.PROJECT)
-      .executeProtobuf(Permissions.SearchProjectPermissionsWsResponse.class);
-
-    assertThat(result.getProjectsList())
-      .extracting("id")
-      .contains(project.uuid())
-      .doesNotContain(portfolio.uuid());
-  }
-
-  @Test
-  public void fail_if_not_logged_in() {
-    userSession.anonymous();
-
-    expectedException.expect(UnauthorizedException.class);
-
-    newRequest().execute();
-  }
-
-  @Test
-  public void fail_if_not_admin() {
-    userSession.logIn();
-
-    expectedException.expect(ForbiddenException.class);
-
-    newRequest().execute();
-  }
-
-  @Test
-  public void display_all_project_permissions() {
-    String result = newRequest().execute().getInput();
-
-    assertJson(result)
-      .ignoreFields("permissions")
-      .isSimilarTo(getClass().getResource("SearchProjectPermissionsActionTest/display_all_project_permissions.json"));
-  }
-
-  @Test
-  public void fail_when_using_branch_db_key() {
-    ComponentDto project = db.components().insertPublicProject();
-    userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
-    ComponentDto branch = db.components().insertProjectBranch(project);
-
-    expectedException.expect(NotFoundException.class);
-    expectedException.expectMessage(format("Project key '%s' not found", branch.getDbKey()));
-
-    newRequest()
-      .setParam(PARAM_PROJECT_KEY, branch.getDbKey())
-      .execute();
-  }
-
-  private ComponentDto insertView() {
-    return db.components().insertComponent(newView()
-      .setUuid("752d8bfd-420c-4a83-a4e5-8ab19b13c8fc")
-      .setName("Java")
-      .setDbKey("Java"));
-  }
-
-  private void insertProjectInView(ComponentDto project, ComponentDto view) {
-    db.components().insertComponent(newProjectCopy("project-in-view-uuid", project, view));
-  }
-
-  private ComponentDto insertClang() {
-    return db.components().insertComponent(newPrivateProjectDto("project-uuid-2")
-      .setName("Clang")
-      .setDbKey("clang")
-      .setUuid("ce4c03d6-430f-40a9-b777-ad877c00aa4d"));
-  }
-
-  private ComponentDto insertJdk7() {
-    return db.components().insertComponent(ComponentTesting.newPublicProjectDto()
-      .setName("JDK 7")
-      .setDbKey("net.java.openjdk:jdk7")
-      .setUuid("0bd7b1e7-91d6-439e-a607-4a3a9aad3c6a"));
-  }
-}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/updatecenter/ws/PluginsActionTestFilesAndMD5.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/updatecenter/ws/PluginsActionTestFilesAndMD5.java
deleted file mode 100644 (file)
index 20445eb..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2021 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.updatecenter.ws;
-
-import org.junit.Test;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.core.platform.PluginInfo;
-import org.sonar.server.plugins.ServerPluginRepository;
-import org.sonar.server.ws.WsActionTester;
-import org.sonar.updatecenter.common.Version;
-
-import static java.util.Arrays.asList;
-import static java.util.Collections.singletonList;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.sonar.test.JsonAssert.assertJson;
-
-public class PluginsActionTestFilesAndMD5 {
-
-  private ServerPluginRepository pluginRepository = mock(ServerPluginRepository.class);
-
-  private WsActionTester ws = new WsActionTester(new InstalledPluginsAction(pluginRepository));
-
-  @Test
-  public void return_plugins() {
-    when(pluginRepository.getPluginInfos()).thenReturn(asList(
-      new PluginInfo("java").setName("Java").setVersion(Version.create("3.14")),
-      new PluginInfo("xoo").setName("Xoo").setVersion(Version.create("1.0"))));
-
-    String result = ws.newRequest().execute().getInput();
-
-    assertJson(result).isSimilarTo("[" +
-      "  {" +
-      "    \"key\": \"java\",\n" +
-      "    \"name\": \"Java\",\n" +
-      "    \"version\": \"3.14\"\n" +
-      "  }," +
-      "  {" +
-      "    \"key\": \"xoo\",\n" +
-      "    \"name\": \"Xoo\",\n" +
-      "    \"version\": \"1.0\"\n" +
-      "  }" +
-      "]");
-  }
-
-  @Test
-  public void return_plugins_with_plugin_having_no_version() {
-    when(pluginRepository.getPluginInfos()).thenReturn(singletonList(
-      new PluginInfo("java").setName("Java")));
-
-    String result = ws.newRequest().execute().getInput();
-
-    assertJson(result).isSimilarTo("[" +
-      "  {" +
-      "    \"key\": \"java\",\n" +
-      "    \"name\": \"Java\"\n" +
-      "  }" +
-      "]");
-  }
-
-  @Test
-  public void test_example() {
-    when(pluginRepository.getPluginInfos()).thenReturn(asList(
-      new PluginInfo("findbugs").setName("Findbugs").setVersion(Version.create("2.1")),
-      new PluginInfo("l10nfr").setName("French Pack").setVersion(Version.create("1.10")),
-      new PluginInfo("jira").setName("JIRA").setVersion(Version.create("1.2"))));
-
-    String result = ws.newRequest().execute().getInput();
-
-    assertJson(result).isSimilarTo(ws.getDef().responseExampleAsString());
-  }
-
-  @Test
-  public void test_definition() {
-    WebService.Action action = ws.getDef();
-    assertThat(action).isNotNull();
-    assertThat(action.isInternal()).isTrue();
-    assertThat(action.isPost()).isFalse();
-    assertThat(action.responseExampleAsString()).isNotEmpty();
-    assertThat(action.params()).hasSize(1);
-  }
-
-}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/updatecenter/ws/UpdateCenterWsModuleTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/updatecenter/ws/UpdateCenterWsModuleTest.java
deleted file mode 100644 (file)
index 0c9e21d..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2021 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.updatecenter.ws;
-
-import org.junit.Test;
-import org.sonar.core.platform.ComponentContainer;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.core.platform.ComponentContainer.COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER;
-
-public class UpdateCenterWsModuleTest {
-  @Test
-  public void verify_count_of_added_components() {
-    ComponentContainer container = new ComponentContainer();
-    new UpdateCenterWsModule().configure(container);
-    assertThat(container.size()).isEqualTo(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 2);
-  }
-
-
-}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/updatecenter/ws/UpdateCenterWsTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/updatecenter/ws/UpdateCenterWsTest.java
deleted file mode 100644 (file)
index 960a9fe..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2021 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.updatecenter.ws;
-
-import org.junit.Test;
-import org.sonar.api.server.ws.Request;
-import org.sonar.api.server.ws.Response;
-import org.sonar.api.server.ws.WebService;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class UpdateCenterWsTest {
-  private UpdateCenterWs underTest = new UpdateCenterWs(new UpdateCenterWsAction() {
-    @Override
-    public void define(WebService.NewController context) {
-      context.createAction("foo").setHandler(this);
-    }
-
-    @Override
-    public void handle(Request request, Response response) {
-
-    }
-  });
-
-  @Test
-  public void define_controller() {
-    WebService.Context context = new WebService.Context();
-
-    underTest.define(context);
-
-    WebService.Controller controller = context.controller("api/updatecenter");
-    assertThat(controller).isNotNull();
-    assertThat(controller.since()).isEqualTo("2.10");
-    assertThat(controller.description()).isNotEmpty();
-    assertThat(controller.actions()).hasSize(1);
-  }
-}
index e84ffec6efebd36fbf6e543876fe51293811afe8..528fd1c473c607bf464f031d502437b592eb9d2a 100644 (file)
@@ -208,7 +208,6 @@ import org.sonar.server.ui.PageRepository;
 import org.sonar.server.ui.WebAnalyticsLoaderImpl;
 import org.sonar.server.ui.ws.NavigationWsModule;
 import org.sonar.server.updatecenter.UpdateCenterModule;
-import org.sonar.server.updatecenter.ws.UpdateCenterWsModule;
 import org.sonar.server.user.NewUserNotifier;
 import org.sonar.server.user.SecurityRealmFactory;
 import org.sonar.server.user.UserSessionFactoryImpl;
@@ -272,7 +271,6 @@ public class PlatformLevel4 extends PlatformLevel {
 
       // update center
       UpdateCenterModule.class,
-      UpdateCenterWsModule.class,
 
       // quality profile
       BuiltInQProfileDefinitionsBridge.class,