I help oversee (quality assurance) a website on AEM that has around 65,000 pages, 320,000 assets, and about 300 users able post and make changes. One thing that has been extremely helpful is a script a former IT employee wrote for us that used the querybuilder servlet to make queries and pull full lists of pages and assets. I've been able to take this output and build all sorts of automated reports using it.
The one thing I have not been able to figure out is how to find out if an asset or page is referenced by another page. The main thing I care about is just a simple true/false on if it is refereced or not. Ideally I would like it if it could be in the initial query and not have to do a query for each individual asset, but if that is the only way then I guess it in theory could be acceptable.
Just a sample query I could run currently to get some info on assets (I limited this one to 5 results for the sample):
http://localhost:4502/bin/querybuilder.json?p.hits=selective&p.offset=0&p.limit=5&p.properties=jcr%3acontent%2fmetadata%2fdc%3aformat%20jcr%3acontent%2fmetadata%2fdc%3atitle%20jcr%3apath%20&path=%2fcontent%2fdam&type=dam%3aAsset
Is there any way to add to that a field for if it is referenced? Or an array of all the references to it?
We are currently running AEM 6.2 but will soon be upgrading to 6.4.
Thank you!
There is an OOTB servlet that will return the list of pages that refer to a particular page or asset
To check if a page or asset is referenced, use
https://localhost:4502/bin/wcm/references?
_charset_=utf-8
&path=<path of the page>
&predicate=wcmcontent
&exact=false
The output will be a json response containing an array of references of the name 'pages'. If the page is not referenced it will be an empty array.
This servlet uses ReferenceSearch API the other answer mentions. If you need this value as JSON outside of AEM, you can straight away use the OOTB one without having to write your own servlet.