Rename a Page with Java Plugin

PJ January 28, 2019

I created a web item for Confluence and it seemed like it was working perfectly fine on all pages. Except there is one page in which this web item action does not work. All this is doing is renaming all the child pages of the a page. I've used on on multiple pages and it works. However, with this one specific page is giving me the following error:

java.lang.NullPointerException
    at com.atlassian.confluence.core.DefaultContentEntityManager.saveNewVersion(DefaultContentEntityManager.java:202)

Seems to be breaking at renamePage() on the following code where childPagesTitles is just a list that contains existing page titles:

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);

 

I tried the following since I assumed that it wanted me to use saveNewVersion instead() but still did not work.

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 not working. Can anyone help me solve this? Not sure what the error actually means. 

0 answers

Suggest an answer

Log in or Sign up to answer