environment-dependent /etc/map config for CQ 5.6 for instance shared by multiple apps | Community
Skip to main content
avni27
Level 2
October 7, 2021
Solved

environment-dependent /etc/map config for CQ 5.6 for instance shared by multiple apps

  • October 7, 2021
  • 2 replies
  • 2452 views

Hi Community, 

Do we have a way to implement redirection using /etc/map configuration for different environment, for example: /etc/map.qa.publish and /etc/map.prod.publish. There are also other apps hosted in the same instance, so we do not want to completely overwrite the regular '/etc/map' mapping location for this change, as it could disturb the configurations present for other websites.We are using CQ 5.6 version.

Is any structure possible which could accommodate this request? 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by lukasz-m

@avni27 I think this should be possible, but you will probably need to copy all generic mappings under more specific path, so i.e. under /etc/map.qa.publish you can store all specific mapping for qa env and all generic ones, and similar approach for /etc/map.prod.publish. This is of course not the ideal approach, and you will need to keep and manage generic mappings in multiple places but in the other hand all the rest you got out of the box. So if generic mappings are not changed too often, this could be an acceptable compromise.

2 replies

lukasz-m
Community Advisor
Community Advisor
October 7, 2021

Hi @avni27, in general you can point to specific mapping location using org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl OSGi configuration - changing value of resource.resolver.map.location

In other words, you can have dedicated OSGi configuration for each environment, base on run mode different OSGi configuration will be applied. Inside each configuration you can set mapping location specific for given environment.

avni27
avni27Author
Level 2
October 7, 2021

Hi @lukasz-m , 

Thanks for replying, However

I have customized the configuration - org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl but this makes the environment specific '/etc/map' location default for all applications sharing the instance.

There are 3 applications using served from this instance, A, B and C.

Two of them, A and B already use the generic sling mappings for all environments, the nodes fall under '/etc/map' location. I will need them to work along with the fix.

While the requirement of the third application, C is to have different environment dependent sling mappings, hence created /etc/map.qa.publish and /etc/map.prod.publish. 

So the problem is - if my customization overwrites the path of 'Mapping location' to /etc/map.qa.publish then the other mappings won't be effective.

lukasz-m
Community Advisor
lukasz-mCommunity AdvisorAccepted solution
Community Advisor
October 7, 2021

@avni27 I think this should be possible, but you will probably need to copy all generic mappings under more specific path, so i.e. under /etc/map.qa.publish you can store all specific mapping for qa env and all generic ones, and similar approach for /etc/map.prod.publish. This is of course not the ideal approach, and you will need to keep and manage generic mappings in multiple places but in the other hand all the rest you got out of the box. So if generic mappings are not changed too often, this could be an acceptable compromise.

joerghoh
Adobe Employee
Adobe Employee
October 8, 2021

The Sling Mapping configuration is global for the whole AEM instance, you cannot decide on a per-page/request/... basis to use a specific mapping.

 

Instead you should adjust your mapping that it can work for all type of pages for your instance, and due to the structure of the mappings, this is definitely possible. I did not came across a situation where it was required to use distinct mapping configurations.

avni27
avni27Author
Level 2
October 12, 2021

Thanks @joerghoh ,

Adding mapping for qa.publish and prod.publish worked out. I have decided to keep '/etc/map' folder as it is and have separate sling:folder with different mappings for qa and prod matching their domains they will pick the sling:redirect appropriately. So the structure now is : 

/etc

     /map

             /qa.C.publish

             /prod.C.publish

             /A.publish

             /B.publish