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
BedrockMission!

Learn More

View all

Sign in to view all badges

PageManager move() Issue

Avatar

Avatar
Validate 1
Level 1
avinasht6348431
Level 1

Like

1 like

Total Posts

16 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
avinasht6348431
Level 1

Like

1 like

Total Posts

16 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
avinasht6348431
Level 1

05-02-2019

Hi All,

when i try to move pages from one location to another , page gets moved and finally page name changes to 1,2,3....

I need to maintain the same names for the pages.How it can be done?

Using pagemanager api for this.

pmgr.move(page, dest,null, false, true, null, null);

Also need to understand use of "beforeName" and "publishrefs[]" in this move().

kindly help with the info.

-Avinash

Replies

Avatar

Avatar
Give back 300
MVP
Gaurav-Behl
MVP

Likes

243 likes

Total Posts

1,145 posts

Correct Reply

281 solutions
Top badges earned
Give back 300
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Give back 300
MVP
Gaurav-Behl
MVP

Likes

243 likes

Total Posts

1,145 posts

Correct Reply

281 solutions
Top badges earned
Give back 300
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile
Gaurav-Behl
MVP

06-02-2019

You may use this tool or refer its source code for your requirements -

Renovator

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

06-02-2019

I am looking into this. I will post back my results.

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

06-02-2019

I am going to modify this artilce to move the page - but rest of article is very much applicable to working with the AEM Page Manager Java API:

Adobe Experience Manager Help | Creating an Experience Manager 6.3 Page using the Page Manager API

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

06-02-2019

I was able to move a page and it returned the page title as per expectations.

MovePage.png

The code is similar to the above code - but page service has this Move code:

package com.aem.community.core;

import org.apache.sling.settings.SlingSettingsService;

import org.osgi.service.component.annotations.Activate;

import org.osgi.service.component.annotations.Component;

import org.osgi.service.component.annotations.ConfigurationPolicy;

import org.osgi.service.component.annotations.Reference;

import org.osgi.service.metatype.annotations.Designate;

import java.util.HashMap;

import java.util.Map;

 

import javax.jcr.Node;

import javax.jcr.Session;

 

import org.apache.jackrabbit.commons.JcrUtils;

import org.apache.sling.api.resource.LoginException;

import org.apache.sling.api.resource.ResourceResolver;

import org.apache.sling.api.resource.ResourceResolverFactory;

 

import com.adobe.cq.sightly.WCMUsePojo;

import com.day.cq.commons.jcr.JcrConstants;

import com.day.cq.wcm.api.Page;

import com.day.cq.wcm.api.PageManager;

import org.apache.sling.api.resource.Resource;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

@Component

public class PageServiceImp implements PageService {

    

private final Logger logger = LoggerFactory.getLogger(getClass());

private String user = "";

    

    private Session session;

    

    //Inject a Sling ResourceResolverFactory

    @Reference

    private ResourceResolverFactory resolverFactory;

    

    

    public String MovePage()

    {

    String pagePath = "/content/MovePage64/fr";

    String newPagePath ="/content/MovePage64/en" ;

    String templatePath = "/apps/AEMPage/templates/page-home";

    String pageTitle = "AEM home page";

    Page newPage;

    PageManager pageManager;

    

    

    ResourceResolver resolver = null;

   

   

     String newPageName = "";  

    try {

                 

       

        //Invoke the adaptTo method to create a Session

        resolver = resolverFactory.getAdministrativeResourceResolver(null);

       

       

        Resource res = resolver.getResource(pagePath);   

       

        //Adapts the resource to another type - in this example to a     com.day.cq.wcm.api.page

         Page page = res.adaptTo(Page.class);

    

        

       // session = resolver.adaptTo(Session.class);

                

        //create a page manager instance

        pageManager = resolver.adaptTo(PageManager.class);

        

        //Move a given page and return the new page- 

        /*

         *

Page move(Page page,

   String destination,

   String beforeName,

  boolean shallow,

  boolean resolveConflict,

   String[] adjustRefs)

  throws WCMException

         */

      

//move the page using the API

newPage = pageManager.move(page,newPagePath,null,true,true,null);

       

        if (newPage != null) {

        newPageName= newPage.getPageTitle();

        logger.info("*** PAGE NAME IS "+newPageName);

            }

        else

        {

        logger.info("*** PAGE CANNOT BE MOVED -- ERROR");

        }

        

        return newPageName;

    } catch (Exception e) {

        // TODO Auto-generated catch block

        logger.info("&&&&& BIG ERROR" +e.getMessage());

    }

    

    return ""  ;

}

}

You can look at the parameters of the MOVE method in the Javadocs -- "The Adobe AEM Quickstart and Web Application."  (LOOK AT PAGE MANAGER)

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

06-02-2019

We will capture this AEM API code in new article so it is easy to find

Avatar

Avatar
Validate 25
MVP
bsloki
MVP

Likes

182 likes

Total Posts

1,859 posts

Correct Reply

545 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile

Avatar
Validate 25
MVP
bsloki
MVP

Likes

182 likes

Total Posts

1,859 posts

Correct Reply

545 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile
bsloki
MVP

06-02-2019

Hi Avinash,

move method in pagemanager API should work without any issues.

Are you moving the same page to the same location multiple times? If so, it would create a node with 0,1,2.. etc.

Avatar

Avatar
Give Back
Level 2
knitshweta
Level 2

Likes

9 likes

Total Posts

7 posts

Correct Reply

2 solutions
Top badges earned
Give Back
Boost 5
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Give Back
Level 2
knitshweta
Level 2

Likes

9 likes

Total Posts

7 posts

Correct Reply

2 solutions
Top badges earned
Give Back
Boost 5
Boost 3
Boost 1
Applaud 5
View profile
knitshweta
Level 2

05-08-2020

Properties as cq:lastReplicated, cq:lastReplicatedBy, cq:lastReplicationAction are not being copied while moving pages. Did someone encounter that?