Setting existing content on new dm_document with DFC

edited January 23, 2017 in Documentum

I'm writing a migration program that will create a new instance of a object_type 1. It will then take attribute values from an existing instance of object_type 2 and set them on the new object_type 1 instance. It will also make a copy of the content on instance1 and set it on instance2. Some of the content on instance1 is very large (100's of MB). As far as I can tell, DFC only provides setting of content from 1 instance to another using byte array streams. This is inefficient and could blow out memory in the JVM using byte array streams.

I would like to set the I_content_id on instance2 to the I_conent_id that is on instance1. I'm aware that a new parent_id value on the content object must also be created. I suspect that there is further management as well that has to occur.

Does anyone know how to set content on a new dm_document (that has no present content) with an existing content that is in the repository, without using byte array streams?

Thank you,

Peter

Best Answer

  • edited January 11, 2017 Accepted Answer

    If your code is running directly on the Content Server, you don't even need to copy the file: you can do the setFile() by specifying the path to the original content on the Content Server file system (you can get that using getPath() on the original object). Alternatively, you can use bindFile(). That will even avoid copying the original file. However, that last option only works for the primary content.

Answers

  • edited January 10, 2017

    If you dont want to read content into memory, the other way is to save the content to file on OS file system (where you app is running from).  You can then use setFileEx() to associate the file to your existing new instance.  This may not be more efficient, but it can handle your large files.

  • edited January 11, 2017 Accepted Answer

    If your code is running directly on the Content Server, you don't even need to copy the file: you can do the setFile() by specifying the path to the original content on the Content Server file system (you can get that using getPath() on the original object). Alternatively, you can use bindFile(). That will even avoid copying the original file. However, that last option only works for the primary content.

  • edited January 19, 2017

    bacham2,

    Yep these are the 2 options I was looking for. A question on the bindFile() method.

    Here is the way I think it should work, please confirm or correct.

    You have your source object - srcObj

    You create a destination object - destObj

    You do a bindfile:

  • edited January 19, 2017

    Continuation of above

    you do a bindfile: destObj.bindFile(0, srcObj,0)

    you now have destObj and srcObj sharing the single content

    you now delete srcObj
    a
    n
    d run a purge job.
    The content does not get deel
    eted corre
    ct ? I would certainly hope that as there is a new content object for s  destObj pointing at the original content file

  • edited January 23, 2017

    Yes that is correct.  Don't forget to save after calling bindFile(). If you delete the source object, the content will not be deleted since a sysobject is still pointed to it. If you modify the source, no issue as well since a new content object would be created for the source.

Sign In or Register to comment.