Request Resource resolver resolve is not working | Community
Skip to main content
kaikubad
New Participant
Jan 26, 2023 5:53 AM UTC
Solved

Request Resource resolver resolve is not working

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.
kaikubad
kaikubadAccepted solution
New Participant
Feb 9, 2023 5:46 AM UTC

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.

13 replies

kaikubad
kaikubadAuthorAccepted solution
New Participant
Feb 9, 2023 5:46 AM UTC

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.
Translate
rampai
Level 1
Jan 27, 2023 9:54 AM UTC
kaikubad
kaikubadAuthor
New Participant
Feb 9, 2023 5:19 AM UTC

Thanks,The documentation is very good.

But unfortunately this doesn't work.

Translate
Anudeep_Garnepudi
New Participant
Jan 26, 2023 8:07 AM UTC

@kaikubad 

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

 

Translate
kaikubad
kaikubadAuthor
New Participant
Jan 26, 2023 8:29 AM UTC

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.

Translate
Ankur_Khare
New Participant
Jan 26, 2023 8:50 AM UTC

Can u try this 

${request.requestURL.toString}
Translate
nitesh_kumar-1
Employee
Jan 26, 2023 6:47 AM UTC

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

Translate
kaikubad
kaikubadAuthor
New Participant
Jan 26, 2023 6:54 AM UTC

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.

Translate
nitesh_kumar-1
Employee
Jan 26, 2023 7:09 AM UTC

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

 

request.getRequestPathInfo().getResourcePath()

 

Translate