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.platform.ServerFileSystem;
44 import org.sonar.server.rule.RuleDescriptionFormatter;
45 import org.sonar.server.user.SystemPasscode;
46 import org.sonar.server.user.UserSession;
47 import org.sonar.server.v2.api.analysis.controller.DefaultJresController;
48 import org.sonar.server.v2.api.analysis.controller.DefaultVersionController;
49 import org.sonar.server.v2.api.analysis.controller.JresController;
50 import org.sonar.server.v2.api.analysis.controller.ScannerEngineController;
51 import org.sonar.server.v2.api.analysis.controller.DefaultScannerEngineController;
52 import org.sonar.server.v2.api.analysis.controller.VersionController;
53 import org.sonar.server.v2.api.analysis.service.JresHandler;
54 import org.sonar.server.v2.api.analysis.service.JresHandlerImpl;
55 import org.sonar.server.v2.api.analysis.service.ScannerEngineHandler;
56 import org.sonar.server.v2.api.analysis.service.ScannerEngineHandlerImpl;
57 import org.sonar.server.v2.api.dop.controller.DefaultDopSettingsController;
58 import org.sonar.server.v2.api.dop.controller.DopSettingsController;
59 import org.sonar.server.v2.api.gitlab.config.controller.DefaultGitlabConfigurationController;
60 import org.sonar.server.v2.api.gitlab.config.controller.GitlabConfigurationController;
61 import org.sonar.server.v2.api.group.controller.DefaultGroupController;
62 import org.sonar.server.v2.api.group.controller.GroupController;
63 import org.sonar.server.v2.api.membership.controller.DefaultGroupMembershipController;
64 import org.sonar.server.v2.api.membership.controller.GroupMembershipController;
65 import org.sonar.server.v2.api.projectbindings.controller.DefaultProjectBindingsController;
66 import org.sonar.server.v2.api.projectbindings.controller.ProjectBindingsController;
67 import org.sonar.server.v2.api.projects.controller.BoundProjectsController;
68 import org.sonar.server.v2.api.projects.controller.DefaultBoundProjectsController;
69 import org.sonar.server.v2.api.rule.controller.DefaultRuleController;
70 import org.sonar.server.v2.api.rule.controller.RuleController;
71 import org.sonar.server.v2.api.rule.converter.RuleRestResponseGenerator;
72 import org.sonar.server.v2.api.system.controller.DefaultLivenessController;
73 import org.sonar.server.v2.api.system.controller.HealthController;
74 import org.sonar.server.v2.api.system.controller.LivenessController;
75 import org.sonar.server.v2.api.user.controller.DefaultUserController;
76 import org.sonar.server.v2.api.user.controller.UserController;
77 import org.sonar.server.v2.api.user.converter.UsersSearchRestResponseGenerator;
78 import org.sonar.server.v2.common.DeprecatedHandler;
79 import org.springframework.context.annotation.Bean;
80 import org.springframework.context.annotation.Configuration;
81 import org.springframework.context.annotation.Import;
82 import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
85 @Import(CommonWebConfig.class)
86 public class PlatformLevel4WebConfig {
89 public LivenessChecker livenessChecker(DbConnectionNodeCheck dbConnectionNodeCheck, WebServerStatusNodeCheck webServerStatusNodeCheck, CeStatusNodeCheck ceStatusNodeCheck,
90 @Nullable EsStatusNodeCheck esStatusNodeCheck) {
91 return new LivenessCheckerImpl(dbConnectionNodeCheck, webServerStatusNodeCheck, ceStatusNodeCheck, esStatusNodeCheck);
95 public LivenessController livenessController(LivenessChecker livenessChecker, UserSession userSession, SystemPasscode systemPasscode) {
96 return new DefaultLivenessController(livenessChecker, systemPasscode, userSession);
100 public HealthController healthController(HealthChecker healthChecker, SystemPasscode systemPasscode, NodeInformation nodeInformation,
101 UserSession userSession) {
102 return new HealthController(healthChecker, systemPasscode, nodeInformation, userSession);
106 public UsersSearchRestResponseGenerator usersSearchResponseGenerator(UserSession userSession) {
107 return new UsersSearchRestResponseGenerator(userSession);
111 public UserController userController(
112 UserSession userSession,
113 UsersSearchRestResponseGenerator usersSearchResponseGenerator,
114 UserService userService) {
115 return new DefaultUserController(userSession, userService, usersSearchResponseGenerator);
119 public GroupController groupController(UserSession userSession, DbClient dbClient, GroupService groupService, ManagedInstanceChecker managedInstanceChecker) {
120 return new DefaultGroupController(userSession, dbClient, groupService, managedInstanceChecker);
124 public GroupMembershipController groupMembershipsController(UserSession userSession,
125 GroupMembershipService groupMembershipService, ManagedInstanceChecker managedInstanceChecker) {
126 return new DefaultGroupMembershipController(userSession, groupMembershipService, managedInstanceChecker);
130 public RuleRestResponseGenerator ruleRestResponseGenerator(Languages languages, MacroInterpreter macroInterpreter, RuleDescriptionFormatter ruleDescriptionFormatter) {
131 return new RuleRestResponseGenerator(languages, macroInterpreter, ruleDescriptionFormatter);
135 public RuleController ruleController(UserSession userSession, RuleService ruleService, RuleRestResponseGenerator ruleRestResponseGenerator) {
136 return new DefaultRuleController(userSession, ruleService, ruleRestResponseGenerator);
140 public RequestMappingHandlerMapping requestMappingHandlerMapping(UserSession userSession) {
141 RequestMappingHandlerMapping handlerMapping = new RequestMappingHandlerMapping();
142 handlerMapping.setInterceptors(new DeprecatedHandler(userSession));
143 return handlerMapping;
147 public GitlabConfigurationController gitlabConfigurationController(UserSession userSession, GitlabConfigurationService gitlabConfigurationService) {
148 return new DefaultGitlabConfigurationController(userSession, gitlabConfigurationService);
152 public BoundProjectsController importedProjectsController(UserSession userSession, ImportProjectService importProjectService) {
153 return new DefaultBoundProjectsController(userSession, importProjectService);
157 public DopSettingsController dopSettingsController(UserSession userSession, DbClient dbClient) {
158 return new DefaultDopSettingsController(userSession, dbClient);
162 public ProjectBindingsController projectBindingsController(UserSession userSession, ProjectBindingsService projectBindingsService) {
163 return new DefaultProjectBindingsController(userSession, projectBindingsService);
167 public VersionController versionController(Server server) {
168 return new DefaultVersionController(server);
172 public JresHandler jresHandler() {
173 return new JresHandlerImpl();
177 public JresController jresController(JresHandler jresHandler) {
178 return new DefaultJresController(jresHandler);
182 public ScannerEngineHandler scannerEngineHandler(ServerFileSystem serverFileSystem) {
183 return new ScannerEngineHandlerImpl(serverFileSystem);
187 public ScannerEngineController scannerEngineController(ScannerEngineHandler scannerEngineHandler) {
188 return new DefaultScannerEngineController(scannerEngineHandler);