diff --git a/dotCMS/hotfix_tracking.md b/dotCMS/hotfix_tracking.md index 6bb0ca1f0c65..9f9a7be6f8d6 100644 --- a/dotCMS/hotfix_tracking.md +++ b/dotCMS/hotfix_tracking.md @@ -192,3 +192,4 @@ This maintenance release includes the following code fixes: 185. https://github.com/dotCMS/core/issues/30804 : The file with name of webPageContent.vtl can't GET and throws 404 #30804 186. https://github.com/dotCMS/core/issues/30993 : Remove calls to ElasticReadOnlyCommand and disable EsReadOnlyMonitorJob #30468 187. https://github.com/dotCMS/core/issues/30993 : In 24.12.10 the EsReadOnlyMonitorJob still shows error #30993 +188. https://github.com/dotCMS/core/issues/26503 : CORS not applied when specifying resource #26503 diff --git a/dotCMS/src/main/java/com/dotcms/rest/api/CorsFilter.java b/dotCMS/src/main/java/com/dotcms/rest/api/CorsFilter.java index 20984087c3e0..8f2ce4874cb3 100644 --- a/dotCMS/src/main/java/com/dotcms/rest/api/CorsFilter.java +++ b/dotCMS/src/main/java/com/dotcms/rest/api/CorsFilter.java @@ -16,6 +16,7 @@ import com.dotmarketing.util.Logger; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import io.vavr.Lazy; /** @@ -26,9 +27,9 @@ public class CorsFilter implements ContainerResponseFilter { final public static String CORS_PREFIX = "api.cors"; final public static String CORS_DEFAULT = "default"; - final private Map> headerMap; + final private Lazy>> headerMap = Lazy.of(this::loadHeaders); - public CorsFilter() { + Map> loadHeaders() { Map> loadingMap = new HashMap<>(); final List props = Config.subsetContainsAsList(CORS_PREFIX); props.forEach(key -> { @@ -43,7 +44,7 @@ public CorsFilter() { loadingMap.put(mapping, keys); }); - this.headerMap = ImmutableMap.copyOf(loadingMap); + return ImmutableMap.copyOf(loadingMap); } @@ -69,7 +70,7 @@ public void filter(ContainerRequestContext requestContext, ContainerResponseCont protected List getHeaders(final String mapping) { - List corsHeaders = headerMap.containsKey(mapping) ? headerMap.get(mapping) : headerMap.get(CORS_DEFAULT); + final List corsHeaders = headerMap.get().containsKey(mapping) ? headerMap.get().get(mapping) : headerMap.get().get(CORS_DEFAULT); return corsHeaders != null ? corsHeaders : ImmutableList.of() ; } diff --git a/dotCMS/src/main/java/com/dotmarketing/util/Config.java b/dotCMS/src/main/java/com/dotmarketing/util/Config.java index af7da4b19b0b..e768dc497a25 100644 --- a/dotCMS/src/main/java/com/dotmarketing/util/Config.java +++ b/dotCMS/src/main/java/com/dotmarketing/util/Config.java @@ -346,6 +346,9 @@ protected static void refreshProperties() { public static List subsetContainsAsList(final String containsString){ final List fullListProps = new ArrayList(); props.getKeys().forEachRemaining(fullListProps::add); + if(null != systemTableConfigSource && enableSystemTableConfigSource){ + systemTableConfigSource.getPropertyNames().forEach(fullListProps::add); + } //List with all system env props that contains the pattern final String envContainsString = envKey(containsString);