diff options
author | Aurelien Poscia <aurelien.poscia@sonarsource.com> | 2023-12-07 17:29:41 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-12-22 20:03:02 +0000 |
commit | b0ebb7e25b4ced824865f0d0307629f93a422371 (patch) | |
tree | c08b2e87e729cf7d52b4aa14fb63f7489185c9dd | |
parent | b42d899084e82dd4eb560a05b777880e97c0b496 (diff) | |
download | sonarqube-b0ebb7e25b4ced824865f0d0307629f93a422371.tar.gz sonarqube-b0ebb7e25b4ced824865f0d0307629f93a422371.zip |
SONAR-21121 Add GET /dop-translation/gitlab-configurations/ and refactored resource search
9 files changed, 162 insertions, 5 deletions
diff --git a/server/sonar-alm-client/src/main/java/org/sonar/alm/client/GenericApplicationHttpClient.java b/server/sonar-alm-client/src/main/java/org/sonar/alm/client/GenericApplicationHttpClient.java index fc375f96992..107ee369cd1 100644 --- a/server/sonar-alm-client/src/main/java/org/sonar/alm/client/GenericApplicationHttpClient.java +++ b/server/sonar-alm-client/src/main/java/org/sonar/alm/client/GenericApplicationHttpClient.java @@ -102,7 +102,7 @@ public abstract class GenericApplicationHttpClient implements ApplicationHttpCli } @Override - public Response post(String appUrl, AccessToken token, String endPoint) throws IOException { + public Response post(String appUrl, @Nullable AccessToken token, String endPoint) throws IOException { return doPost(appUrl, token, endPoint, new FormBody.Builder().build()); } diff --git a/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/WebApiEndpoints.java b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/WebApiEndpoints.java index 65511201ae2..bfb2288591b 100644 --- a/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/WebApiEndpoints.java +++ b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/WebApiEndpoints.java @@ -36,6 +36,8 @@ public class WebApiEndpoints { public static final String CLEAN_CODE_POLICY_DOMAIN = "/clean-code-policy"; public static final String RULES_ENDPOINT = CLEAN_CODE_POLICY_DOMAIN + "/rules"; + public static final String INTERNAL = "internal"; + private WebApiEndpoints() { } } diff --git a/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/controller/Searchable.java b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/controller/Searchable.java new file mode 100644 index 00000000000..79b6f5d16bc --- /dev/null +++ b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/controller/Searchable.java @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2023 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.v2.api.controller; + +import javax.validation.Valid; +import org.sonar.server.v2.api.model.RestPage; +import org.sonar.server.v2.api.request.RestSearchRequest; +import org.sonar.server.v2.api.response.RestSearchResponse; +import org.springdoc.api.annotations.ParameterObject; + +public interface Searchable<T, U extends RestSearchRequest> { + + RestSearchResponse<T> search(@Valid @ParameterObject U searchRequest, @Valid @ParameterObject RestPage restPage); + +} diff --git a/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/controller/package-info.java b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/controller/package-info.java new file mode 100644 index 00000000000..61c7fa1e28b --- /dev/null +++ b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/controller/package-info.java @@ -0,0 +1,23 @@ +/* + * SonarQube + * Copyright (C) 2009-2023 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.v2.api.controller; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/model/RestPage.java b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/model/RestPage.java index d7b667480c8..9600b9db8e4 100644 --- a/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/model/RestPage.java +++ b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/model/RestPage.java @@ -22,17 +22,16 @@ package org.sonar.server.v2.api.model; import com.google.common.annotations.VisibleForTesting; import io.swagger.v3.oas.annotations.media.Schema; import javax.validation.constraints.Max; -import javax.validation.constraints.Min; -import javax.validation.constraints.Positive; +import javax.validation.constraints.PositiveOrZero; import org.jetbrains.annotations.Nullable; public record RestPage( - @Min(0) + @PositiveOrZero @Max(500) @Schema(defaultValue = DEFAULT_PAGE_SIZE, description = "Number of results per page. A value of 0 will only return the pagination information.") Integer pageSize, - @Positive + @PositiveOrZero @Schema(defaultValue = DEFAULT_PAGE_INDEX, description = "1-based page index") Integer pageIndex ) { diff --git a/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/request/RestSearchRequest.java b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/request/RestSearchRequest.java new file mode 100644 index 00000000000..746a9deb21c --- /dev/null +++ b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/request/RestSearchRequest.java @@ -0,0 +1,23 @@ +/* + * SonarQube + * Copyright (C) 2009-2023 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.v2.api.request; + +public interface RestSearchRequest { +} diff --git a/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/request/package-info.java b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/request/package-info.java new file mode 100644 index 00000000000..a263f787e1f --- /dev/null +++ b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/request/package-info.java @@ -0,0 +1,23 @@ +/* + * SonarQube + * Copyright (C) 2009-2023 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.v2.api.request; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/response/RestSearchResponse.java b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/response/RestSearchResponse.java new file mode 100644 index 00000000000..7d76340c5fd --- /dev/null +++ b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/response/RestSearchResponse.java @@ -0,0 +1,25 @@ +/* + * SonarQube + * Copyright (C) 2009-2023 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.v2.api.response; + +import java.util.List; + +public record RestSearchResponse<T> (List<T> responses, PageRestResponse page) { +} diff --git a/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/response/SearchRestResponse.java b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/response/SearchRestResponse.java new file mode 100644 index 00000000000..a1bfa9aa7d2 --- /dev/null +++ b/server/sonar-webserver-webapi-v2/src/main/java/org/sonar/server/v2/api/response/SearchRestResponse.java @@ -0,0 +1,30 @@ +/* + * SonarQube + * Copyright (C) 2009-2023 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.v2.api.response; + +import java.util.List; + +public interface SearchRestResponse<T> { + + List<T> responses(); + + PageRestResponse page(); + +} |