Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Absolute URL for assets and links localized to AEM in content fragments

ManojSj
Level 2
Level 2

Hi Experts,

 

We have a use case to send the absolute or full URL's for localized assets/links configured from AEM in fragments. This is being consumed by another non aem application by making model json API call. The content fragments authored with links have relative URL's in JSON. Is there a way to achieve this without code changes at present in AEM 6.4.x version? If not, could you please let us know how we can achieve or go about this request?

 

Edit: This query is not related to custom components created using sling models or at component level. It's Absolute url for all assets and content links to be available for all content fragments created using a content model. 

 

Thanks.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution
SureshDhulipudi
Correct answer by
Community Advisor
Community Advisor

If you are using Sling Model to send the URL to JSON, you can construct the Url explicitly in the URL variable

 

@ValueMapValue
@Optional
private String fullurl;

 

@PostConstruct
private void activate(){
// build the Full URL with absolute path
fullurl = <<<construct -- path>>> ;
}

View solution in original post

5 Replies
SureshDhulipudi
Correct answer by
Community Advisor
Community Advisor

If you are using Sling Model to send the URL to JSON, you can construct the Url explicitly in the URL variable

 

@ValueMapValue
@Optional
private String fullurl;

 

@PostConstruct
private void activate(){
// build the Full URL with absolute path
fullurl = <<<construct -- path>>> ;
}

View solution in original post

ManojSj
Level 2
Level 2

Hi @SureshDhulipudi,

This is applicable for individual or custom component implemented using sling models, which is not relevant for our case. Our use case is to have absolute url for all assets and content links to be available for all the content fragments created using content model whenever a JSON GET call is made to it.

Thanks 

SureshDhulipudi
Community Advisor
Community Advisor
can you write logic in consumer application?, construct the Full URL in consumer application after reading the JSON, apply the logic in consumer JSON read method
ManojSj
Level 2
Level 2
Hi @SureshDhulipudi, We don't have control on consumer end in this case. Moreover it's reasonable that consumer is expecting AEM to send Absolute URL, reason being that it can be an non AEM application and /content/dam* or /content/* does not give any context for them. Thanks
SureshDhulipudi
Community Advisor
Community Advisor
I don't think this is possible without a custom JSON or JSON Exporter, OOTB model.json will provide only relative URLs / paths of the content and assists. You have to write a custom JSON Exporter and Service to give absolute path in JSON