]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-18654 add ability to check if instance is managed.
authorWojtek Wajerowicz <115081248+wojciech-wajerowicz-sonarsource@users.noreply.github.com>
Wed, 8 Mar 2023 09:42:19 +0000 (10:42 +0100)
committersonartech <sonartech@sonarsource.com>
Wed, 22 Mar 2023 20:04:06 +0000 (20:04 +0000)
server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/ManagedInstanceChecker.java [new file with mode: 0644]

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 (file)
index 0000000..ed87df8
--- /dev/null
@@ -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.");
+  }
+}