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

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

  • October 8, 2022
  • 1 risposta
  • 519 visualizzazioni

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

Questo argomento è stato chiuso alle risposte.
Migliore risposta di 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 risposta

B_Sravan
Community Advisor
B_SravanCommunity AdvisorRisposta
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.