I tried Adobe documentation at https://experienceleague.adobe.com/docs/experience-manager-65/developing/extending-aem/extending-msm.html?lang=en but the instructions doe not work for me. I created a case (E-001003099) at Adobe to follow up on their proposed implementation.
However, I was able to combine some online resources to have a working version of a custom rollout config and a custom live action.
Inside your core bundle, create a Java Class CustomActionFactory
package com.mypackage.aem.core.msm;
import com.day.cq.wcm.api.WCMException;
import com.day.cq.wcm.msm.api.LiveAction;
import com.day.cq.wcm.msm.api.LiveActionFactory;
import com.day.cq.wcm.msm.api.LiveRelationship;
import com.day.cq.wcm.msm.commons.BaseAction;
import com.day.cq.wcm.msm.commons.BaseActionFactory;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ValueMap;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.jcr.RepositoryException;
@Component(
service = LiveActionFactory.class,
property = {LiveActionFactory.LIVE_ACTION_NAME + "=" + CustomActionFactory.LIVE_ACTION_NAME})
public class CustomActionFactory extends BaseActionFactory<BaseAction> {
private static final Logger LOG = LoggerFactory.getLogger(CustomActionFactory.class);
public static final String LIVE_ACTION_NAME = "CustomAction";
@9944223
public String createsAction() {
return LIVE_ACTION_NAME;
}
@9944223
protected CustomAction newActionInstance(ValueMap config) throws WCMException {
return new CustomAction(config, this);
}
private static final class CustomAction extends BaseAction {
private static final Logger LOG = LoggerFactory.getLogger(CustomAction.class);
public CustomAction(ValueMap config, BaseActionFactory<? extends LiveAction> liveActionFactory) {
super(config, liveActionFactory);
}
protected boolean handles(Resource source, Resource target, LiveRelationship relation, boolean resetRollout)
throws RepositoryException, WCMException {
return (relation.getStatus().isPage() && source != null && target != null);
}
protected void doExecute(Resource source, Resource target, LiveRelationship relation, boolean resetRollout)
throws RepositoryException, WCMException {
LOG.debug("Custom Action.");
}
}
}
Inside your ui.apps module, create a package apps/msm/myproject/rolloutconfigs and create a file .content.xml
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:mixinTypes="[rep:AccessControllable]"
jcr:primaryType="sling:OrderedFolder"
jcr:title="Rollout Configurations">
<customRolloutconfig/>
</jcr:root>
Next create a package apps/msm/myproject/rolloutconfigs/customRolloutConfig and create a file .content.xml
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:title="Custom Rollout Config"
jcr:description="Custom Rollout Config Description"
jcr:primaryType="cq:RolloutConfig"
cq:trigger="rollout">
<CustomAction jcr:primaryType="cq:LiveSyncAction"/>
</jcr:root>
This will create a Custom Rollout Config, available in Granite UI when creating Live Copies. And the config should trigger the CustomAction.