Hi @webera,
The problem is you're using an XPath-like query to find assets where any dam:failedRenditions/*/reason != RenditionFormatUnsupported. This can be expensive because:
-
dam:failedRenditions is a child node with nested properties, which makes this a deep tree traversal.
-
The repository has to check each dam:Asset node under /content/dam/customer, drill into jcr:content/dam:failedRenditions, and then evaluate child properties.
-
Lucene indexing may not be optimized for this kind of nested query.
I would follow one of the option as below:
1. Use a Custom Sling Job / Groovy Script in AEM
Write a one-time or periodic script using Groovy (via ACS AEM Commons) or Java to traverse the repository efficiently in batches.
Groovy Script (via ACS AEM Commons):
import com.day.cq.dam.api.Asset
import javax.jcr.Node
def rootPath = "/content/dam/customer"
def assetManager = getService(com.day.cq.dam.api.AssetManager)
def resourceResolver = getResourceResolver()
def results = []
resourceResolver.getResource(rootPath).listChildren().each { res ->
def asset = res.adaptTo(Asset)
if (asset) {
Node failedNode = asset.adaptTo(Node).getNode("jcr:content/dam:failedRenditions")
if (failedNode && failedNode.hasNodes()) {
def iterator = failedNode.getNodes()
while (iterator.hasNext()) {
def rendition = iterator.nextNode()
def reason = rendition.getProperty("reason").getString()
if (!reason.equals("RenditionFormatUnsupported")) {
results.add(asset.getPath())
}
}
}
}
}
return results
You can tweak this to only check recent assets or those modified after a certain date.
2. Use an AEM Workflow Step (eg. Post-Processing Audit)
Create a workflow step that logs failed renditions to a custom metadata property (dam:processingStatus = failed-custom) whenever a custom processor fails.
Then use a simple query on that metadata:
type=dam:Asset
path=/content/dam/customer
property=jcr:content/dam:processingStatus
property.value=failed-custom
3. Create a Custom Report Page in AEM
Use a Servlet or Coral UI-based tool to fetch/report assets failing rendition processing, querying in batches, paginating through the repository using QueryBuilder or JCR API.