Custom Workflow Action Plugin

Last Updated: Aug 21, 2019
documentation for the dotCMS Content Management System

This bundle plugin is an example of how to add dotCMSWorkFlowActionlet 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 insidethe bundle plugin and that are exported by dotCMS.

Beware (!)

In order to work inside the Apache Felix OSGI runtime, the importand 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";
    }bc0805da-a889-46b0-bbdc-3487eb581832

    @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

On this page

×

We Dig Feedback

Selected excerpt:

×