How to programatically delete revisions of a page in CQ5?

南楼画角 提交于 2019-12-12 04:06:22

问题


In the current setup; we are trying to automate the process of creating the blueprint page, rolling it out to its live copies; and activating the live copy pages.Also; deactivation and deletion of pages is also done programmatically . All this is done via code using the com.day.cq.wcm.api.msm and com.day.cq.replication api.

The problem we are facing right now is after deleting the blueprint and live copy pages programmatically ; if we again create the same page programmatically ; then; there comes an option of 'No Action' ; rather than 'Create' while rolling out the page; which means that the live copy has been detached. What we want to do is that while deleting the pages; we want to delete the history associated with the relationship ; so that next time the same page is created; it would get rolled out to the live copy branch.

We tried the cancelRelationship and endRelationship(mentioned in the docs that it deletes the history https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/com/day/cq/wcm/msm/api/LiveRelationshipManager.html#endRelationship ) but it does not delete the history.

This is because every time the page is activated; a version is created. How can we programmatically delete the revision/version of the page? There is an option to create revision https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/com/day/cq/wcm/api/PageManager.html#createRevision but no option to delete the created revisions.

Should we try to remove the version nodes which get created at /var/audit/com.day.cq.replication ?


回答1:


I think you want to be able to recreate a page that has previously been a live copy. Then just make sure that BEFORE you delete a page that is a live copy, then the live relationship is terminated (https://docs.adobe.com/docs/en/aem/6-0/develop/ref/javadoc/com/day/cq/wcm/msm/api/LiveRelationshipManager.html#endRelationship(org.apache.sling.api.resource.Resource, boolean)

This method DOES NOT delete any history. It just removes any live copy information on the page so that when you delete the page afterwards, the created revision of that page does not have any live copy information either.

In order to find out if a deleted page was a live copy, AEM/MSM looks for the last revision of that page to check if it had any live copy information by the time it was deleted.

To purge the version you should use: https://docs.adobe.com/docs/en/cq/5-6-1/deploying/version_purging.html



来源:https://stackoverflow.com/questions/30773706/how-to-programatically-delete-revisions-of-a-page-in-cq5

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!