|
Copyright 2008. All Rights Reserved.
Everyone know, to create workflow method we have to implements IDmMethod but there is another way and it's much faster
Introducting WorkflowMethod class that comes from Process Builder (look in C:\Program Files\Documentum\ BPM\classes\lib\bpmutil.jar). By Extending this class your method can be shortened as this class provides many "tools" that very useful for a workflow method package net.mydocumentum.workflow.method;
import java.io.PrintWriter;
import com.documentum.bpm.rtutil.WorkflowMethod; import com.documentum.fc.client.IDfWorkitem; import com.documentum.fc.common.IDfProperties;
public class MyWorkflwMethod extends WorkflowMethod {
@Override protected int doTask(IDfWorkitem arg0, IDfProperties arg1, PrintWriter arg2) throws Exception { // TODO Auto-generated method stub return 0; }
}
Compare it to the "old way" package net.mydocumentum.workflow.method; import java.io.OutputStream;
import java.util.Iterator; import java.util.Map; import java.util.Set; import com.documentum.fc.client.DfClient;
import com.documentum.fc.client.IDfClient; import com.documentum.fc.client.IDfSession; import com.documentum.fc.client.IDfSessionManager; import com.documentum.fc.common.DfException; import com.documentum.fc.common.DfLogger; import com.documentum.fc.common.DfLoginInfo; import com.documentum.fc.common.IDfLoginInfo; import com.documentum.mthdservlet.IDmMethod; public class MyMethod implements IDmMethod {
private static final String USER_KEY = "user"; private static final String DOCBASE_KEY = "docbase_name"; private static final String TICKET_KEY = "ticket"; protected String docbaseName = null;
protected String userName = null; protected String ticket = null; private IDfSessionManager sessionManager = null;
private IDfSession session = null; protected void login() throws DfException { if (docbaseName==null) throw new IllegalArgumentException("invalid docbaseName!"); if (userName==null) throw new IllegalArgumentException("invalid userName!"); if (ticket==null) throw new IllegalArgumentException("invalid ticket!"); IDfClient dfClient = DfClient.getLocalClient(); IDfLoginInfo li = new DfLoginInfo();
li.setUser(userName); li.setPassword(ticket); li.setDomain(null); sessionManager = dfClient.newSessionManager(); sessionManager.setIdentity(docbaseName, li); session = sessionManager.getSession(docbaseName); } protected void logout() {
sessionManager.release(session); } protected void readParams(Map params) { Set keys = params.keySet(); Iterator iter = keys.iterator(); while (iter.hasNext()) { String key = (String) iter.next(); if( (key == null) || (key.length() == 0) ) { continue; } String []value = (String[])params.get(key); if ( key.equalsIgnoreCase(USER_KEY) )
userName = (value.length > 0) ? value[0] : ""; else if ( key.equalsIgnoreCase(DOCBASE_KEY) ) docbaseName = (value.length > 0) ? value[0] : ""; else if ( key.equalsIgnoreCase(TICKET_KEY) ) ticket = (value.length > 0) ? value[0] : ""; } } protected IDfSession getSession() {
return session; } protected IDfSessionManager getSessionManager() {
return sessionManager; } protected String getDocbaseName() {
return docbaseName; } protected String getTicket() {
return ticket; } protected String getUserName() {
return userName; } public void logInfo(String message)
{ DfLogger.info(this, "METHOD-INFO: "+message, null, null); } public void logDebug(String message) { DfLogger.debug(this, "METHOD-DEBUG: "+message, null, null); } public void logError(String message, DfException ex )
{ DfLogger.error(this, "METHOD-ERROR: "+message, null, ex); } /************************************************************** * doExecute method template **/
abstract public boolean doExecute(Map param, OutputStream out) throws Exception; public void execute(Map param, OutputStream out) throws Exception { DfLogger.debug(this, "Execute workflow method...", null, null); readParams(param); login(); doExecute(param, out);
logout(); } }
Trackback(0)
 |