Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

Customizing rollouts

Avatar

Level 4

For a client, we would need to customize the standard rollout. 

 

Currently, when a blueprint is rolled out, all subpages are rolled out as well. 

 

Expected behavior is that when a blueprint "somePage" is rolled out, we can rollout subpage "someSubPage" only if it contains Tag "someTag".

 

Could we achieve this in AEM by adapting the rollout configs? How could we tackle this? And is there some documentation to do achieve this?

1 Accepted Solution

Avatar

Correct answer by
Level 4

I tried Adobe documentation at https://experienceleague.adobe.com/docs/experience-manager-65/developing/extending-aem/extending-msm... 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";

    @Override
    public String createsAction() {
        return LIVE_ACTION_NAME;
    }

    @Override
    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.

View solution in original post

5 Replies

Avatar

Community Advisor

Hello @jeremylanssiers 

 

Please refer to the following blog:

http://suryakand-shinde.blogspot.com/2015/01/custom-synchronisation-or-rollout.html

 

It contains step-by-step instructions on creating Rollout configs and creating custom LiveSync Actions.

It should help you achieve the requirement


Aanchal Sikka

Avatar

Level 4

The documenation's instructions for custom live actions do not work. I created a case at Adobe for this. 

Avatar

Correct answer by
Level 4

I tried Adobe documentation at https://experienceleague.adobe.com/docs/experience-manager-65/developing/extending-aem/extending-msm... 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";

    @Override
    public String createsAction() {
        return LIVE_ACTION_NAME;
    }

    @Override
    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.