如何以编程方式激活子页面?

时间:2013-08-23 09:59:05

标签: java cq5 jcr

每当作者激活父页面时(我的情况subPage),我想以编程方式激活myPage myPage。{}我使用EventHandler来检测ACTIVATE操作并尝试使用subPage激活replicator,如下所示:

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

编译器打印java.lang.NullPointerException:

23.08.2013 15:04:20.138 警告 [Thread-2276] org.apache.felix.eventadmin服务[myjavaClass,2921] EventAdmin:事件发送期间的异常[org.osgi.service。 event.Event [topic = com / day / cq / replication] | [org.osgi.service.event.EventHandler] | Bundle(myBundle [170])](java.lang.NullPointerException)

1 个答案:

答案 0 :(得分:0)

我已经解决了这个问题。问题是我将Replicator改编为错误的资源。