Externalizer returning wrong host name | Community
Skip to main content
trc41594544
Level 3
Jan 18, 2018 7:24 PM UTC
Solved

Externalizer returning wrong host name

Hi,

I have externalizer configuration in AEM for publish as publish http://www.a.com. We have also many subdomains under a.com as b.a.com or c.a.com. We use mappings for both websites and its sub domains.

When i am trying to do externalizer.publishLink(resourceResolver, url) i am getting b.a.com instead of a.com. Everything looks correct with externalizer configuration. If i remove b.a.com mappings from map.local.publish then i am getting a.com as value. I am not sure why this is happening.

My assumption is when i do externalizer.publishLink then it goes to OSGI configuration and get the value present behind "publish". I am not sure from where subdomain host name is showing up.

Any thoughts are welcome.

Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
edubey
edubeyAccepted solution
Level 10
Jan 20, 2018 5:50 PM UTC

As long you have correct config deployed to your instance, externalizer code work fine. You may want to ensure that configs in felix are deployed properly,

Also try using this externalizer.externalLink(resolver, "mydomain", "/my/page") for any custom domain

3 replies

edubey
edubeyAccepted solution
Level 10
Jan 20, 2018 5:50 PM UTC

As long you have correct config deployed to your instance, externalizer code work fine. You may want to ensure that configs in felix are deployed properly,

Also try using this externalizer.externalLink(resolver, "mydomain", "/my/page") for any custom domain

Translate
trc41594544
Level 3
Jan 19, 2018 2:21 PM UTC

Hi,

Below are the configs present in the externalizer OSGI configuration.

local https://localhost:5433

author http://author.a.com

publish http://www.a.com

mobile http://www.a.com

Technically, it should pick up link beside publish, but it is not picking up this.

Below is the code i have written for extracting link

package com.a.com.app;

import com.day.cq.commons.Externalizer;

import org.apache.sling.api.SlingHttpServletRequest;

import org.apache.sling.models.annotations.DefaultInjectionStrategy;

import org.apache.sling.models.annotations.Model;

import org.apache.sling.models.annotations.injectorspecific.OSGiService;

import org.apache.sling.models.annotations.injectorspecific.Self;

import javax.annotation.PostConstruct;

@Model(adaptables = SlingHttpServletRequest.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)

public class component {

   @Self
   SlingHttpServletRequest request;

   @OSGiService
   Externalizer externalizer;

   private String externalizedPath;

   private static final String LOCATION = "/location";

   @PostConstruct
   protected void init() {

  setExternalizedPath(externalizer.publishLink(request.getResourceResolver(), LOCATION));

  }

   public String getExternalizedPath() {

   return externalizedPath;

  }

   public void setExternalizedPath(String externalizedPath) {

   this.externalizedPath = externalizedPath;

  }

}

The output should be "http://www.a.com/location" but instead i am getting "http://b.a.com/location"

Thanks for any help

Translate
edubey
Level 10
Jan 19, 2018 5:19 AM UTC

Your understanding is correct, it picks the osgi config in front of publish.

Can you share your externalizer configs?

Translate