Creating IBM WCM 8.5 Custom Workflow Action

Steps:


1) Create New Dynamic Web Project

2) Create a  new Java Class which implements  com.ibm.workplace.wcm.api.custom.CustomWorkflowAction
3) Implement execute method of  CustomWorkflowAction . and get  WebContentCustomWorkflowService  object by using JNDI Lookup
4)Create new java factory class which implements  com.ibm.workplace.wcm.api.custom.CustomWorkflowActionFactory
5) Create new  plugin.xml   under WEB-INF
6) Make starting weight of the application as same as starting weight of WCM application  , By Default it should be 20.
7)Deploy Application , New Cusotm Work flow action will be available in WCM.
Code:


Custom Workflow Action Class:

package com.ibm.core;

import java.util.Date;
import java.util.logging.Logger;

import javax.naming.InitialContext;

import com.ibm.workplace.wcm.api.Document;
import com.ibm.workplace.wcm.api.custom.CustomWorkflowActionResult;
import com.ibm.workplace.wcm.api.custom.Directive;
import com.ibm.workplace.wcm.api.custom.Directives;
import com.ibm.workplace.wcm.api.WebContentCustomWorkflowService;


public class MyCustomWorkflow implements
com.ibm.workplace.wcm.api.custom.CustomWorkflowAction {
Logger LOGGER = Logger.getLogger(MyCustomWorkflow.class.toString());

@Override
public CustomWorkflowActionResult execute(Document arg0) {
// Put your customized trigger codes here
LOGGER.info("Executing MyCustomWorkflow Doc id: "
+ arg0.getName());
String msg = "";
InitialContext initCtx = null;
WebContentCustomWorkflowService customWorkflowService = null;

try {
initCtx = new InitialContext();
customWorkflowService = (WebContentCustomWorkflowService) initCtx
.lookup("portal:service/wcm/WebContentCustomWorkflowService");
} catch (Exception e) {
msg = " - System has encountered exception (do check logs).";
e.printStackTrace();
}

// directive: indicate if the content should proceed to the next stage
// Check out WCM Javadoc for more valid directives information
Directive directive = Directives.CONTINUE;
LOGGER.info(" - document:" + arg0.getName());
return customWorkflowService.createResult(directive, msg);
}

@Override
public Date getExecuteDate(Document arg0) {
LOGGER.info("***********************Its executed in getExecutedDate *******************");
Date dt = new Date();
return dt;
}
}


Factory Class:

package com.ibm.core;

import java.util.Locale;

import com.ibm.workplace.wcm.api.Document;
import com.ibm.workplace.wcm.api.custom.CustomWorkflowAction;
import com.ibm.workplace.wcm.api.custom.CustomWorkflowActionFactory;

public class MyCustomWorkflowFactory implements CustomWorkflowActionFactory {

@Override
public CustomWorkflowAction getAction(String arg0, Document arg1) {
// Return object of CustomWorkflow that you created earlier.
return new MyCustomWorkflow();
}

@Override
public String getActionDescription(Locale arg0, String arg1) {
// TODO Auto-generated method stub
System.out
.println("Get Action Description is executing *****************");
return "Generates a thumbnail from existing content";
}

@Override
public String[] getActionNames() {
String names[] = { "Creating document id sp db" };
System.out
.println("**********get Action Name is executing ****************");
return names;
}

@Override
public String getActionTitle(Locale arg0, String arg1) {
// TODO Auto-generated method stub
System.out
.println("*******************get Action Title is executing ***************");
return "MyCustomWorkFlowFactory";
}

@Override
public String getName() {
// TODO Auto-generated method stub
System.out
.println("*************get Name is executing *****************");
return "MyCustomWorkFlowFactory";
}

@Override
public String getTitle(Locale arg0) {
System.out
.println("********************Get Title is executing *******************");
return "WCM 8.5 Portal Custom Workflow Action Factory";
}

}

Plugin.xml:







Here are the some of the book recommendations :

           

Enable GingerCannot connect to Ginger Check your internet connection
or reload the browser
Disable in this text fieldEditEdit in GingerEdit in GingerΓ—

Leave a Reply

Your email address will not be published. Required fields are marked *

Enable Notifications OK No thanks