Problem using msm RolloutManager API | Community
Skip to main content
Level 2
Oct 11, 2018 11:45 AM UTC
Solved

Problem using msm RolloutManager API

First of all some background info, I'm currently using AEM 6.1, and the classic UI.

I'm running into an issue when using the msm API. My code gets a rollout config, establishes a LiveRelationship on two pages (with deep = true), then calls RolloutManager#rollout. After doing this, I can see the cq:LiveSyncConfig node set up on the parent of the copy, with deep = true in the properties, like I would expect.

The issue is, that when done in this way, the configured RolloutConfig only executes on the parent page (despite deep being set to true). Alternatively, when I create a new live copy via the UI (new -> Live Copy via the SiteAdmin), I see the same resulting nodes in the JCR (cq:LiveSyncConfig exists only on the parent, with deep = true), but the Rollout itself also executes on the Child Pages.

Code:

RolloutConfigManager rolloutConfigManager = getResourceResolver().adaptTo(RolloutConfigManager.class);

RolloutConfig rolloutConfig = rolloutConfigManager.getRolloutConfig("<my-rollout-config>");

//Establish the live relationship with deep = true, autoSave = false

LiveRelationship relationship = liveRelationshipManager.establishRelationship(sourceParent, destParent, true, false, rolloutConfig);

//Rollout with reset = true, autoSave = false

rolloutManager.rollout(getResourceResolver(), relationship, true, false);

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
patricka5339143Accepted solution
Level 2
Oct 11, 2018 4:17 PM UTC

Figured it out. My solution looks like this:

protected void recursiveRollout(RolloutConfig rolloutConfig, Page source, Page dest, boolean first) throws WCMException {

  LiveRelationship relationship;

  if (first) {

   //Establish the live relationship with deep = true, autoSave = false
   relationship = liveRelationshipManager.establishRelationship(source, dest, true, false, rolloutConfig);
   } else {

   //Get the established relationship of the parent
   relationship = liveRelationshipManager.getLiveRelationship(dest.getContentResource(), false);
   }

   //Rollout with reset = true, autoSave = false
   rolloutManager.rollout(getResourceResolver(), relationship, true, false);

   //Recurse
   Iterator<Page> sourceChildren = source.listChildren();
  while (sourceChildren.hasNext()) {

  Page sourceChild = sourceChildren.next();
   Page destChild = dest.getPageManager().getPage(dest.getPath() + "/" + sourceChild.getName());
   recursiveRollout(rolloutConfig, sourceChild, destChild, false);
   }

}

1 reply

patricka5339143AuthorAccepted solution
Level 2
Oct 11, 2018 4:17 PM UTC

Figured it out. My solution looks like this:

protected void recursiveRollout(RolloutConfig rolloutConfig, Page source, Page dest, boolean first) throws WCMException {

  LiveRelationship relationship;

  if (first) {

   //Establish the live relationship with deep = true, autoSave = false
   relationship = liveRelationshipManager.establishRelationship(source, dest, true, false, rolloutConfig);
   } else {

   //Get the established relationship of the parent
   relationship = liveRelationshipManager.getLiveRelationship(dest.getContentResource(), false);
   }

   //Rollout with reset = true, autoSave = false
   rolloutManager.rollout(getResourceResolver(), relationship, true, false);

   //Recurse
   Iterator<Page> sourceChildren = source.listChildren();
  while (sourceChildren.hasNext()) {

  Page sourceChild = sourceChildren.next();
   Page destChild = dest.getPageManager().getPage(dest.getPath() + "/" + sourceChild.getName());
   recursiveRollout(rolloutConfig, sourceChild, destChild, false);
   }

}

Translate