Hi ,
PFB the code with which I am facing issues
package com.sample.test;
import java.io.OutputStream;
import java.util.Iterator;
import java.util.Map;
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.DfLoginInfo;
import com.documentum.fc.common.IDfLoginInfo;
import com.documentum.mthdservlet.IDmMethod;
import java.util.*;
public class TestJob implements IDmMethod {
protected String m_docbase;
protected String m_userName;
protected String m_password;
protected String m_domain;
protected String m_jobid;
protected String m_mtl;
int noRecords;
public TestJob()
{
m_docbase = null;
m_userName = null;
m_password = null;
m_domain = null;
m_jobid = null;
m_mtl = "0";
}
public void execute(Map params, OutputStream ostream) throws Exception
{
initParams(params, ostream);
IDfSession session=null;
IDfSessionManager sMgr=null;
ostream.write("\n\nThe docbase logged in is:".getBytes());
try{
sMgr=login();
session = sMgr.getSession(m_docbase);
ostream.write("\nsession id is:".getBytes());
ostream.write(session.getSessionId().getBytes());
ostream.write("\n".getBytes());
ostream.write(session.getLoginUserName().getBytes());
ostream.write("\n".getBytes());
ostream.write(m_userName.getBytes());
define(ostream , session);
ostream.write("\n Define successfully called".getBytes());
}
catch(DfException dexception)
{
ostream.write(dexception.getMessage().getBytes());
//DfLogger.debug(this, "In Execute Method catch block", null, null);
dexception.printStackTrace();
//throw dexception;
}
catch(Exception e)
{
ostream.write(e.getMessage().getBytes());
}
finally {
if(session!=null){
sMgr.release(session);
ostream.write("\nIn finally block:".getBytes());
}
}
System.out.println("End of Code");
}
protected void initParams(Map params, OutputStream ostream)
throws Exception
{
Set keys = params.keySet();
for(Iterator iter = keys.iterator(); iter.hasNext();)
{
String key = (String)iter.next();
if(key != null && key.length() != 0)
{
String value[] = (String[])params.get(key);
if(key.equalsIgnoreCase("user_name"))
m_userName = value.length <= 0 ? "" : value[0];
else
if(key.equalsIgnoreCase("docbase_name"))
m_docbase = value.length <= 0 ? "" : value[0];
else
if(key.equalsIgnoreCase("password"))
m_password = value.length <= 0 ? "" : value[0];
else
if(key.equalsIgnoreCase("domain"))
m_domain = value.length <= 0 ? "" : value[0];
else
if(key.equalsIgnoreCase("job_id"))
m_jobid = value.length <= 0 ? "" : value[0];
else
if(key.equalsIgnoreCase("method_trace_level"))
m_mtl = value.length <= 0 ? "" : value[0];
}
}
System.out.println("Details are :" + m_userName + m_docbase + m_password + m_domain + m_jobid + m_mtl);
}
protected IDfSessionManager login()
throws DfException
{
System.out.println("Docbase:" + m_docbase);
System.out.println("UserName:" + m_userName);
if(m_docbase == null || m_userName == null)
return null;
IDfClient dfClient = DfClient.getLocalClient();
if(dfClient != null)
{
IDfLoginInfo li = new DfLoginInfo();
li.setUser(m_userName);
li.setPassword(m_password);
li.setDomain(m_domain);
IDfSessionManager sessionMgr = dfClient.newSessionManager();
sessionMgr.setIdentity(m_docbase, li);
return sessionMgr;
} else
{
return null;
}
}
public void define(OutputStream ostream , IDfSession session) throws Exception
{
TestDriver testDriver=null;
try
{
testDriver = new TestDriver(ostream);
ostream.write("\nTest Driver Object is created:".getBytes());
testDriver.testMethod(session , ostream);
ostream.write("\nCalling test method is done:".getBytes());
}
catch(Exception e)
{
ostream.write(e.getMessage().getBytes());
e.printStackTrace();
}
finally {
ostream.write("\nIn finally block2:".getBytes());
}
}
}
In the above method, we are able to create session and everything but the TestDriver object is not getting created and the method testMethod is not getting called. The TestDriver is a seperate class. Using the ostream I am creating the report for the method. When the method is being deployed as a job and then after selecting the job and clicking on View->Report it is showing all the log messages. But it is not displaying the messages after the line where the TestDriver class is being instantiated.
Please let me know where I am going wrong and what are the possible ways of resolving this issue.