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.resources.Languages;
24 import org.sonar.db.DbClient;
25 import org.sonar.server.common.gitlab.config.GitlabConfigurationService;
26 import org.sonar.server.common.group.service.GroupMembershipService;
27 import org.sonar.server.common.group.service.GroupService;
28 import org.sonar.server.common.health.CeStatusNodeCheck;
29 import org.sonar.server.common.health.DbConnectionNodeCheck;
30 import org.sonar.server.common.health.EsStatusNodeCheck;
31 import org.sonar.server.common.health.WebServerStatusNodeCheck;
32 import org.sonar.server.common.management.ManagedInstanceChecker;
33 import org.sonar.server.common.platform.LivenessChecker;
34 import org.sonar.server.common.platform.LivenessCheckerImpl;
35 import org.sonar.server.common.project.ImportProjectService;
36 import org.sonar.server.common.rule.service.RuleService;
37 import org.sonar.server.common.text.MacroInterpreter;
38 import org.sonar.server.common.user.service.UserService;
39 import org.sonar.server.health.HealthChecker;
40 import org.sonar.server.platform.NodeInformation;
41 import org.sonar.server.rule.RuleDescriptionFormatter;
42 import org.sonar.server.user.SystemPasscode;
43 import org.sonar.server.user.UserSession;
44 import org.sonar.server.v2.api.gitlab.config.controller.DefaultGitlabConfigurationController;
45 import org.sonar.server.v2.api.gitlab.config.controller.GitlabConfigurationController;
46 import org.sonar.server.v2.api.group.controller.DefaultGroupController;
47 import org.sonar.server.v2.api.group.controller.GroupController;
48 import org.sonar.server.v2.api.membership.controller.DefaultGroupMembershipController;
49 import org.sonar.server.v2.api.membership.controller.GroupMembershipController;
50 import org.sonar.server.v2.api.projects.controller.DefaultBoundProjectsController;
51 import org.sonar.server.v2.api.projects.controller.BoundProjectsController;
52 import org.sonar.server.v2.api.rule.controller.DefaultRuleController;
53 import org.sonar.server.v2.api.rule.controller.RuleController;
54 import org.sonar.server.v2.api.rule.converter.RuleRestResponseGenerator;
55 import org.sonar.server.v2.api.system.controller.DefaultLivenessController;
56 import org.sonar.server.v2.api.system.controller.HealthController;
57 import org.sonar.server.v2.api.system.controller.LivenessController;
58 import org.sonar.server.v2.api.user.controller.DefaultUserController;
59 import org.sonar.server.v2.api.user.controller.UserController;
60 import org.sonar.server.v2.api.user.converter.UsersSearchRestResponseGenerator;
61 import org.sonar.server.v2.common.DeprecatedHandler;
62 import org.springframework.context.annotation.Bean;
63 import org.springframework.context.annotation.Configuration;
64 import org.springframework.context.annotation.Import;
65 import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
68 @Import(CommonWebConfig.class)
69 public class PlatformLevel4WebConfig {
72 public LivenessChecker livenessChecker(DbConnectionNodeCheck dbConnectionNodeCheck, WebServerStatusNodeCheck webServerStatusNodeCheck, CeStatusNodeCheck ceStatusNodeCheck,
73 @Nullable EsStatusNodeCheck esStatusNodeCheck) {
74 return new LivenessCheckerImpl(dbConnectionNodeCheck, webServerStatusNodeCheck, ceStatusNodeCheck, esStatusNodeCheck);
78 public LivenessController livenessController(LivenessChecker livenessChecker, UserSession userSession, SystemPasscode systemPasscode) {
79 return new DefaultLivenessController(livenessChecker, systemPasscode, userSession);
83 public HealthController healthController(HealthChecker healthChecker, SystemPasscode systemPasscode, NodeInformation nodeInformation,
84 UserSession userSession) {
85 return new HealthController(healthChecker, systemPasscode, nodeInformation, userSession);
89 public UsersSearchRestResponseGenerator usersSearchResponseGenerator(UserSession userSession) {
90 return new UsersSearchRestResponseGenerator(userSession);
94 public UserController userController(
95 UserSession userSession,
96 UsersSearchRestResponseGenerator usersSearchResponseGenerator,
97 UserService userService) {
98 return new DefaultUserController(userSession, userService, usersSearchResponseGenerator);
102 public GroupController groupController(UserSession userSession, DbClient dbClient, GroupService groupService, ManagedInstanceChecker managedInstanceChecker) {
103 return new DefaultGroupController(userSession, dbClient, groupService, managedInstanceChecker);
107 public GroupMembershipController groupMembershipsController(UserSession userSession,
108 GroupMembershipService groupMembershipService, ManagedInstanceChecker managedInstanceChecker) {
109 return new DefaultGroupMembershipController(userSession, groupMembershipService, managedInstanceChecker);
113 public RuleRestResponseGenerator ruleRestResponseGenerator(Languages languages, MacroInterpreter macroInterpreter, RuleDescriptionFormatter ruleDescriptionFormatter) {
114 return new RuleRestResponseGenerator(languages, macroInterpreter, ruleDescriptionFormatter);
118 public RuleController ruleController(UserSession userSession, RuleService ruleService, RuleRestResponseGenerator ruleRestResponseGenerator) {
119 return new DefaultRuleController(userSession, ruleService, ruleRestResponseGenerator);
123 public RequestMappingHandlerMapping requestMappingHandlerMapping(UserSession userSession) {
124 RequestMappingHandlerMapping handlerMapping = new RequestMappingHandlerMapping();
125 handlerMapping.setInterceptors(new DeprecatedHandler(userSession));
126 return handlerMapping;
130 public GitlabConfigurationController gitlabConfigurationController(UserSession userSession, GitlabConfigurationService gitlabConfigurationService) {
131 return new DefaultGitlabConfigurationController(userSession, gitlabConfigurationService);
135 public BoundProjectsController importedProjectsController(UserSession userSession, ImportProjectService importProjectService) {
136 return new DefaultBoundProjectsController(
137 userSession, importProjectService);