How to activate subpage programmatically?

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)

Answers


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


Need Your Help

Keeping text size the same on zooming

html css

I want to make a line on the top of the page that can't be zoomed. Neither the line, nor the text contained in it. The main problem is the text. Whenever I zoom in my browser, the line stays the same

Android SDK Manager MacOS Could Not Select Items For Install

java android eclipse osx

I install the Android SDK into my Mac for development. I open the Android SDK Manager and want to install several items from the list shown in the program. When the list of SDK shown and I want to

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.