Snippets

Adaptavist convert pages from old editor format to the new(Fabric) editor format from a given list of spaces

Created by Kristian Walker
/*
    This script converts pages from old editor format to the new editor format from a given list of spaces
    
    The script perfomance is dependent the (No. of spaceskeys provided, pages in one space) 
    The script correctness is dependent on the atlassian api(/wiki/rest/api/content/{id}/convert?hash=6749) that is not yet up for support
*/

String[] spaceKey=["<spacekey1>","<spacekey2>","..","<spacekeyN>"] // add the space keys to this list. The script will pick all the pages from this spaceKey list and convert them new editor                                                        
for(int i=0;i < spaceKey.size();i++){
   println("SpaceKey=${spaceKey[i]}")

Object[] pages= get("/wiki/rest/api/space/${spaceKey[i]}/content?childTypes.page")
.asObject(Map).body.page.results


for(int j=0;j<pages.size();j++){

    def status = put("/wiki/rest/api/content/${pages[j].id}/convert?hash=6749")
   .asObject(Map).status
      println("#Status-"+status)
      if(status>300)
      logger.error("Error while converting page contents from the page *title:'${pages[j].title}'* in the *spaceKey:'${spaceKey[i]}'*")
      else
      logger.info("Successfully converted contents from the page *title:'${pages[j].title}'* in the *spaceKey:'${spaceKey[i]}'*")

    }
}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.