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 (2)Add Comment
0
Cool Stuff - wholesale cool gifts - unique gift ideas
written by cool stuff, August 26, 2010
very cool article ,thanks for sharing the article!like my cool stuff .very useful.
uCoolStuff is the leading China wholesaler for cool stuff, cool gifts, unusual gadgets and other unique gift ideas. We provide the very latest cool stuff and cool gifts for you
0
China Wholesale Directory - Top China Wholesalers
written by china wholesale directory, August 26, 2010
excellent article , I added you to my Top China Wholesalers category.. thanks for sharing the article!

Write comment

security code
Write the displayed characters


busy