Creating a New Synchronization Action

Create custom synchronization actions to use with your rollout configurations. Create a synchronization action when the installed actions do not meet your specific application requirements. To do so, create two classes:

The LiveActionFactory creates instances of the LiveAction class for a given configuration:

  • LiveAction classes include the following methods:

    • getName: Returns the name of the action The name is used to refer to the action, for example in rollout configurations.
      • execute: Performs the tasks of the action.
  • LiveActionFactory classes include the following members:

    • LIVE_ACTION_NAME: A field that contains the name of the associated LiveAction. This name must coincide with the value that is returned by the getName method of the LiveAction class.
    • createAction: Creates an instance of the LiveAction. The optional Resource parameter can be used to provide configuration information.
    • createsAction: Returns the name of the associated LiveAction.

Accessing the LiveAction Configuration Node

Use the LiveAction configuration node in the repository to store information that affects the runtime behaviour of the LiveAction instance. The node in the repository that stores the LiveAction configuration is available to the LiveActionFactory object at runtime. Therefore, you can add properties to the configuration node to and use them in your LiveActionFactory implementation as needed.

For example, a LiveAction needs to store the name of the blueprint author. A property of the configuration node includes the property name of the blueprint page that stores the information. At runtime, the LiveAction retrieves the property name from the configuration, then obtains the property value.

The parameter of the LiveActionFactory.createAction method is a Resource object. This Resource object represents the cq:LiveSyncAction node for this live action in the rollout configuration; see Creating a Rollout Configuration. As usual when using a configuration node, you should adapt it to a ValueMap object:

public LiveAction createAction(Resource resource) throws WCMException {
        ValueMap config;
        if (resource == null || resource.adaptTo(ValueMap.class) == null) {
            config = new ValueMapDecorator(Collections.<String, Object>emptyMap());
        } else {
            config = resource.adaptTo(ValueMap.class);
        }
        return new MyLiveAction(config, this);
}