From: Wojtek Wajerowicz <115081248+wojciech-wajerowicz-sonarsource@users.noreply.github.com> Date: Wed, 8 Mar 2023 09:42:19 +0000 (+0100) Subject: SONAR-18654 add ability to check if instance is managed. X-Git-Tag: 10.0.0.68432~104 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fb1d8a7c055bf75468b384837f34034da2eb8273;p=sonarqube.git SONAR-18654 add ability to check if instance is managed. --- 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."); + } +}