내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

Get path of actual resource if only given usage reference

Avatar

Level 3
Hi all,

Is it possible to get the actual path of a resource, if we only know where it was used?

For example, I have a policy being used on a template at:
/conf/we-retail/settings/wcm/templates/section-page/policies/jcr:content/root/responsivegrid/weretail/components/content/teaser/policy_1526037253202

Having the above path, I want to get the path of the actual policy, which is should be:
/conf/we-retail/settings/wcm/policies/weretail/components/content/teaser/policy_1526037253202

Is this possible? Thanks
1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Employee Advisor

Hi @sean12341 ,

 

There are multiple ways to achieve it.

  1. You could use a JCR SQL2 query like below, using the policy name and executing in query editor of CRXDE

 

SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE([/conf/we-retail]) AND NAME() = 'policy_1526037253202'

 

 

   This will give you the path "/conf/we- retail/settings/wcm/policies/weretail/components/content/teaser/policy_1526037253202" in      the result.

 

2. Quite a manual approach, because if you look at the path there is a pattern

 /conf/we-retail/settings/wcm/templates/section-page/policies/jcr:content/root/responsivegrid/weretail/components/content/teaser/policy_1526037253202

/conf/we-retail/settings/wcm/policies/weretail/components/content/teaser/policy_1526037253202

 

All you need to do is pick the partial path and append "/conf/we-retail/settings/wcm/policies" and you will always end up into the same directory.

 

Hope that helps!

 

Regards,

Nitesh

 

원본 게시물의 솔루션 보기

4 답변 개

Avatar

정확한 답변 작성자:
Employee Advisor

Hi @sean12341 ,

 

There are multiple ways to achieve it.

  1. You could use a JCR SQL2 query like below, using the policy name and executing in query editor of CRXDE

 

SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE([/conf/we-retail]) AND NAME() = 'policy_1526037253202'

 

 

   This will give you the path "/conf/we- retail/settings/wcm/policies/weretail/components/content/teaser/policy_1526037253202" in      the result.

 

2. Quite a manual approach, because if you look at the path there is a pattern

 /conf/we-retail/settings/wcm/templates/section-page/policies/jcr:content/root/responsivegrid/weretail/components/content/teaser/policy_1526037253202

/conf/we-retail/settings/wcm/policies/weretail/components/content/teaser/policy_1526037253202

 

All you need to do is pick the partial path and append "/conf/we-retail/settings/wcm/policies" and you will always end up into the same directory.

 

Hope that helps!

 

Regards,

Nitesh

 

Avatar

Community Advisor

where you wanted to get the actual path, in code?

If in code you just need to get property value for policy and get the resource object with the help of resource resolver for the path.

 

 

Avatar

Level 3

Yes I want to get the path programmatically. 

Could you provide an example or pseudo code of how it can be done? 

I have tried the following:

 

resourceResolver.getResource("/conf/we-retail/settings/wcm/templates/section-page/policies/jcr:content/root/responsivegrid/weretail/components/content/teaser").getValueMap().get("cq:policy")

 

But still only returns the relative path of the policy, which is:

"weretail/components/content/teaser/policy_1526037253202"

 

Thanks

Avatar

Employee Advisor

Why would you need that? Currently that is an implementation detail of AEM, and trying to rely on the implementation (although not specified) might work, but it could also break in interesting and unexpceted ways.