Hi All
I have just finished my exercise to show data access of documents inside the Documentum database on to my Tomcat console using the DFC Guide as well as help from the community. The following is the Java code for the same.
package com.documentum.custom.library;import com.documentum.fc.client.IDfCollection;
import com.documentum.fc.client.IDfGroup;
import com.documentum.fc.client.IDfSession;
import com.documentum.fc.common.DfException;
import com.documentum.fc.common.DfId;
import com.documentum.fc.common.DfList;
import com.documentum.fc.common.IDfList;
import com.documentum.web.common.AccessibilityService;
import com.documentum.web.common.ArgumentList;
import com.documentum.web.common.ErrorMessageService;
import com.documentum.web.common.WrapperRuntimeException;
import com.documentum.web.form.Control;
import com.documentum.web.form.Form;
import com.documentum.web.form.FormActionReturnListener;
import com.documentum.web.form.control.Checkbox;
import com.documentum.web.form.control.DropDownList;
import com.documentum.web.form.control.Label;
import com.documentum.web.form.control.Link;
import com.documentum.web.form.control.Panel;
import com.documentum.web.form.control.TextArea;
import com.documentum.web.form.control.databound.DataProvider;
import com.documentum.web.form.control.databound.Datagrid;
import com.documentum.web.form.control.validator.RegExpValidator;
import com.documentum.web.form.control.validator.RequiredFieldValidator;
import com.documentum.web.formext.component.Component;
import com.documentum.web.formext.docbase.ServerUtil;
import com.documentum.webcomponent.common.WebComponentErrorService;
import com.documentum.webcomponent.library.locator.LocatorItemResultSet;
import com.documentum.webcomponent.library.messages.MessageService;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import com.documentum.com.DfClientX;
import com.documentum.fc.client.IDfClient;
import com.documentum.fc.client.IDfCollection;
import com.documentum.fc.client.IDfSession;
import com.documentum.fc.client.IDfSessionManager;
import com.documentum.fc.client.IDfSysObject;
import com.documentum.fc.client.IDfTypedObject;
import com.documentum.fc.common.IDfId;
import com.documentum.fc.common.IDfLoginInfo;import com.documentum.fc.client.IDfSession;
import com.documentum.fc.client.IDfSessionManager;
import com.documentum.fc.client.IDfSysObject;
import com.documentum.fc.common.IDfId;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.InputStreamReader;public class DummyComponent extends Component
{
private HashMap m_docIdLookup;
private ArrayList m_users;
private HashMap m_userLookup;
private HashMap m_userTypeLookup;
private String m_recipientNameDelim;
private boolean m_bSelectingRecipients;
private boolean m_bSelectingDocuments;
private boolean m_bSupportSequential;
public static final String SELECTED_FILES_DATAGRID_CONTROL_NAME = "__SELECTED_FILES_DATAGRID_CONTROL_NAME";
public static final String INSTRUCTIONS_TEXTAREA_CONTROL_NAME = "__INSTRUCTIONS_TEXTAREA_CONTROL_NAME";
public static final String INSTRUCTIONS_VALIDATOR_CONTROL_NAME = "__INSTRUCTIONS_VALIDATOR_CONTROL_NAME";
public static final String PRIORITY_DROPDOWN_CONTROL_NAME = "__PRIORITY_DROPDOWN_CONTROL_NAME";
public static final String RECIPIENTS_LABEL_CONTROL_NAME = "__RECIPIENTS_LABEL_CONTROL_NAME";
public static final String RECIPIENTS_VALIDATOR = "__RECIPIENTS_VALIDATOR";
public static final String SEQUENTIAL_CHECKBOX_CONTROL_NAME = "__SEQUENTIAL_CHECKBOX_CONTROL_NAME";
public static final String REJECT_INITIATOR_CHECKBOX_CONTROL_NAME = "__REJECT_INITIATOR_CHECKBOX_CONTROL_NAME";
public static final String REJECT_PREVIOUS_CHECKBOX_CONTROL_NAME = "__REJECT_PREVIOUS_CHECKBOX_CONTROL_NAME";
public static final String NOTIFICATION_CHECKBOX_CONTROL_NAME = "__NOTIFICATION_CHECKBOX_CONTROL_NAME";
public static final String SIGNOFF_CHECKBOX_CONTROL_NAME = "__SIGNOFF_CHECKBOX_CONTROL_NAME";
public static final String SEQUENTIAL_PANEL_CONTROL_NAME = "__SEQUENTIAL_PANEL_CONTROL_NAME";
public static final String SIGNOFF_PANEL_CONTROL_NAME = "__SIGNOFF_PANEL_CONTROL_NAME";
public static final String PRIORITY_VALUE_HIGH = "10";
public static final String PRIORITY_VALUE_MEDIUM = "5";
public static final String PRIORITY_VALUE_LOW = "1";
private IDfSessionManager m_sessionManager;
private String reponame = "documentum";
private String objectString = "09de75d180003df9";
private String strObject;
public DummyComponent(){
this.m_docIdLookup = new HashMap(); this.m_users = new ArrayList();
this.m_userLookup = new HashMap();
this.m_userTypeLookup = new HashMap(); this.m_bSelectingRecipients = false; this.m_bSelectingDocuments = false; this.m_bSupportSequential = false;
createSessionManager();
strObject = getContent(m_sessionManager,reponame,objectString);
System.out.println("This is content " + strObject );
}
public void onInit(ArgumentList arg)
{
super.onInit(arg);
String[] vals = arg.getValues("objectId");
}
private Boolean createSessionManager() { try {
System.out.println("This is inside createSessionManager");
// The only class we instantiate directly is DfClientX.
DfClientX clientx = new DfClientX();
// Most objects are created using factory methods in interfaces.
// Create a client based on the DfClientX object.
IDfClient client = clientx.getLocalClient();
System.out.println("This is inside createSessionManager 11");
// Create a session manager based on the local client.
m_sessionManager = client.newSessionManager();
// Set the user information in the login information variable.
System.out.println("This is inside createSessionManager 22");
IDfLoginInfo loginInfo = clientx.getLoginInfo();
loginInfo.setUser("MyUsername");
loginInfo.setPassword("MyPassword");
System.out.println("This is inside createSessionManager33");
// Set the identity of the session manager object based on the repository
// name and login information.
m_sessionManager.setIdentity( "documentum",loginInfo);
System.out.println("This is prior to True");
return true;
}
catch (Exception ex)
{
ex.printStackTrace();
System.out.println("Failed to instantiate Session Manager.");
return false;
}
}public String getContent(IDfSessionManager sessionManager,String repositoryName,String objectIdString)
{
IDfSession mySession = null;
StringBuffer sb = new StringBuffer("");
try
{
System.out.println("Repository Name " + repositoryName);
mySession = sessionManager.getSession(repositoryName);
System.out.println("MySession" + mySession);
// Get the object ID based on the object ID string.
System.out.println("Inside getContent 1");
System.out.println("objectString" + objectString);
DfId dfId = new DfId(objectString);
if(dfId.isObjectId()) {
System.out.println("Successfully fetched id " + dfId);
}
//IDfId idObj =mySession.getIdByQualification("dm_sysobject_s where r_object_id='09de75d180003df9'");
//System.out.println("idObj>>>>>" + idObj); //if (idObj.getId().equals("09de75d180003df9"))
//{
// System.out.println("Successfully fetched id");
//}
System.out.println("Inside getContent 2");
// Instantiate an object from the ID.
IDfSysObject sysObj = (IDfSysObject) mySession.getObject(dfId);
System.out.println("Inside getContent 3");
System.out.println("Content Type ++++++ "+ sysObj.getContentType());
if (sysObj.getContentType().equals("crtext") | sysObj.getContentType().equals("text"))
{
ByteArrayInputStream buf = sysObj.getContent();
System.out.println("Inside getContent 4");
int i = 0;
InputStreamReader readInput = new InputStreamReader(buf, "UTF8");
BufferedReader br = new BufferedReader(readInput);
while (br.ready())
{
System.out.println("Inside while of getContent ******** ");
sb.append(br.readLine());
sb.append("\n");
}
return sb.toString();
}
else
{
System.out.println("Inside getContent 5");
return "Use getContent to view text documents.";
}
}
//Handle any exceptions.
catch (Exception ex)
{
ex.printStackTrace();
return "Exception has been thrown: " + ex;
}
//Always, always, release the session in the "finally" clause.
finally
{
sessionManager.release(mySession);
}
}
}
public
My question is ahow can i undo the hardcoding of object_id by getting values from my JSP.My reply to this post has information regarding the JSP