I want to copy a page to a target path as follows:
Page page = "pagePath";
PageManager pageManager = getResourceResolver().adaptTo(PageManager.class);
pageManager.copy(pagePath, pagePath + "/target/newPage", null, true, false);
This works fine, if the page "target" exists (i.e. the would-be parent of the new copy). If this page doesn't exist however, PageManager will throw an Exception.
How can I tell the PageManager that it should create target if it doesn't exist already? (I.e. similar to the -p
flag on the unix mkdir
programme.)