This is an automated email from the ASF dual-hosted git repository. cziegeler pushed a commit to branch issues/SLING-11742 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-resourceresolver.git
The following commit(s) were added to refs/heads/issues/SLING-11742 by this push: new 446f7ec Move vanity configuration to configurer class 446f7ec is described below commit 446f7ec776bc66ecb81582a80bf495c0e7f5ed3b Author: Carsten Ziegeler <cziege...@apache.org> AuthorDate: Sat Jun 3 11:06:07 2023 +0200 Move vanity configuration to configurer class --- .../impl/CommonResourceResolverFactoryImpl.java | 19 +----------- .../impl/VanityPathConfigurer.java | 35 ++++++++++++++-------- 2 files changed, 24 insertions(+), 30 deletions(-) diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/CommonResourceResolverFactoryImpl.java b/src/main/java/org/apache/sling/resourceresolver/impl/CommonResourceResolverFactoryImpl.java index 8391a5d..d04942f 100644 --- a/src/main/java/org/apache/sling/resourceresolver/impl/CommonResourceResolverFactoryImpl.java +++ b/src/main/java/org/apache/sling/resourceresolver/impl/CommonResourceResolverFactoryImpl.java @@ -450,24 +450,7 @@ public class CommonResourceResolverFactoryImpl implements MapConfigurationProvid @Override public List<VanityPathConfig> getVanityPathConfig() { - final List<String> includes = this.activator.getVanityPathConfigurer().getVanityPathAllowList(); - final List<String> excludes = this.activator.getVanityPathConfigurer().getVanityPathDenyList(); - if ( includes == null && excludes == null ) { - return null; - } - final List<VanityPathConfig> configs = new ArrayList<>(); - if ( includes != null ) { - for(final String val : includes) { - configs.add(new VanityPathConfig(val, false)); - } - } - if ( excludes != null ) { - for(final String val : excludes) { - configs.add(new VanityPathConfig(val, true)); - } - } - Collections.sort(configs); - return configs; + return this.activator.getVanityPathConfigurer().getVanityPathConfig(); } @Override diff --git a/src/main/java/org/apache/sling/resourceresolver/impl/VanityPathConfigurer.java b/src/main/java/org/apache/sling/resourceresolver/impl/VanityPathConfigurer.java index e904a71..d4ff5b3 100644 --- a/src/main/java/org/apache/sling/resourceresolver/impl/VanityPathConfigurer.java +++ b/src/main/java/org/apache/sling/resourceresolver/impl/VanityPathConfigurer.java @@ -19,7 +19,10 @@ package org.apache.sling.resourceresolver.impl; import java.util.ArrayList; +import java.util.Collections; import java.util.List; + +import org.apache.sling.resourceresolver.impl.mapping.MapConfigurationProvider.VanityPathConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,24 +31,35 @@ class VanityPathConfigurer { private volatile ResourceResolverFactoryConfig config; - /** Vanity path allow list */ - private volatile List<String> vanityPathAllowList; - - /** Vanity path deny list */ - private volatile List<String> vanityPathDenyList; + private volatile List<VanityPathConfig> vanityPathConfig; public void setConfiguration(final ResourceResolverFactoryConfig c) { this.config = c; + this.vanityPathConfig = null; - this.vanityPathAllowList = this.configureVanityPathPrefixes(c.resource_resolver_vanitypath_allowlist(), + final List<String> includes = this.configureVanityPathPrefixes(c.resource_resolver_vanitypath_allowlist(), c.resource_resolver_vanitypath_whitelist(), "resource_resolver_vanitypath_allowlist", "resource_resolver_vanitypath_whitelist"); - this.vanityPathDenyList = this.configureVanityPathPrefixes(c.resource_resolver_vanitypath_denylist(), + final List<String> excludes = this.configureVanityPathPrefixes(c.resource_resolver_vanitypath_denylist(), c.resource_resolver_vanitypath_blacklist(), "resource_resolver_vanitypath_denylist", "resource_resolver_vanitypath_blacklist"); + if ( includes != null || excludes != null ) { + this.vanityPathConfig = new ArrayList<>(); + if ( includes != null ) { + for(final String val : includes) { + this.vanityPathConfig.add(new VanityPathConfig(val, false)); + } + } + if ( excludes != null ) { + for(final String val : excludes) { + this.vanityPathConfig.add(new VanityPathConfig(val, true)); + } + } + Collections.sort(this.vanityPathConfig); + } } public int getDefaultVanityPathRedirectStatus() { @@ -60,13 +74,10 @@ class VanityPathConfigurer { return this.config.resource_resolver_vanitypath_cache_in_background(); } - public List<String> getVanityPathAllowList() { - return this.vanityPathAllowList; + public List<VanityPathConfig> getVanityPathConfig() { + return this.vanityPathConfig; } - public List<String> getVanityPathDenyList() { - return this.vanityPathDenyList; - } public boolean hasVanityPathPrecedence() { return this.config.resource_resolver_vanity_precedence();