Custom Workflow Action Plugin - Documentation topics on: actionlet,custom workflow,osgi,workflow,.

Custom Workflow Action Plugin

This bundle plugin is an example of how to add dotCMS WorkFlowActionlet classes with our bundle plugin.

How to add a Actionlet OSGI plugin

Let’s review the file organization on the Actionlet (com.dotcms.actionlet) example:

META-INF/MANIFEST.MF: The manifest file is very important for the deployment, it lists the Bundle Name, Version and Packages.

In this MANIFEST you must specify (see template plugin):

  • Bundle-Name: The name of your bundle
  • Bundle-SymbolicName: A short an unique name for the bundle
  • Bundle-Activator: Package and name of your Activator class (example: com.dotmarketing.osgi.actionlet.Activator)
  • DynamicImport-Package: *. Dynamically add required imports the plugin may need without adding them explicitly
  • Import-Package: This is a comma separated list of package's name. List the packages that you are using inside the bundle plugin and that are exported by dotCMS.

Beware (!)

In order to work inside the Apache Felix OSGI runtime, the import and export directive must be bidirectional.

dotCMS must declare the set of packages that will be available to the OSGI plugins by changing the file: dotCMS/WEB-INF/felix/osgi-extra.conf.

This is possible also using the dotCMS UI (System -> Dynamic Plugins -> Exported Packages).

Only after that exported packages are defined in this list, a plugin can Import the packages to use them inside the OSGI blundle.

Source

Under the src folder you will find all the Java classes needed to create a new actionlet:

$ pwd
/dotCMS/docs/examples/osgi/com.dotcms.actionlet
$ ls -l src/com/dotmarketing/osgi/actionlet/
-rw-r--r-- 1 Activator.java
-rw-r--r-- 1 MyActionlet.java

com.dotmarketing.osgi.actionlet.MyActionlet

Implementation of a WorkFlowActionlet object.

public class MyActionlet extends WorkFlowActionlet {

    private static final long serialVersionUID = 1L;

    @Override
    public List getParameters () {
        return null;
    }

    @Override
    public String getName () {
        return "My Osgi Actionlet";
    }

    @Override
    public String getHowTo () {
        return null;
    }

    @Override
    public void executeAction ( WorkflowProcessor processor, Map<String, WorkflowActionClassParameter> params ) throws WorkflowActionFailureException {
        System.out.println( "Launch actionlet" );
    }

}

Activator

This bundle activator extends from com.dotmarketing.osgi.GenericBundleActivator and implements BundleActivator.start().

This activator will allow you to register the WorkFlowActionlet object using the GenericBundleActivator.registerActionlet method

Testing

After installing the plugin the actionlet: My Osgi Actionlet will be available as an action in the Workflow Scheme Manager. When the action runs, the message: "Launch actionlet" will be displayed in the log file.

First install the plugin

Then create a new action using the subaction: My Osgi Actionlet.

After that, edit content and run the new action.

Tail the logs to see the message:

$ tail -f /dotCMS_home/dotsecure/tomcatX.x/logs/catalina.out
Launch actionlet