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.Database;
26 import org.sonar.db.DbClient;
27 import org.sonar.server.common.email.config.EmailConfigurationService;
28 import org.sonar.server.common.github.config.GithubConfigurationService;
29 import org.sonar.server.common.gitlab.config.GitlabConfigurationService;
30 import org.sonar.server.common.group.service.GroupMembershipService;
31 import org.sonar.server.common.group.service.GroupService;
32 import org.sonar.server.common.health.CeStatusNodeCheck;
33 import org.sonar.server.common.health.DbConnectionNodeCheck;
34 import org.sonar.server.common.health.EsStatusNodeCheck;
35 import org.sonar.server.common.health.WebServerStatusNodeCheck;
36 import org.sonar.server.common.management.ManagedInstanceChecker;
37 import org.sonar.server.common.platform.LivenessChecker;
38 import org.sonar.server.common.platform.LivenessCheckerImpl;
39 import org.sonar.server.common.project.ImportProjectService;
40 import org.sonar.server.common.projectbindings.service.ProjectBindingsService;
41 import org.sonar.server.common.rule.service.RuleService;
42 import org.sonar.server.common.text.MacroInterpreter;
43 import org.sonar.server.common.user.service.UserService;
44 import org.sonar.server.health.HealthChecker;
45 import org.sonar.server.platform.NodeInformation;
46 import org.sonar.server.platform.ServerFileSystem;
47 import org.sonar.server.platform.db.migration.DatabaseMigrationState;
48 import org.sonar.server.platform.db.migration.version.DatabaseVersion;
49 import org.sonar.server.rule.RuleDescriptionFormatter;
50 import org.sonar.server.user.SystemPasscode;
51 import org.sonar.server.user.UserSession;
52 import org.sonar.server.v2.api.analysis.controller.DefaultJresController;
53 import org.sonar.server.v2.api.analysis.controller.DefaultScannerEngineController;
54 import org.sonar.server.v2.api.analysis.controller.DefaultVersionController;
55 import org.sonar.server.v2.api.analysis.controller.JresController;
56 import org.sonar.server.v2.api.analysis.controller.ScannerEngineController;
57 import org.sonar.server.v2.api.analysis.controller.VersionController;
58 import org.sonar.server.v2.api.analysis.service.JresHandler;
59 import org.sonar.server.v2.api.analysis.service.JresHandlerImpl;
60 import org.sonar.server.v2.api.analysis.service.ScannerEngineHandler;
61 import org.sonar.server.v2.api.analysis.service.ScannerEngineHandlerImpl;
62 import org.sonar.server.v2.api.dop.controller.DefaultDopSettingsController;
63 import org.sonar.server.v2.api.dop.controller.DopSettingsController;
64 import org.sonar.server.v2.api.email.config.controller.DefaultEmailConfigurationController;
65 import org.sonar.server.v2.api.email.config.controller.EmailConfigurationController;
66 import org.sonar.server.v2.api.github.config.controller.DefaultGithubConfigurationController;
67 import org.sonar.server.v2.api.github.config.controller.GithubConfigurationController;
68 import org.sonar.server.v2.api.gitlab.config.controller.DefaultGitlabConfigurationController;
69 import org.sonar.server.v2.api.gitlab.config.controller.GitlabConfigurationController;
70 import org.sonar.server.v2.api.group.controller.DefaultGroupController;
71 import org.sonar.server.v2.api.group.controller.GroupController;
72 import org.sonar.server.v2.api.membership.controller.DefaultGroupMembershipController;
73 import org.sonar.server.v2.api.membership.controller.GroupMembershipController;
74 import org.sonar.server.v2.api.projectbindings.controller.DefaultProjectBindingsController;
75 import org.sonar.server.v2.api.projectbindings.controller.ProjectBindingsController;
76 import org.sonar.server.v2.api.projects.controller.BoundProjectsController;
77 import org.sonar.server.v2.api.projects.controller.DefaultBoundProjectsController;
78 import org.sonar.server.v2.api.rule.controller.DefaultRuleController;
79 import org.sonar.server.v2.api.rule.controller.RuleController;
80 import org.sonar.server.v2.api.rule.converter.RuleRestResponseGenerator;
81 import org.sonar.server.v2.api.system.controller.DatabaseMigrationsController;
82 import org.sonar.server.v2.api.system.controller.DefaultLivenessController;
83 import org.sonar.server.v2.api.system.controller.HealthController;
84 import org.sonar.server.v2.api.system.controller.LivenessController;
85 import org.sonar.server.v2.api.user.controller.DefaultUserController;
86 import org.sonar.server.v2.api.user.controller.UserController;
87 import org.sonar.server.v2.api.user.converter.UsersSearchRestResponseGenerator;
88 import org.sonar.server.v2.common.DeprecatedHandler;
89 import org.springframework.context.annotation.Bean;
90 import org.springframework.context.annotation.Configuration;
91 import org.springframework.context.annotation.Import;
92 import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
95 @Import(CommonWebConfig.class)
96 public class PlatformLevel4WebConfig {
99 public LivenessChecker livenessChecker(DbConnectionNodeCheck dbConnectionNodeCheck, WebServerStatusNodeCheck webServerStatusNodeCheck, CeStatusNodeCheck ceStatusNodeCheck,
100 @Nullable EsStatusNodeCheck esStatusNodeCheck) {
101 return new LivenessCheckerImpl(dbConnectionNodeCheck, webServerStatusNodeCheck, ceStatusNodeCheck, esStatusNodeCheck);
105 public LivenessController livenessController(LivenessChecker livenessChecker, UserSession userSession, SystemPasscode systemPasscode) {
106 return new DefaultLivenessController(livenessChecker, systemPasscode, userSession);
110 public HealthController healthController(HealthChecker healthChecker, SystemPasscode systemPasscode, NodeInformation nodeInformation,
111 UserSession userSession) {
112 return new HealthController(healthChecker, systemPasscode, nodeInformation, userSession);
116 public DatabaseMigrationsController databaseMigrationsController(DatabaseVersion databaseVersion, DatabaseMigrationState databaseMigrationState,
118 return new DatabaseMigrationsController(databaseVersion, databaseMigrationState, database);
122 public UsersSearchRestResponseGenerator usersSearchResponseGenerator(UserSession userSession) {
123 return new UsersSearchRestResponseGenerator(userSession);
127 public UserController userController(
128 UserSession userSession,
129 UsersSearchRestResponseGenerator usersSearchResponseGenerator,
130 UserService userService) {
131 return new DefaultUserController(userSession, userService, usersSearchResponseGenerator);
135 public GroupController groupController(UserSession userSession, DbClient dbClient, GroupService groupService, ManagedInstanceChecker managedInstanceChecker) {
136 return new DefaultGroupController(userSession, dbClient, groupService, managedInstanceChecker);
140 public GroupMembershipController groupMembershipsController(UserSession userSession,
141 GroupMembershipService groupMembershipService, ManagedInstanceChecker managedInstanceChecker) {
142 return new DefaultGroupMembershipController(userSession, groupMembershipService, managedInstanceChecker);
146 public RuleRestResponseGenerator ruleRestResponseGenerator(Languages languages, MacroInterpreter macroInterpreter, RuleDescriptionFormatter ruleDescriptionFormatter) {
147 return new RuleRestResponseGenerator(languages, macroInterpreter, ruleDescriptionFormatter);
151 public RuleController ruleController(UserSession userSession, RuleService ruleService, RuleRestResponseGenerator ruleRestResponseGenerator) {
152 return new DefaultRuleController(userSession, ruleService, ruleRestResponseGenerator);
156 public RequestMappingHandlerMapping requestMappingHandlerMapping(UserSession userSession) {
157 RequestMappingHandlerMapping handlerMapping = new RequestMappingHandlerMapping();
158 handlerMapping.setInterceptors(new DeprecatedHandler(userSession));
159 return handlerMapping;
163 public GitlabConfigurationController gitlabConfigurationController(UserSession userSession, GitlabConfigurationService gitlabConfigurationService) {
164 return new DefaultGitlabConfigurationController(userSession, gitlabConfigurationService);
168 public GithubConfigurationController githubConfigurationController(UserSession userSession, GithubConfigurationService githubConfigurationService) {
169 return new DefaultGithubConfigurationController(userSession, githubConfigurationService);
173 public BoundProjectsController importedProjectsController(UserSession userSession, ImportProjectService importProjectService) {
174 return new DefaultBoundProjectsController(userSession, importProjectService);
178 public DopSettingsController dopSettingsController(UserSession userSession, DbClient dbClient) {
179 return new DefaultDopSettingsController(userSession, dbClient);
183 public ProjectBindingsController projectBindingsController(UserSession userSession, ProjectBindingsService projectBindingsService) {
184 return new DefaultProjectBindingsController(userSession, projectBindingsService);
188 public VersionController versionController(Server server) {
189 return new DefaultVersionController(server);
193 public JresHandler jresHandler() {
194 return new JresHandlerImpl();
198 public JresController jresController(JresHandler jresHandler) {
199 return new DefaultJresController(jresHandler);
203 public ScannerEngineHandler scannerEngineHandler(ServerFileSystem serverFileSystem) {
204 return new ScannerEngineHandlerImpl(serverFileSystem);
208 public ScannerEngineController scannerEngineController(ScannerEngineHandler scannerEngineHandler) {
209 return new DefaultScannerEngineController(scannerEngineHandler);
213 public EmailConfigurationController emailConfigurationController(UserSession userSession, EmailConfigurationService emailConfigurationService) {
214 return new DefaultEmailConfigurationController(userSession, emailConfigurationService);