We're on CQ v5.4 and have some old node corruption (the cause of which was fixed by CRX hotfix 126.96.36.199). The corruption was generally cleaned up by running the repository consistency check and fix. But some corrupt nodes were simply removed by this process. One such example is that under our /content/dam tree, a few renditions are missing their jcr:content nodes. The renditions aren't actually being used, so it isn't a huge problem. But when we try to create a package that includes these nodes and install the package on another CQ instance, it fails with an error that the mandatory child node is missing.
I wanted to create a JSP that would walk the entire JCR and validate each Node with its node type definition and report on how many of these cases exist (and what their paths are).
However, I'm running into an interesting problem. I wanted to use the org.apache.jackrabbit.core.ItemValidator, but it seems like it isn't actually available to the JSP. I guess I'm a little unclear as to how much Jackrabbit actually still exists under CQ - I had thought all of it, but perhaps I'm wrong.
So does anyone have a good suggestion for checking a Node for validity? I thought another approach might be to actually try copying the Node to a temporary location. If the structure doesn't match the node type definition then the copy should fail with a ConstraintViolationException... but it also seems like this approach will take a long time to execute.
The Jackrabbit classes are not exposed to CQ, but only the JCR API.
What you could do is to run a "touch" like script on each page/asset, which just updates the "last modified" date and saves that asset then. In case that save failes, you have such an invalid node.