Expand my Community achievements bar.

SOLVED

Problem using msm RolloutManager API

Avatar

Level 2

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

1 Accepted Solution

Avatar

Correct answer by
Level 2

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

}

View solution in original post

1 Reply

Avatar

Correct answer by
Level 2

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

}