diff --git a/src/main/java/com/contentgrid/gateway/runtime/config/ApplicationConfiguration.java b/src/main/java/com/contentgrid/gateway/runtime/config/ApplicationConfiguration.java index 21559e7b..7b3e25f2 100644 --- a/src/main/java/com/contentgrid/gateway/runtime/config/ApplicationConfiguration.java +++ b/src/main/java/com/contentgrid/gateway/runtime/config/ApplicationConfiguration.java @@ -1,7 +1,5 @@ package com.contentgrid.gateway.runtime.config; -import static com.contentgrid.gateway.runtime.config.ApplicationConfiguration.Keys.DELIMITER_REGEX; - import com.contentgrid.gateway.runtime.application.ApplicationId; import java.util.Arrays; import java.util.Map.Entry; @@ -34,6 +32,10 @@ class Keys { Optional getProperty(@NonNull String property); + default Stream getProperties(@NonNull String property) { + return this.getProperty(property).stream(); + } + Stream keys(); Stream> stream(); @@ -51,14 +53,15 @@ default String getIssuerUri() { } default Set getDomains() { - return Arrays.stream(this.getProperty(Keys.ROUTING_DOMAINS).orElse("").split(DELIMITER_REGEX)) + return Arrays.stream(this.getProperty(Keys.ROUTING_DOMAINS).orElse("").split(Keys.DELIMITER_REGEX)) .map(String::trim) .filter(str -> !str.isBlank()) .collect(Collectors.toSet()); } default Set getCorsOrigins() { - return Arrays.stream(this.getProperty(Keys.CORS_ORIGINS).orElse("").split(DELIMITER_REGEX)) + return this.getProperties(Keys.CORS_ORIGINS) + .flatMap(value -> Stream.of(value.split(Keys.DELIMITER_REGEX))) .map(String::trim) .filter(str -> !str.isBlank()) .collect(Collectors.toSet()); diff --git a/src/main/java/com/contentgrid/gateway/runtime/config/ComposedApplicationConfiguration.java b/src/main/java/com/contentgrid/gateway/runtime/config/ComposedApplicationConfiguration.java index 7a4a7485..5b701f7d 100644 --- a/src/main/java/com/contentgrid/gateway/runtime/config/ComposedApplicationConfiguration.java +++ b/src/main/java/com/contentgrid/gateway/runtime/config/ComposedApplicationConfiguration.java @@ -50,11 +50,17 @@ public String getConfigurationId() { @Override public Optional getProperty(@NonNull String property) { + return this.getProperties(property).findFirst(); + } + + @Override + public Stream getProperties(@NonNull String property) { return this.fragments.values().stream() - .flatMap(frag -> frag.getProperty(property).stream()) - .findFirst(); + .flatMap(frag -> frag.getProperty(property).stream()); } + + public Stream> stream() { return this.keys().flatMap(key -> this.getProperty(key).stream().map(prop -> Map.entry(key, prop))); }