javajythondocumentumdfc

Jython with DFC Code


I am trying to work with IDfSysObjects in Documentum via jython, but I can't figure out how to call the methods appropriately from the interperter. The code below illustrates what I'd like to call with jython.

String docId= getDocId();
IDfSysObject doc = (IDfSysObject)session.getObject(new DfId(docId));
ByteArrayInputStream stream = doc.getContent();

from this post:

DFC reading a file

I don't know how to reconcile an IDfSysObject with the session. I have tried calling

session.getObject([r_object_id])

but I get

TypeError: 1st arg can't be coerced to com.documentum.fc.common.IDfId

My primary question is, does anyone know how to convert the following line of code into jython?

IDfSysObject doc = (IDfSysObject)session.getObject(new DfId(docId));

Solution

  • Try this code, it does what you want:

    import com.documentum.fc.client.DfClient as DfClient
    import com.documentum.fc.common as common
    
    import array 
    
    class DFCExample:
     def connectToDocbase(docbase, user, password):
       client = DfClient.getLocalClient()
       li = common.DfLoginInfo()        
       li.setUser(user)
       li.setPassword(password)
       sess = client.newSession(docbase, li)
       return sess
    
     def example(sess, docId):  
       id = common.DfId(docId)
       sysObj = sess.getObject(id)
       print array.array('b', iter(sysObj.getContent().read, -1)).tostring()
    
     session = connectToDocbase("docbaseDev", "dmadmin", "dmadmin")
     example(session, "0900323e80071339")
     sess.disconnect()