# Prevent Channel Manager users from deleting pages with nested sub-pages

**URL:** <https://community.bloomreach.com/t/prevent-channel-manager-users-from-deleting-pages-with-nested-sub-pages/1131>\
**Category:** Experience Manager (PaaS/OnPrem)\
**Created:** [May 29, 2019, 6:41pm UTC](https://community.bloomreach.com/t/prevent-channel-manager-users-from-deleting-pages-with-nested-sub-pages/1131 "2019-05-29T18:41:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patrick\_McInerney](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/patrick_mcinerney/32/282_2.png) [@Patrick\_McInerney](https://community.bloomreach.com/u/Patrick_McInerney)\
**Post date:** [May 29, 2019, 6:41pm UTC](https://community.bloomreach.com/t/prevent-channel-manager-users-from-deleting-pages-with-nested-sub-pages/1131/1 "2019-05-29T18:41:10Z")

</div>

Prevent Channel Manager users from deleting pages with nested sub-pages

The documentation for the Channel Manager has the following note on [this page](https://documentation.bloomreach.com/library/concepts/template-composer/page-management.html)

> Note that when deleting a page which has nested sub-pages in the sitemap, the sub-pages will also be deleted. For example, assume you have an editable page at URL [www.example.com/blogs](http://www.example.com/blogs) and a nested sub-page at URL [www.example.com/blogs/myblog](http://www.example.com/blogs/myblog). If you delete the former page, the latter page will be deleted, too.

I am trying to design a way to prevent this from happening, or at least provide a Channel Manager user with warning when their page delete action will also remove nested pages.

I have so far attempted to capture the ‘write-changes’ event emitted by the Channel Manager and respond to it. However, it seems like this event is triggered after the changes are already made, so there is no way to abort the delete action.

Some example code:

```
public class ChannelPageIndexer {

    @Subscribe
    public void handleEvent(HippoEvent event) {
        if (!(event.category().equals("channel-manager") && event.action().equals("write-changes")) || event.message().isEmpty()) {
            return;
        }

        String[] changedNodes = event.message().split(",");

        try {
            for (String changedNode : changedNodes) {
                Node node = this.getUserSession().getNode(changedNode);
                if (node.getPrimaryNodeType().getName().equals("hst:sitemapitem")) {
                    NodeIterator children = node.getNodes(); // the children are already deleted when the event is captured,
                    if (children.getSize() > 0) { // so this check is always false. 
                        //no way to abort action, either
                    }
                }
            }
        } catch (RepositoryException e) {
            //handle exception
        }
    }
}

```

Is there an alternative approach that might work better, or is this type of validation not possible within the current Channel Manager? If it makes any difference, I am currently working with Hippo CMS version 11.2.8
