Creating a custom workflow action class

You can create custom workflow action classes to enable you to use custom workflow actions in a workflow.

Creating the custom workflow action class

  1. Create a java class that implements the interface com.ibm.workplace.wcm.api.custom.CustomWorkflowAction . This class must implement the following methods:
    • public Date getExecuteDate(Document p_document) {} (This specifies when the custom action will be executed)
    • public CustomWorkflowActionResult execute(Document p_document) {} (This method contains the code that will run when the custom action is executed.)
  2. Implement execute()method . This method contains the code that will be executed against the supplied Document. This method must return a com.ibm.workplace.wcm.api.custom.CustomWorkflowActionResult object to indicate the result of the custom code through the use of com.ibm.workplace.wcm.api.custom.Directives.
    • A custom workflow action result object is created by first retrieving a reference to the WebContentCustomWorkflowService object, and then calling the method webContentCustomWorkflowService.getCustomWorkflowService().createResult. If the CustomWorkflowActionResult does not indicate a failure, changes to the document will be saved. See the Web Content Manager Javadoc for further information. The Javadoc HTML files are located under the was_profile_root\installedApps\nodename\wcm.ear\ilwwcm.war\webinterface\ folder.
    • Also see the Web Content Manager Javadoc for further information on valid directives.
  3. Create a custom workflow action factory class that implements the interface com.ibm.workplace.wcm.api.custom.CustomWorkflowActionFactory.

Create a plugin.xml file

A plugin.xml file is needed whether the deployment is done using a WAR or EAR, or using a loose jar. If deploying via an application in a WAR or EAR, include the plugin.xml file in the application's "WEB-INF" folder. When using a jar, include the plugin.xml in the root of the jar.
<?xml version="1.0" encoding="UTF-8"?>
<plugin id="com.ibm.workplace.wcm.sample.customworkflowaction"
name="Sample Custom Workflow Action Factory"
version="1.0.0"
provider-name="IBM">

<extension
point="com.ibm.workplace.wcm.api.CustomWorkflowActionFactory"
id="SimpleCustomWorkflowActionFactory">
<provider class="com.ibm.workplace.wcm.sample.customworkflowaction.SimpleCustomWorkflowActionFactory"/>
</extension>

</plugin>
  • The ID of each plugin must be unique. You must replace the plugin ID specified in this example, com.ibm.workplace.wcm.sample.customworkflowaction, with a different ID for each custom workflow you create.
  • Each custom workflow action factory is represented by a single <extension></extension> tag.
  • The value of the point attribute must be "com.ibm.workplace.wcm.api.CustomWorkflowActionFactory".
  • Provide an id value of your choice.
  • Specify the provider class for your custom workflow action factory.
Naming conventions:
If you create a new plugin application with the same names and IDs as an existing plugin, the new plugin may override the first. When creating plugin applications ensure that the following are unique across your system:
  • The plugin ID, plugin name and extension ID of the plugin.xml file.
  • The fully qualified class name plus path of all classes within the application.
  • The file path of any files within the application.