Is there a recommended approach to implementing validation in CQ5 (we are using 5.5) that will run when a Page is activated? I have been reading up on different approaches for this, but have not been able to find a clear solution.
The requirement that I have is for a News article to only be published if all of it's mandatory fields have been supplied - for example Heading, Image, Body Text, Author. Simply implementing validation on the edit dialog doesn't really solve the issue, as each component is editable separately, so it is easy for a content author to miss entering the Author for example.
What I'm trying to accomplish is to run some custom validation code when the page is replicated, and cancel the replication if the validation does not pass. Ideally this would show a "Validation Failed" or similar notification in the CQ user interface, the same way that the "Activation Successful" notification is shown.
The approaches that I have investigated so far are:
Replication Action Event Handler
- This triggers at the right time and provides sufficient information (path to page), but doesn't provide a mechanism to stop the replication.
- Potentially this could be combined with further service calls to stop replication?
Workflow Action Event Handler
- This doesn't seem to fire when activating a page
Custom Replication Agent
- This would provide a hook for validation, but seems like massive overkill - is there no way to simply hook into the existing replication process and cancel it if the page is not valid?
Any advice on how to best accomplish this would be much appreciated.
I tried that out and it works great!