Skip to content

Commit

Permalink
Temporarily use PROFILE_CORE to verify getOrThrow
Browse files Browse the repository at this point in the history
  • Loading branch information
ole-ve committed Oct 15, 2024
1 parent a8f0cc0 commit bf2dd86
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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> T getOrThrow(Optional<T> 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();
Expand Down

0 comments on commit bf2dd86

Please sign in to comment.