Expand my Community achievements bar.

How to prioritize Sling internalRedirect ?

Avatar

Level 4

I have a situation where I have two mappings in etc.maps with `sling:internalRedirects`.

 

Map 1: maps /content/brand to a custom domain name, brand.com 

Map 2: maps /content/brand/retailers/retailer to a custom domain name, retailer.brand.com

 

My issues is map 1 is prioritized over map 2.

I always get brand.com/retailers/retailers instead of retailer.brand.com. 

Yet, I can clearly see it as a 2nd option in "Other Candidates" in the JCR Resolver at http://localhost:4503/system/console/jcrresolver.

 

Map 1

 

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
	jcr:primaryType="sling:Mapping"
	sling:match="content/brand/country(.+)"
	sling:internalRedirect="[/content/brand/country$1]"/>

 

 

Map 2

 

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
	jcr:primaryType="sling:Mapping"
	sling:match="content/brand/country/retailers/retailer(.*)"
	sling:internalRedirect="[/content/brand/country/retailers/retailer$1]"/>

 

 

How could I make sure Map 2 is used? 

2 Replies

Avatar

Level 4

One of my colleagues solved the issue. He adapted the JcrResourceResolverFactoryImpl config file and sling mappings.

 

org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl.config

resource.resolver.required.providernames=["JCR"]
resource.resolver.manglenamespaces=B"true"
resource.resolver.optimize.alias.resolution=B"true"
resource.resolver.vanitypath.blacklist=["/content/usergenerated"]
resource.resolver.vanity.precedence=B"false"
resource.resolver.vanitypath.maxEntries=I"-1"
resource.resolver.required.providers=[""]
resource.resolver.enable.vanitypath=B"true"
resource.resolver.providerhandling.paranoid=B"false"
resource.resolver.allowDirect=B"true"
resource.resolver.mapping=["/-/"]
resource.resolver.vanitypath.whitelist=["/apps/","/libs/","/content/"]
resource.resolver.map.location="/etc/map"
resource.resolver.vanitypath.maxEntries.startup=B"true"
resource.resolver.map.observation=["/"]
resource.resolver.default.vanity.redirect.status=I"302"
resource.resolver.vanitypath.bloomfilter.maxBytes=I"1024000"
resource.resolver.searchpath=["/apps","/libs"]
resource.resolver.log.unclosed=B"false"
resource.resolver.log.closing=B"false"
resource.resolver.virtual=[
  "https://www.brand.com:/content/brand",
  "https://retailer.brand.com/:/content/brand/retailers/retailer"
]

 

ui.apps/src/main/content/jcr_root/etc/map.prod/https/retailer.brand.com.443/.content.xml

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
	jcr:primaryType="sling:Mapping"
	sling:match="content/brand/retailers/retailer(.*)"
	sling:internalRedirect="[/content/brand/retailers/retailer$1]"/>

 

ui.apps/src/main/content/jcr_root/etc/map.prod/https/retailer.brand.com.443/content/.content.xml

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root 
	xmlns:sling="http://sling.apache.org/jcr/sling/1.0" 
	xmlns:jcr="http://www.jcp.org/jcr/1.0"
	jcr:primaryType="sling:Mapping"
	sling:internalRedirect="[/content/brand/retailers/retailer]"/>