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
- 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.)
- 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 calling the method webContentCustomWorkflowService.getCustomWorkflowService().createResult(Directive,
String). If the CustomWorkflowActionResult does
not indicate a failure changes to the document will be saved. See the Web Content Management Javadoc for further information.
The Javadoc HTML files are located under the folder on your Web Content Management server.
- Also see the Web Content Management 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.
- Register the new custom workflow action factory by calling the following
lines of code:
public void init(ServletConfig p_config) throws ServletException
{
super.init(p_config);
m_factory = new SimpleCustomWorkflowActionFactory();
try
{
// Construct and inital Context
InitialContext ctx = new InitialContext();
// Retrieve WebContentCustomWorkflowService
WebContentCustomWorkflowService webContentCustomWorkflowService = (WebContentCustomWorkflowService) ctx.lookup("portal:service/wcm/WebContentCustomWorkflowService");
webContentCustomWorkflowService.registerFactory(m_factory);
}
catch (NamingException ne)
{
ne.printStackTrace();
}
}
After this code has executed, the custom workflow action will
be available to select when creating a custom workflow action.
Note: Multiple
custom workflow action factories can be created but must be registered separately
by calling the code above.
Deploying the ear file in the Administrative Console
To
ensure the new workflow action class is available each time your server is
started you can register the ear file in the Administrative Console:
- Select Applications
- Select Install new application
- Browse for the ear file
- Select next until you reach step 2. Map modules to servers
- Select the tickbox for the custom action module
- In the Clusters and Servers section, select WebSphere_Portal and
select apply
- Keep selecting next until the end when you select finish
- The screen titled updating will be shown. Select Manage Applications.
- Locate and select the application you just installed. This is named "WCM
Sample Custom Workflow Action" by default.
- Under Detail Properties select Startup behavior.
- Under General Properties modify the Startup order to be the same
weight as "wcm" and select Apply. By default, the weight is 20.
- Select Save directly to master configuration.
To update an existing ear file:
- Select Applications
- Select Enterprise Applications
- Search for the Application name
- Select the tickbox for the custom action application and click on update
- Select upload the replacement application and browse for the ear
file
- Keep selecting next until the end when you select finish
- The screen titled 'updating' will be shown. Select Save to Master
Configuration and then click save.
Create a custom workflow action
Once your java class
is installed, you can create a custom workflow action. The custom workflow
action can be added to a workflow stage just like any other workflow action.
Parent topic: Creating a custom action
|
|
|