Create a custom workflow action class
Overview
We can create custom workflow action classes to enable us to use custom workflow actions in a workflow.
For an example, see Writing a simple custom workflow action
Create the custom workflow action class
- Create a java class that implements the interface com.ibm.workplace.wcm.api.custom.CustomWorkflowAction
This class implement the following methods:
- public Date getExecuteDate(Document p_document) {}
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.
- 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 Javadoc documentation for further information. The Javadoc files for Web Content Manager are located in...
PORTAL_HOME/doc/Javadoc/spi_docs/com/ibm/workplace/wcm
- Also see the WCM Javadoc for further information on valid directives.
- 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 name="Sample Custom Workflow Action Factory" version="1.0.0" provider-name="IBM"> <extension point="com.ibm.workplace.wcm.api.CustomWorkflowActionFactory" > <provider class="com.ibm.workplace.wcm.sample.customworkflowaction.SimpleCustomWorkflowActionFactory"/> </extension> </plugin>
- The ID of each plugin must be unique. Replace the plugin ID specified in this example, com.ibm.workplace.wcm.sample.customworkflowaction, with a different ID for each custom workflow we 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 the choice.
- Specify the provider class for the custom workflow action factory.
Naming conventions:
If we 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 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.
Parent Create custom plug-ins