MyDocumentum

Community with Real World Experience

 

Login

Best Way to Create Workflow Method PDF E-mail
Written by <a href="http://www.mydocumentum.net/component/comprofiler/userprofile/jazar">James Azarja</a>   
Wednesday, 14 January 2009 23:10

Tags See All Tags Add New Tag...

Please Enter New Tags Separated By Comma's
  Or Close


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)
Comments (5)Add Comment
65
...
written by Constantin, January 16, 2009
Regarding to what that James has written, maybe you all need to know the API documentation, you can find the documentation in : [DOCUMENTUM_SHARED]/Help/bpm/api/index.html For example: C:/Program Files/Documentum/Help/bpm/api/index.html
65
Logging your class that extend from WorkflowMethod
written by Constantin, January 16, 2009
Do you realize ? That if you extend a class using class from bpm, for instance extending from WorkflowMethod, you cannot see all your log. For example you have a class pis.documentum.method.TestWorkflow that extend WorkflowMethod, and configure in log4j.properties : log4j.logger.pis.documentum.method=DEBUG, PIS_TRACE. Actually this line will not work. You must add a bpm in front, so the syntax would be like this : log4j.logger.bpm.pis.documentum.method=DEBUG, PIS_TRACE
145
Using IDfModule for workflow methods
written by Henrik Klemmen, March 27, 2009
Hi,
I generally use IDfModule as well. It makes the deployment much easier.

public class WasApprovedByAll extends WorkflowMethod implements IDfModule ...
147
...
written by Yogesh, April 01, 2009
Hi,
i have placed a jar containing the new custom method in both, the ....dba/java_methods and the ....bpm/custom folders, but the auto activity in process builder cannot see this method. I have created a method through DA which references the new class. Am i missing any steps?

Thanks
-yogesh
145
java_methods
written by Henrik Klemmen, April 02, 2009
Hi,
If you deploy in a jar file, you must add the jar-file to classpath.
bt
Henrik

Write comment

security code
Write the displayed characters


busy