Question

I would like to activate subPage of myPage programmatically every time the author activates the parent page (in my case myPage). I use EventHandler to detect an ACTIVATE action and try to activate the subPage with a replicator as follows:

@Property(name = "event.topics", value = { ReplicationAction.EVENT_TOPIC })
public class mySubPageActivator extends AbstractRepositoryService implements EventHandler {
  public void handleEvent(final Event event) {
  ReplicationAction action = ReplicationAction.fromEvent(event);
    if (action.getType().equals(ReplicationActionType.ACTIVATE)) {
       Replicator repl = getResourceResolver().adaptTo(Replicator.class);
       repl.replicate(getAdminSession(), ReplicationActionType.ACTIVATE, subPagePath);
     }
  }
}

the compiler prints java.lang.NullPointerException:

23.08.2013 15:04:20.138 WARN [Thread-2276] org.apache.felix.eventadmin Service [myjavaClass,2921] EventAdmin: Exception during event dispatch [org.osgi.service.event.Event [topic=com/day/cq/replication] | [org.osgi.service.event.EventHandler] | Bundle(myBundle[170])] (java.lang.NullPointerException)

Was it helpful?

Solution

I have resolved the Issue. The problem was that I adapted the Replicator to the wrong resource.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top