From bf2dd869432718cf65c03612e6c3faac91680ddb Mon Sep 17 00:00:00 2001 From: Ole Vester Date: Tue, 15 Oct 2024 15:59:17 +0200 Subject: [PATCH] Temporarily use PROFILE_CORE to verify getOrThrow --- .../java/de/tum/cit/aet/artemis/core/api/AbstractApi.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/tum/cit/aet/artemis/core/api/AbstractApi.java b/src/main/java/de/tum/cit/aet/artemis/core/api/AbstractApi.java index e0af79532cc7..b05200bc7a93 100644 --- a/src/main/java/de/tum/cit/aet/artemis/core/api/AbstractApi.java +++ b/src/main/java/de/tum/cit/aet/artemis/core/api/AbstractApi.java @@ -1,5 +1,7 @@ package de.tum.cit.aet.artemis.core.api; +import static de.tum.cit.aet.artemis.core.config.Constants.PROFILE_CORE; + import java.util.Optional; import org.springframework.core.env.Environment; @@ -18,13 +20,15 @@ public AbstractApi(Environment environment, String profileName) { this.profileName = profileName; } - public boolean isActive() { + public boolean isActive(String profileName) { return environment.acceptsProfiles(Profiles.of(profileName)); } /** @noinspection OptionalUsedAsFieldOrParameterType */ protected T getOrThrow(Optional instance) { - if (!isActive() || instance.isEmpty()) { + // noinspection UnnecessaryLocalVariable + String moduleProfileName = PROFILE_CORE; // in the future, we will switch to profileName + if (!isActive(moduleProfileName) || instance.isEmpty()) { throw new ModuleNotPresentException(profileName); } return instance.get();