Request Resource resolver resolve is not working | Community
Skip to main content
kaikubad
Community Advisor
Community Advisor
January 26, 2023
Solved

Request Resource resolver resolve is not working

  • January 26, 2023
  • 4 replies
  • 5041 views

We are using AEM 6.5.14. The map and reverse map is properly configured. From /system/console/jcrresolver the resolve and map is working fine.

But from code we can not get the full path from domain. In short request.getResourceResolver().resolve("http://local.---world.com").getPath() is not returning the full path. 

THE MAP

 

FROM  /system/console/jcrresolver

 

FROM code map is working

BUT from code resolve is not working


 

What could be the possible solution?????

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 kaikubad

Tried too many things, but the resurceReolver.resolve() is not working.
Finally moved to manual solution.

  1. Created the reverse map node on /etc/map
  2. Searching manually under /etc/map when needed with the domaain
  3. Then concatinating with path.

4 replies

nitesh_kumar-1
Adobe Employee
Adobe Employee
January 26, 2023

Hi @kaikubad ,

 

The "resolve" method expects the path of the resource, you have to write something like this:-

 

resourceResolver.resolve("/content/something")

Also, take a look at the API documentation for more details about these methods.

https://sling.apache.org/apidocs/sling11/org/apache/sling/api/resource/ResourceResolver.html 

 

Hope this helps!

 

Regards,

Nitesh

kaikubad
Community Advisor
kaikubadCommunity AdvisorAuthor
Community Advisor
January 26, 2023

I was actually looking for the full path from domain. In this case i dont know the /content/something.
I only have http://local.---world.com/. From this I have to find the actual path mapped with it.

I need this from http://local.---world.com  -to>  content/---world/global/en.

nitesh_kumar-1
Adobe Employee
Adobe Employee
January 26, 2023

If you have access to the slingRequest object, then you could use it to get the resource path, something like this:-

 

request.getRequestPathInfo().getResourcePath()

 

Anudeep_Garnepudi
Community Advisor
Community Advisor
January 26, 2023

@kaikubad 

Can you try resourceResolver.map(...) instead of resolve. 

 

AG
kaikubad
Community Advisor
kaikubadCommunity AdvisorAuthor
Community Advisor
January 26, 2023

map is to convert long path to short path.
i.e : contentPath=/content/---world/global/en.

now if i use resourceResolver.map(contentPath) then it will retuen http://local.---world.com/en.

I need the reverse one. I need  this from http://local.---world.com  -to>  content/---world/global.

Ankur_Khare
Community Advisor
Community Advisor
January 26, 2023

Can u try this 

${request.requestURL.toString}
rampai
Community Advisor
Community Advisor
January 27, 2023
kaikubad
Community Advisor
kaikubadCommunity AdvisorAuthor
Community Advisor
February 9, 2023

Thanks,The documentation is very good.

But unfortunately this doesn't work.

kaikubad
Community Advisor
kaikubadCommunity AdvisorAuthorAccepted solution
Community Advisor
February 9, 2023

Tried too many things, but the resurceReolver.resolve() is not working.
Finally moved to manual solution.

  1. Created the reverse map node on /etc/map
  2. Searching manually under /etc/map when needed with the domaain
  3. Then concatinating with path.