Monday, July 20, 2015

How to find dam assets referenced on the page

How to find page dependencies w.r.t to dam assets i.e what are the dam assets related the page . AssetRefernceSearch will provide the list of Assets associated with the page given as an argument.

public AssetReferenceSearch(Node node,
                            String searchPath,
                            ResourceResolver resolver)
The constructor.
Parameters:
node - node to start search for references
searchPath - search for assets starting with searchPath
resolver - resource resolver

Example : 
AssetReferenceSearch assetReference = new AssetReferenceSearch(<node of the page>, "/content/dam", resolver);
for (Map.Entry<String, Asset> assetMap : assetReference.search().entrySet()) {
Asset asset = assetMap.getValue();
assetsPathList.add(asset.getPath());
}
Note : Node of the page is "jcr:content" node of the page.



No comments:

Post a Comment