Archive for April, 2011

Uploading Document In Documentum Through Java

April 13, 2011 1 comment

Document management is a requirement in many applications and documentum is a widely used document management system. Document management starts with document upload. Once a document is uploaded it can be associated with workflow and lifecycle. In addition to this, different versions of the document can be created and maintained. This document focuses on saving documents with metadata in the documentum using java and JSF.

An object or document in documentum can be considered to be a combination of metadata and physical file. A content model that defines the attributes of the document can be created in the documentum. This can be used to refer to the attributes that are associated with the document.


A Documentum object has to be created before storing data in the Documentum.

Following are the steps to do the same.

1. Get the session for the user who is creating the object

Sample code to get the session object

// Getting the clientIDfClient client =DfClient.getLocalClient();

// Preparing IDfLogininfo object with the user credentialsIDfLoginInfo loginInfo = new DfLoginInfo();

// Set the UserloginInfo.setUser(“<userid>”);

// Set the passwordloginInfo.setPassword(“<password>”);

// Get the session managersessionManager= client.newSessionManager();

// set the user identity for the session managersessionManager.setIdentity(“”,loginInfo);

// Get the IDfSessionIDfSession session = sessionManager.getSession(“”)
2. Create a documentum object Before uploading a document, a place holder for the document, with an identifier has to be created in the documentum.

Given below is the sample code for doing the same.

IDfDocument documentObj = (IDfDocument)session.newObject(“name_of_the_contentmodel”);


where,“name_of_the_contentmodel” , is the type of the object to be created.

“crtext” is the documentum format for a text file.

Setting the content type for the file to be uploaded is mandatory.

On creating a new object, a unique identifier, say objectId is generated.

It can be obtained using “documentObj.getObjectId()”.

Once the object is created, it can be accessed using methods of the Interface,

IDfSysObject.IDfSysObject sysObject = (IDfSysObject)session.getObject(new DfId(documentObj.getObjectId());

where, documentObj.getObjectId() is the documentum object.

Saving Metadata

Document attributes obtained from UI or otherwise can be set and then saved in the documentum using the object reference, sysObject as shown below.

sysObject.setString(identifier for the attribute in the documentum , value for the attribute).

sysObject.setInt(identifier for the attribute in the documentum, value for the attribute)

sysObject.setTime(identifier for the attribute in the documentum, new DfTime(date))

Attaching repeating values(List of objects) , to a property of the documetum object

for (Object value : repeatingValues){

document.appendValue(identifier for the attribute in the documentum,new DfValue(value,sysObject.getAttrDataType(identifier for the attribute in the documentum)));


}, saves the attributes in the documentum.

Uploading file:


In JSF, hx:fileUpload can be used to browse and select a file. This tag accepts data in the form of an array of bytes.

Code in the .jsp file

<hx:fileupload id=”fileupload1″ value=”#{managedBeanName.fileData}” >

<hx:fileProp name=”fileName” value=”#{ managedBeanName.uploadFileName}”/>

<hx:fileProp name=”contentType” value=”#{ managedBeanName.format}”/>


private byte[] fileData = null;—-property in the managed bean to store the content of the file.

private String uploadFileName = null;—-property in the managed bean that stores the file name.

private String format = null;—-property in the managed bean that stores the file format.

Sample java code for saving the file content in the Documentum

FileOutputStream fileOutputStream = null;

ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();


IDfSysObject sysObject= (IDfSysObject)session.getObject(new DfId(documentObj.getObjectId());





where, sysObject is the reference to the Documentum object , that will hold the uploaded data and “format” is the format of the file to be uploaded .

Setting contentType is mandatory and the format of the file has to be mapped to Documentum format using resource bundle. The uploaded file, with its attributes can be viewed through the Documentum administrator.

%d bloggers like this: