AEM 6.2 Not all properties getting copied when copying a page via code | Community
Skip to main content
Level 2
July 18, 2017
Solved

AEM 6.2 Not all properties getting copied when copying a page via code

  • July 18, 2017
  • 3 replies
  • 1521 views

Hi All

On AEM 6.2 when I copy a page via the Page manager not all the properties on the are getting copied,

System user has full access to everything on my author instance, My user mapping is as below:

user mapping service

com.test.pw.test-pw-services:getResourceResolver=system-user

do I need more user mapping to copy across all properties?

//working but not all props are getting copied

Page sourcePage = resourceResolver.resolve(source).adaptTo(Page.class);

if(sourcePage != null){

   pageManager.copy(sourcePage, newPath, null, true, true, true);

//I've even tried manually overwriting these settings but it still gets set as blank

Page newPage = resourceResolver.resolve(newPath).adaptTo(Page.class);

if(newPage.hasContent()){

     Node newpageJCRNode = newPage.resourceResolver.adaptTo(Node.class);

    newpageJCRNode.setProperty("pageTitle", title);

Thanks

Eric

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 zeeshanKhan0786

For Service Mapping

<bundleId>:<subServiceName> = <systemUserName>

com.test.pw.test-pw-services:getResourceResolver=system-user

As i am seeing your subServiceName is getResourceResolver that seems like a method name, could you please give specific name of the service that will be the best practice and can use for various purpose like readService or writeService

Could you try of getting session in this way and check it works or not .

session = repository.loginService("subServiceName ", null);

3 replies

zeeshanKhan0786
Level 5
July 18, 2017

Hi Eric,

For the copy of the page please check source and destination path.Check with different path.

In second scenerio did you save the session like this Session.save();

Level 2
July 18, 2017

Hi

Yes, the page copy itself is working as the paths for both source and destination is correct.

it's wrapped in a try and catch with session.save() applied at the base of the try.

     session.save();

     session.refresh(true);

the issue im facing is not all the props are getting copied across

zeeshanKhan0786
zeeshanKhan0786Accepted solution
Level 5
July 18, 2017

For Service Mapping

<bundleId>:<subServiceName> = <systemUserName>

com.test.pw.test-pw-services:getResourceResolver=system-user

As i am seeing your subServiceName is getResourceResolver that seems like a method name, could you please give specific name of the service that will be the best practice and can use for various purpose like readService or writeService

Could you try of getting session in this way and check it works or not .

session = repository.loginService("subServiceName ", null);