Friday, 4 July 2014

Documentum Methods ?

A method is a java code which can be executed in two ways

1.job
2.Auto-activity


Method Creation:
---------------
An example method is given below:

package com.dba.javamethod.SampleMethodFolder;

//import method from packages

public class TestDBA_JavaMethod implements IDfMethod
{
private IDfSession idfSession = null;
private String strUserName = null;
private String strTicket = null; // token for password
private String strDocbaseName = null;
private String workitemId = null;
private String workitemState = null;

public int execute(Map parameters, PrintWriter ostream) throws Exception
{
try
{
Iterator iterator = parameters.keySet().iterator();
while (iterator.hasNext())
{
String key = (String) iterator.next();
String[] values = (String[]) parameters.get(key);

if ("user".equals(key))
{
strUserName = values[0];
Log.debug(TestDBA_JavaMethod.class,"Value for user : "+strUserName);
}
else if ("ticket".equals(key))
{  
strTicket = values[0];
if(strTicket.indexOf("DM_TICKET=") == 0)
strTicket = strTicket.substring(10, strTicket.length());
Log.debug(TestDBA_JavaMethod.class,"Final Value for ticket : "+strTicket);
} else if ("docbase_name".equals(key))
{
strDocbaseName = values[0];
}
else if (key.equalsIgnoreCase("packageId")) //workitem ID
{
       workitemId = values[0];
   }

else if (key.equalsIgnoreCase("mode")) //workitem runtime state
{
       workitemState = values[0];
   }
}
Log.info("", "completed assigning required from Map interface");

IDfClientX cx = new DfClientX();
IDfLoginInfo li = cx.getLoginInfo();
li.setUser(strUserName);
li.setPassword(strTicket);
li.setDomain(null);

IDfClient dfClient = cx.getLocalClient();
       IDfSessionManager sessionMgr = dfClient.newSessionManager();
       sessionMgr.setIdentity(strDocbaseName, li);
       idfSession = sessionMgr.getSession(strDocbaseName);
       Log.info("", "got the session");
     
       IDfId workitemID = new DfId(workitemId);
       IDfWorkitem workitem = (IDfWorkitem)idfSession.getObject(workitemID);
       System.out.println(" before acquiring ");
       if(workitemState.equals("0"))
        workitem.acquire();
       System.out.println("Task acquired ");
     
      //Business logic
     
       workitem.complete();
       Log.info("", "completed Work flow related tasks");    

} catch (Exception e)
    {
    DfLogger.error(null, "An exception has occured ….", null, e);
    }
    finally
    {
    if(idfSession!=null)
    {
    idfSession.getSessionManager().release(idfSession);
    System.out.println("In TestMethod.execute() idfSession released …");
    }
    }
    return 0;
}
}




This method class file has to be copied to :Documentum>dba>java_methods> <<package>>
if needed place the IDmMethod.jar or IDfMethod.jar in :Documentum>dba>java_methods>bin folder

In DA Administration>Job Management>Methods>File>new>method

there provide the
method name ex:Test_method
verd  ex:com.dba.javamethod.SampleMethodFolder.TestDBA_JavaMethod
method type: java
check Use method server,run as owner

then finish


Method running through Auto-Activity:
-------------------------------------
For running a method through Auto-Activity the folowing query has to be run

update dm_method object set a_special_app='Workflow' where object_name ='try auto method'

So that the method will be available in method dropdown-list of Auto-Activity


A method implements IDfMethod or IDmMethod thereby overriding the existing 'execute' method

IDfMethod has execte(Map arguments,PrintWriter print) method and it returns integer value
IDmMethod has excute(Map arguments,OutputStream output) method returns nothing

IDmMethod is in metdsrvlet.jar used in Documentum 5.3x.// But Depricated
IDfMethod is in Dfc.jar and  //both are same

No comments:

Post a Comment