Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

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

Avatar

Level 2

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

1 Accepted Solution

Avatar

Correct answer by
Level 5

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

View solution in original post

3 Replies

Avatar

Level 5

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

Avatar

Level 2

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

Avatar

Correct answer by
Level 5

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