Expand my Community achievements bar.

SOLVED

Get Scheme(http/https..etc) serverName and ServerPort in EventHandler

Avatar

Level 2

Hi,

 

I have added one class that implements EventHandler for ReplicationAction.EVENT_TOPIC , I publish the content from Author and that same time I get call in my event handler class, here I want to know server details like, scheme, server name and server port, can any one guide me how I can achieve this.

Let me explain my requirements, I am publishing the content from Author and when get call in event handler I call GraphiQL(http://localhost:4502/content/graphiql.html.) for data and that data I am indexing in solr. I can get solr server details but not http://localhost:4502/. SO I need this http://localhost:4502/ in event handler class. 

 

Thanks,

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@kumamanish Please let the domain name and other details from the Externalizer Service

To define a domain mapping for the Externalizer service:

  1. Navigate to the configuration manager via Tools, then Web Console, or enter https://<host>:<port>/system/console/configMgr.

  2. Click Day CQ Link Externalizer to open the configuration dialog box.

    shaileshbassi_0-1657092474186.png

     

  3. Define a domain mapping: a mapping consists of a unique name that can be used in the code to reference the domain, a space and the domain:

    <unique-name> [scheme://]server[:port][/contextpath], where:

    • scheme is usually http or https, but can also be ftp etc.; use https to enforce https links if desired; it will be used if the client code does not override the scheme when asking for externalization of a URL.
    • server is the host name (can be a domain name or ip address).
    • port (optional) is the port number.
    • contextpath (optional) is only set if AEM is installed as a webapp under a different context path.

    For example: production https://my.production.instance

    The following mapping names are predefined and must always be set as AEM relies on them:

    • local - the local instance
    • author - the authoring system DNS
    • publish - the public facing website DNS

Code snippet for getting the value from externalized service

shaileshbassi_1-1657092723323.png

Hope this helps!

Thanks

 

View solution in original post

4 Replies

Avatar

Correct answer by
Community Advisor

@kumamanish Please let the domain name and other details from the Externalizer Service

To define a domain mapping for the Externalizer service:

  1. Navigate to the configuration manager via Tools, then Web Console, or enter https://<host>:<port>/system/console/configMgr.

  2. Click Day CQ Link Externalizer to open the configuration dialog box.

    shaileshbassi_0-1657092474186.png

     

  3. Define a domain mapping: a mapping consists of a unique name that can be used in the code to reference the domain, a space and the domain:

    <unique-name> [scheme://]server[:port][/contextpath], where:

    • scheme is usually http or https, but can also be ftp etc.; use https to enforce https links if desired; it will be used if the client code does not override the scheme when asking for externalization of a URL.
    • server is the host name (can be a domain name or ip address).
    • port (optional) is the port number.
    • contextpath (optional) is only set if AEM is installed as a webapp under a different context path.

    For example: production https://my.production.instance

    The following mapping names are predefined and must always be set as AEM relies on them:

    • local - the local instance
    • author - the authoring system DNS
    • publish - the public facing website DNS

Code snippet for getting the value from externalized service

shaileshbassi_1-1657092723323.png

Hope this helps!

Thanks

 

Avatar

Level 2

Awesome @Shailesh_Bassi_ , finally I got author link by using externalizer.authorLink(resourceResolver, "").     At last of link I am adding asset path for my requirements.

 

Appreciated your help.

Avatar

Community Advisor

Hi @kumamanish 

 

You can get the Protocal, Servername and Serverport from CQ Link Externalizer configration.  Create local OSGi configration as shown below in the screen shot and also you need use the externalizer and use below code 

 

String publishUrl = externalizer.publishLink(resolver, payloadPath + CommonConstants.SUFFIX_HTML);

 

Jagadeesh_Prakash_0-1657100376524.png

 

If the domain is different from the current server,  You can put the other domain in a different configration seperatly. 

Avatar

Level 2

Thank you so much @Jagadeesh_Prakash , definitely it helped me and will help me in future if we use different domains.