Custom Live Action does not execute on Rollout page and all sub pages
Hi,
I've developed a custom live action that executes on Rollout Page but not on Rollout page and all sub pages .
In the code below, VersionNodesLiveAction.execute does not fire on Rollout page and all sub pages, but it does on Rollout Page.
Is there something I'm missing?
package com.test;
import com.day.cq.wcm.api.WCMException;
import com.day.cq.wcm.msm.api.ActionConfig;
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.sonova.support.core.service.component.VersionNodesByPath;
import com.sonova.support.core.utils.SonovaUtils;
import org.apache.felix.scr.annotations.*;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.api.wrappers.ValueMapDecorator;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.io.JSONWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import java.util.Collections;
import java.util.Map;
/**
* Creates actions for each node being rolled out.
*
*/
@Component(metatype = false)
@Service
public class VersionNodesLiveActionFactory implements LiveActionFactory<LiveAction> {
@Property(value = "versionNodesLiveAction")
static final String actionname = LiveActionFactory.LIVE_ACTION_NAME;
private static final Logger log = LoggerFactory.getLogger(VersionNodesLiveActionFactory.class);
public LiveAction createAction(Resource config) {
ValueMap configs;
/* Adapt the config resource to a ValueMap */
if (config == null || config.adaptTo(ValueMap.class) == null) {
configs = new ValueMapDecorator(Collections.<String, Object>emptyMap());
} else {
log.debug(config.getName());
log.debug(config.getPath());
configs = config.adaptTo(ValueMap.class);
}
return new VersionNodesLiveAction(actionname, configs);
}
public String createsAction() {
return actionname;
}
@Activate
public void activate(final Map<String, Object> config) throws RepositoryException {
log.debug("VersionNodesLiveActionFactory: activate");
}
@Deactivate
public void deactivate(final Map<String, String> config) throws RepositoryException {
log.debug("VersionNodesLiveActionFactory: deactivate");
}
/************* LiveAction ****************/
public static class VersionNodesLiveAction implements LiveAction {
private static final Logger log = LoggerFactory.getLogger(VersionNodesLiveAction.class);
private String name;
private ValueMap configs;
public VersionNodesLiveAction(String nm, ValueMap config) {
name = nm;
configs = config;
}
public void execute(Resource source, Resource target,
LiveRelationship liverel, boolean autoSave, boolean isResetRollout)
throws WCMException {
log.debug("VersionNodesLiveAction: execute");
if (source == null)
log.debug(source.getName());
if (source == null || !source.getName().endsWith("jcr:content")) {
return;
}
if (source.adaptTo(Node.class) != null) {
log.debug(source.getPath());
VersionNodesByPath vnbp = SonovaUtils.getService(VersionNodesByPath.class);
vnbp.autoVersion(source.getPath());
}
}
public String getName() {
return name;
}
/************* Deprecated *************/
@Deprecated
public void execute(ResourceResolver arg0, LiveRelationship arg1,
ActionConfig arg2, boolean arg3) throws WCMException {
log.debug("VersionNodesLiveAction: execute1");
}
@Deprecated
public void execute(ResourceResolver arg0, LiveRelationship arg1,
ActionConfig arg2, boolean arg3, boolean arg4)
throws WCMException {
log.debug("VersionNodesLiveAction: execute2");
}
@Deprecated
public String getParameterName() {
return null;
}
@Deprecated
public String[] getPropertiesNames() {
return null;
}
@Deprecated
public int getRank() {
return 0;
}
@Deprecated
public String getTitle() {
return null;
}
@Deprecated
public void write(JSONWriter arg0) throws JSONException {
}
public void process(final String eventPath, final String type) {
log.debug("VersionNodesLiveAction: process");
}
}
}