3 * Copyright (C) 2009-2023 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.db.DbClient;
24 import org.sonar.server.common.group.service.GroupMembershipService;
25 import org.sonar.server.common.group.service.GroupService;
26 import org.sonar.server.common.health.CeStatusNodeCheck;
27 import org.sonar.server.common.health.DbConnectionNodeCheck;
28 import org.sonar.server.common.health.EsStatusNodeCheck;
29 import org.sonar.server.common.health.WebServerStatusNodeCheck;
30 import org.sonar.server.common.management.ManagedInstanceChecker;
31 import org.sonar.server.common.platform.LivenessChecker;
32 import org.sonar.server.common.platform.LivenessCheckerImpl;
33 import org.sonar.server.common.rule.service.RuleService;
34 import org.sonar.server.common.user.service.UserService;
35 import org.sonar.server.health.HealthChecker;
36 import org.sonar.server.platform.NodeInformation;
37 import org.sonar.server.user.SystemPasscode;
38 import org.sonar.server.user.UserSession;
39 import org.sonar.server.v2.api.group.controller.DefaultGroupController;
40 import org.sonar.server.v2.api.group.controller.GroupController;
41 import org.sonar.server.v2.api.membership.controller.DefaultGroupMembershipController;
42 import org.sonar.server.v2.api.membership.controller.GroupMembershipController;
43 import org.sonar.server.v2.api.rule.controller.DefaultRuleController;
44 import org.sonar.server.v2.api.rule.controller.RuleController;
45 import org.sonar.server.v2.api.rule.converter.RuleRestResponseGenerator;
46 import org.sonar.server.v2.api.system.controller.DefaultLivenessController;
47 import org.sonar.server.v2.api.system.controller.HealthController;
48 import org.sonar.server.v2.api.system.controller.LivenessController;
49 import org.sonar.server.v2.api.user.controller.DefaultUserController;
50 import org.sonar.server.v2.api.user.controller.UserController;
51 import org.sonar.server.v2.api.user.converter.UsersSearchRestResponseGenerator;
52 import org.springframework.context.annotation.Bean;
53 import org.springframework.context.annotation.Configuration;
54 import org.springframework.context.annotation.Import;
57 @Import(CommonWebConfig.class)
58 public class PlatformLevel4WebConfig {
61 public LivenessChecker livenessChecker(DbConnectionNodeCheck dbConnectionNodeCheck, WebServerStatusNodeCheck webServerStatusNodeCheck, CeStatusNodeCheck ceStatusNodeCheck,
62 @Nullable EsStatusNodeCheck esStatusNodeCheck) {
63 return new LivenessCheckerImpl(dbConnectionNodeCheck, webServerStatusNodeCheck, ceStatusNodeCheck, esStatusNodeCheck);
67 public LivenessController livenessController(LivenessChecker livenessChecker, UserSession userSession, SystemPasscode systemPasscode) {
68 return new DefaultLivenessController(livenessChecker, systemPasscode, userSession);
72 public HealthController healthController(HealthChecker healthChecker, SystemPasscode systemPasscode, NodeInformation nodeInformation,
73 UserSession userSession) {
74 return new HealthController(healthChecker, systemPasscode, nodeInformation, userSession);
78 public UsersSearchRestResponseGenerator usersSearchResponseGenerator(UserSession userSession) {
79 return new UsersSearchRestResponseGenerator(userSession);
83 public UserController userController(
84 UserSession userSession,
85 UsersSearchRestResponseGenerator usersSearchResponseGenerator,
86 UserService userService) {
87 return new DefaultUserController(userSession, userService, usersSearchResponseGenerator);
91 public GroupController groupController(UserSession userSession, DbClient dbClient, GroupService groupService, ManagedInstanceChecker managedInstanceChecker) {
92 return new DefaultGroupController(userSession, dbClient, groupService, managedInstanceChecker);
97 public GroupMembershipController groupMembershipsController(UserSession userSession,
98 GroupMembershipService groupMembershipService, ManagedInstanceChecker managedInstanceChecker) {
99 return new DefaultGroupMembershipController(userSession, groupMembershipService, managedInstanceChecker);
103 public RuleRestResponseGenerator ruleRestResponseGenerator() {
104 return new RuleRestResponseGenerator();
108 public RuleController ruleController(UserSession userSession, RuleService ruleService, RuleRestResponseGenerator ruleRestResponseGenerator) {
109 return new DefaultRuleController(userSession, ruleService, ruleRestResponseGenerator);