Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

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

EricKennedyEdel
Level 2
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
zeeshanKhan0786
Correct answer by
Level 5
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
zeeshanKhan0786
Level 5
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();

EricKennedyEdel
Level 2
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

zeeshanKhan0786
Correct answer by
Level 5
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);