Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

DAM Asset Usage Information

Avatar

Community Advisor

I want to get usage information of any DAM asset. That means suppose an Image is used in different content. I want that information or the location where the image has been used.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @AsifChowdhury ,

You can get the reference information from properties as suggest by @milind_bachani .

Also there is ReferenceSearch API to get reference in java as below.

You can pass asset or page path from servlet parameter and import ReferenceSearch.

import com.day.cq.wcm.commons.ReferenceSearch;

 

resourceResolver = request.getResourceResolver();
//Asset or Page Path
String pagePath = request.getParameter("pagePath");

/* Reference Search of Page
* Provide list of all pages where current page are being Used */
ReferenceSearch referenceSearch = new ReferenceSearch();
referenceSearch.setExact(true);
referenceSearch.setHollow(true);
referenceSearch.setMaxReferencesPerPage(-1);

Collection<ReferenceSearch.Info> resultSet = referenceSearch.search(resourceResolver, pagePath).values();
for (ReferenceSearch.Info info : resultSet) {
String currentPage = info.getPagePath();
//Custom code using reference page path
}

Regards

Shiv

 

 

 

Shiv Prakash

View solution in original post

4 Replies

Avatar

Employee Advisor

Hi @AsifChowdhury ,

You can refer to references tab in asset properties, find below:

milind_bachani_0-1683538862293.png


Best,

Milind

Avatar

Community Advisor

@milind_bachani , Can I get that information programmatically in JAVA? Do you know any way to do it or can you give me any reference?

Avatar

Correct answer by
Community Advisor

Hi @AsifChowdhury ,

You can get the reference information from properties as suggest by @milind_bachani .

Also there is ReferenceSearch API to get reference in java as below.

You can pass asset or page path from servlet parameter and import ReferenceSearch.

import com.day.cq.wcm.commons.ReferenceSearch;

 

resourceResolver = request.getResourceResolver();
//Asset or Page Path
String pagePath = request.getParameter("pagePath");

/* Reference Search of Page
* Provide list of all pages where current page are being Used */
ReferenceSearch referenceSearch = new ReferenceSearch();
referenceSearch.setExact(true);
referenceSearch.setHollow(true);
referenceSearch.setMaxReferencesPerPage(-1);

Collection<ReferenceSearch.Info> resultSet = referenceSearch.search(resourceResolver, pagePath).values();
for (ReferenceSearch.Info info : resultSet) {
String currentPage = info.getPagePath();
//Custom code using reference page path
}

Regards

Shiv

 

 

 

Shiv Prakash