WebSphere Portal, Express Beta Version 6.1
Operating systems: i5/OS, Linux,Windows


 

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:

  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.

  3. Create a custom workflow action factory class that implements the interface com.ibm.workplace.wcm.api.custom.CustomWorkflowActionFactory.
  4. 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:

  1. Select Applications
  2. Select Install new application
  3. Browse for the ear file
  4. Select next until you reach step 2. Map modules to servers
  5. Select the tickbox for the custom action module
  6. In the Clusters and Servers section, select WebSphere_Portal and select apply
  7. Keep selecting next until the end when you select finish
  8. The screen titled updating will be shown. Select Manage Applications.
  9. Locate and select the application you just installed. This is named "WCM Sample Custom Workflow Action" by default.
  10. Under Detail Properties select Startup behavior.
  11. Under General Properties modify the Startup order to be the same weight as "wcm" and select Apply. By default, the weight is 20.
  12. Select Save directly to master configuration.
To update an existing ear file:

  1. Select Applications
  2. Select Enterprise Applications
  3. Search for the Application name
  4. Select the tickbox for the custom action application and click on update
  5. Select upload the replacement application and browse for the ear file
  6. Keep selecting next until the end when you select finish
  7. 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
Library | Support | Terms of use |