I created a web item for Confluence that renames child pages. Seems to work fine, but for some reason is not working on a certain parent page. I'm trying to figure out what's wrong but not sure what exactly the error means.
for (int x=0; x < childPagesTitles.size(); x++) {
Page moduleChildPage = pageManager.getPage(currentSpaceKey, childPagesTitles.get(x));
pageManager.renamePage((AbstractPage) moduleChildPage, "a" + x);
childPagesTitles.set(x, "a" + x);
}
childPagesTitles is just a list of page titles that exist in Confluence. I'm getting the following error when the code gets to renamePage():
java.lang.NullPointerException at com.atlassian.confluence.core.DefaultContentEntityManager.saveNewVersion(DefaultContentEntityManager.java:202)
I was not using saveNewVersion at all so I replaced renamePage() with:
for (int x=0; x < childPagesTitles.size(); x++) {
Page moduleChildPage = pageManager.getPage(currentSpaceKey, childPagesTitles.get(x));
final String num = Integer.toString(x);
pageManager.saveNewVersion(moduleChildPage, new Modification<Page>() {
public void modify(Page moduleChildPage) {
moduleChildPage.setTitle("a" + num);
}
});
childPagesTitles.set(x, "a" + x);
}
Still doesn't work. Can anyone help with this? Not really sure what the problem is. The code seems to work on all other pages. Even if I copy this exact same parent page with the child pages, the code works. It's just not working on this certain page and giving me saveNewVersion error. I'm assuming it has to do with the version, but not really sure how to solve it, as I assumed that if I used saveNewVersion() it would work.