3 * Copyright (C) 2009-2024 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package org.sonar.server.v2.config;
22 import javax.annotation.Nullable;
23 import org.sonar.api.platform.Server;
24 import org.sonar.api.resources.Languages;
25 import org.sonar.db.DbClient;
26 import org.sonar.server.common.gitlab.config.GitlabConfigurationService;
27 import org.sonar.server.common.group.service.GroupMembershipService;
28 import org.sonar.server.common.group.service.GroupService;
29 import org.sonar.server.common.health.CeStatusNodeCheck;
30 import org.sonar.server.common.health.DbConnectionNodeCheck;
31 import org.sonar.server.common.health.EsStatusNodeCheck;
32 import org.sonar.server.common.health.WebServerStatusNodeCheck;
33 import org.sonar.server.common.management.ManagedInstanceChecker;
34 import org.sonar.server.common.platform.LivenessChecker;
35 import org.sonar.server.common.platform.LivenessCheckerImpl;
36 import org.sonar.server.common.project.ImportProjectService;
37 import org.sonar.server.common.projectbindings.service.ProjectBindingsService;
38 import org.sonar.server.common.rule.service.RuleService;
39 import org.sonar.server.common.text.MacroInterpreter;
40 import org.sonar.server.common.user.service.UserService;
41 import org.sonar.server.health.HealthChecker;
42 import org.sonar.server.platform.NodeInformation;
43 import org.sonar.server.rule.RuleDescriptionFormatter;
44 import org.sonar.server.user.SystemPasscode;
45 import org.sonar.server.user.UserSession;
46 import org.sonar.server.v2.api.analysis.controller.DefaultVersionController;
47 import org.sonar.server.v2.api.analysis.controller.VersionController;
48 import org.sonar.server.v2.api.dop.controller.DefaultDopSettingsController;
49 import org.sonar.server.v2.api.dop.controller.DopSettingsController;
50 import org.sonar.server.v2.api.gitlab.config.controller.DefaultGitlabConfigurationController;
51 import org.sonar.server.v2.api.gitlab.config.controller.GitlabConfigurationController;
52 import org.sonar.server.v2.api.group.controller.DefaultGroupController;
53 import org.sonar.server.v2.api.group.controller.GroupController;
54 import org.sonar.server.v2.api.membership.controller.DefaultGroupMembershipController;
55 import org.sonar.server.v2.api.membership.controller.GroupMembershipController;
56 import org.sonar.server.v2.api.projectbindings.controller.DefaultProjectBindingsController;
57 import org.sonar.server.v2.api.projectbindings.controller.ProjectBindingsController;
58 import org.sonar.server.v2.api.projects.controller.BoundProjectsController;
59 import org.sonar.server.v2.api.projects.controller.DefaultBoundProjectsController;
60 import org.sonar.server.v2.api.rule.controller.DefaultRuleController;
61 import org.sonar.server.v2.api.rule.controller.RuleController;
62 import org.sonar.server.v2.api.rule.converter.RuleRestResponseGenerator;
63 import org.sonar.server.v2.api.system.controller.DefaultLivenessController;
64 import org.sonar.server.v2.api.system.controller.HealthController;
65 import org.sonar.server.v2.api.system.controller.LivenessController;
66 import org.sonar.server.v2.api.user.controller.DefaultUserController;
67 import org.sonar.server.v2.api.user.controller.UserController;
68 import org.sonar.server.v2.api.user.converter.UsersSearchRestResponseGenerator;
69 import org.sonar.server.v2.common.DeprecatedHandler;
70 import org.springframework.context.annotation.Bean;
71 import org.springframework.context.annotation.Configuration;
72 import org.springframework.context.annotation.Import;
73 import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
76 @Import(CommonWebConfig.class)
77 public class PlatformLevel4WebConfig {
80 public LivenessChecker livenessChecker(DbConnectionNodeCheck dbConnectionNodeCheck, WebServerStatusNodeCheck webServerStatusNodeCheck, CeStatusNodeCheck ceStatusNodeCheck,
81 @Nullable EsStatusNodeCheck esStatusNodeCheck) {
82 return new LivenessCheckerImpl(dbConnectionNodeCheck, webServerStatusNodeCheck, ceStatusNodeCheck, esStatusNodeCheck);
86 public LivenessController livenessController(LivenessChecker livenessChecker, UserSession userSession, SystemPasscode systemPasscode) {
87 return new DefaultLivenessController(livenessChecker, systemPasscode, userSession);
91 public HealthController healthController(HealthChecker healthChecker, SystemPasscode systemPasscode, NodeInformation nodeInformation,
92 UserSession userSession) {
93 return new HealthController(healthChecker, systemPasscode, nodeInformation, userSession);
97 public UsersSearchRestResponseGenerator usersSearchResponseGenerator(UserSession userSession) {
98 return new UsersSearchRestResponseGenerator(userSession);
102 public UserController userController(
103 UserSession userSession,
104 UsersSearchRestResponseGenerator usersSearchResponseGenerator,
105 UserService userService) {
106 return new DefaultUserController(userSession, userService, usersSearchResponseGenerator);
110 public GroupController groupController(UserSession userSession, DbClient dbClient, GroupService groupService, ManagedInstanceChecker managedInstanceChecker) {
111 return new DefaultGroupController(userSession, dbClient, groupService, managedInstanceChecker);
115 public GroupMembershipController groupMembershipsController(UserSession userSession,
116 GroupMembershipService groupMembershipService, ManagedInstanceChecker managedInstanceChecker) {
117 return new DefaultGroupMembershipController(userSession, groupMembershipService, managedInstanceChecker);
121 public RuleRestResponseGenerator ruleRestResponseGenerator(Languages languages, MacroInterpreter macroInterpreter, RuleDescriptionFormatter ruleDescriptionFormatter) {
122 return new RuleRestResponseGenerator(languages, macroInterpreter, ruleDescriptionFormatter);
126 public RuleController ruleController(UserSession userSession, RuleService ruleService, RuleRestResponseGenerator ruleRestResponseGenerator) {
127 return new DefaultRuleController(userSession, ruleService, ruleRestResponseGenerator);
131 public RequestMappingHandlerMapping requestMappingHandlerMapping(UserSession userSession) {
132 RequestMappingHandlerMapping handlerMapping = new RequestMappingHandlerMapping();
133 handlerMapping.setInterceptors(new DeprecatedHandler(userSession));
134 return handlerMapping;
138 public GitlabConfigurationController gitlabConfigurationController(UserSession userSession, GitlabConfigurationService gitlabConfigurationService) {
139 return new DefaultGitlabConfigurationController(userSession, gitlabConfigurationService);
143 public BoundProjectsController importedProjectsController(UserSession userSession, ImportProjectService importProjectService) {
144 return new DefaultBoundProjectsController(userSession, importProjectService);
148 public DopSettingsController dopSettingsController(UserSession userSession, DbClient dbClient) {
149 return new DefaultDopSettingsController(userSession, dbClient);
153 public ProjectBindingsController projectBindingsController(UserSession userSession, ProjectBindingsService projectBindingsService) {
154 return new DefaultProjectBindingsController(userSession, projectBindingsService);
158 public VersionController versionController(Server server) {
159 return new DefaultVersionController(server);