Skip to content

Commit

Permalink
#26503 include in 23.10.24 LTS
Browse files Browse the repository at this point in the history
  • Loading branch information
erickgonzalez committed Feb 13, 2025
1 parent 26e6346 commit 7d9c7db
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions dotCMS/hotfix_tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 5 additions & 4 deletions dotCMS/src/main/java/com/dotcms/rest/api/CorsFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;


/**
Expand All @@ -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<String, List<String[]>> headerMap;
final private Lazy<Map<String, List<String[]>>> headerMap = Lazy.of(this::loadHeaders);

public CorsFilter() {
Map<String, List<String[]>> loadHeaders() {
Map<String, List<String[]>> loadingMap = new HashMap<>();
final List<String> props = Config.subsetContainsAsList(CORS_PREFIX);
props.forEach(key -> {
Expand All @@ -43,7 +44,7 @@ public CorsFilter() {
loadingMap.put(mapping, keys);

});
this.headerMap = ImmutableMap.copyOf(loadingMap);
return ImmutableMap.copyOf(loadingMap);
}


Expand All @@ -69,7 +70,7 @@ public void filter(ContainerRequestContext requestContext, ContainerResponseCont


protected List<String[]> getHeaders(final String mapping) {
List<String[]> corsHeaders = headerMap.containsKey(mapping) ? headerMap.get(mapping) : headerMap.get(CORS_DEFAULT);
final List<String[]> corsHeaders = headerMap.get().containsKey(mapping) ? headerMap.get().get(mapping) : headerMap.get().get(CORS_DEFAULT);
return corsHeaders != null ? corsHeaders : ImmutableList.of() ;

}
Expand Down
3 changes: 3 additions & 0 deletions dotCMS/src/main/java/com/dotmarketing/util/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,9 @@ protected static void refreshProperties() {
public static List<String> subsetContainsAsList(final String containsString){
final List<String> fullListProps = new ArrayList<String>();
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);
Expand Down

0 comments on commit 7d9c7db

Please sign in to comment.