Expand my Community achievements bar.

Handling multiple domains using Externalizer

Avatar

Level 4

Hello All - Is there a way to configure the externalizer for multiple publish domains? We have 4 domains in our project and would like to maintain the externalizer config based on run-modes. In the externalizer config it says, we need to specify publish followed by domain to specify the configs. i.e 

publish www.example1.com

publish www.example2.com

publish www.example3.com

publish www.example4.com

How can I specify the configs. Since all are different domains.

 

com.day.cq.commons.impl.ExternalizerImpl

 

8 Replies

Avatar

Level 2

Have you explored context-aware configuration for your problem? I believe you should be able to create separate configs for different paths of your repository.

Avatar

Level 4
@mayank_saklech1 - Actually the same content slice (i.e /content/test/en/) is used for all four sites. we cannot use context-aware here as the path is same.

Avatar

Level 3

Hi @aemninja,

    I tried using the different domains but when try to call them using externalizer api then it is throwing error that
error: cannot find the symbol:
[ERROR] variable PUBLISH_CA
[ERROR] location: interface Externalizer

This is the piece of code that I am using : 
externalizer.externalLink(resolver, Externalizer.PUBLISH_CA, "/my/page") + ".html";
can you please help me here.

 

Thanks,

Pavan

Avatar

Level 3

Hi @mayank_saklech1 ,

 I tried using the different domains but when try to call them using externalizer api then it is throwing error that
error: cannot find the symbol:
[ERROR] variable PUBLISH_CA
[ERROR] location: interface Externalizer

This is the piece of code that I am using : 
externalizer.externalLink(resolver, Externalizer.PUBLISH_CA, "/my/page") + ".html";
can you please help me here.

 

Thanks,

Pavan

Avatar

Community Advisor

Hi @aemninja 

 

You can define it in the OOTB configuration.i.e., with com.day.cq.commons.impl.ExternalizerImpl.xml and add the domain names. In your code you can read the configuration by passing the domain name.

<?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:OsgiConfig"
externalizer.domains="[author http://localhost:4502,publish http://localhost:4503,website1 https://www.website1.com,website2 https://www.website2.com]"/>

 

Thanks! 

Avatar

Level 2

This Doesn't actually work, not sure if there is any other customization needed on AEM on cloud.

Avatar

Employee Advisor

@aemninja  Once you define various domains in externalizer, you would be able to refer those in the code as below:

String myExternalizedUrl = externalizer.externalLink(resolver, Externalizer.LOCAL, "/my/page") + ".html";

Avatar

Level 1

Do we need to add this logic to very component?