From fb1d8a7c055bf75468b384837f34034da2eb8273 Mon Sep 17 00:00:00 2001 From: Wojtek Wajerowicz <115081248+wojciech-wajerowicz-sonarsource@users.noreply.github.com> Date: Wed, 8 Mar 2023 10:42:19 +0100 Subject: [PATCH] SONAR-18654 add ability to check if instance is managed. --- .../usergroups/ws/ManagedInstanceChecker.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/ManagedInstanceChecker.java diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/ManagedInstanceChecker.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/ManagedInstanceChecker.java new file mode 100644 index 00000000000..ed87df8c2ba --- /dev/null +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/ManagedInstanceChecker.java @@ -0,0 +1,17 @@ +package org.sonar.server.usergroups.ws; + +import org.sonar.server.exceptions.BadRequestException; +import org.sonar.server.management.ManagedInstanceService; + +public class ManagedInstanceChecker { + + private final ManagedInstanceService managedInstanceService; + + public ManagedInstanceChecker(ManagedInstanceService managedInstanceService) { + this.managedInstanceService = managedInstanceService; + } + + public void checkInstanceIsNotExternallyManaged() { + BadRequestException.checkRequest(!managedInstanceService.isInstanceExternallyManaged(), "Operation not allowed when instance is externally managed."); + } +} -- 2.39.5