Trying to move a Page from one place to another through backend(java) | Community
Skip to main content
Adobe Employee
October 8, 2022
Solved

Trying to move a Page from one place to another through backend(java)

  • October 8, 2022
  • 1 reply
  • 519 views

Hi,

I am trying to change the path of my "demomovement" page to archive-articles. But somewhere its crashing. Can anyone please help me out here?

 

 

@9944223 public void run() {

String rs="/content/enablementCapstone/us-capstone/en/article/demomovement";
Page page = resourceResolver.getResource(rs).adaptTo(Page.class);
PageManager pm = resourceResolver.adaptTo(PageManager.class);
String TargetPage="/content/enablementCapstone/us-capstone/en/archive-articles";
try{
pm.move(page, TargetPage, null, false, true, null);
}
catch(Exception e){
LOG.info("ErrorInMovement");
}
LOG.info("\n ====> RUN METHOD !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!S");
}
 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by B_Sravan

what is the error on logs?

Try having the shallow field as true to move the page content, as in "pm.move(page, TargetPage, null, true, true, null);" and also, make sure you have the write permissions.

are you running this on scheduler? check your cron expression timing etc.., to perform the action immediately.

 

Also, instead of passing null for references, you can have the references of the resource, check this – here is the way to find our resources' references acs-aem-commons/PagesReferenceProvider.java at master · Adobe-Consulting-Services/acs-aem-commons · ... 

 

Thank you.


1 reply

B_Sravan
Community Advisor
B_SravanCommunity AdvisorAccepted solution
Community Advisor
October 8, 2022

what is the error on logs?

Try having the shallow field as true to move the page content, as in "pm.move(page, TargetPage, null, true, true, null);" and also, make sure you have the write permissions.

are you running this on scheduler? check your cron expression timing etc.., to perform the action immediately.

 

Also, instead of passing null for references, you can have the references of the resource, check this – here is the way to find our resources' references acs-aem-commons/PagesReferenceProvider.java at master · Adobe-Consulting-Services/acs-aem-commons · ... 

 

Thank you.