I want to copy the content from one object stored in one docbase to another object stored in another docbase. I do not want to create a file because I have more than 300 k files to copy. Below is a part of my code:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
IOUtils.copy(source.getContent(), baos);
[...]
targetObj.setContent(baos); // Documentum DFC
targetObj.save(); // Documentum DFC
If I do not tune the JVM, IOUtils.copy(source.getContent(), baos);
gives java.lang.OutOfMemoryError: Java heap space
.
If I tune the JVM by setting Xmx max value, the previous instruction is ok, but java.lang.OutOfMemoryError: Java heap space
occurs with targetObj.setContent(baos);
.
With an only 8332175 Bytes large content... (7.94 MB)
Any idea what's wrong? A better way to copy from ByteArrayInputStream to ByteArrayOutputStream? Something else?
Some Documentum API
getContent
public ByteArrayInputStream getContent() throws DfException
Copies this object's content from the Documentum server into a ByteArrayInputStream >object.
The following code example demonstrates how to copy an objects content from the >Documentum server into memory:
IDfSysObject sysObj = (IDfSysObject)session.getObject(new DfId("0900d5bb8001f900")); ByteArrayInputStream bais = sysObj.getContent(); if (bais.available() > 0) { // Data successfully fetched from the server... }
Returns: a ByteArrayInputStream object containing the objects content. Throws: DfException - if a server error occurs.
And
setContent
public boolean setContent(ByteArrayOutputStream content) throws DfException
Sets new content to an object. Use this method when you want to set data that resides >in working memory.
The following code example demonstrates how to set content residing in memory to a new document:
IDfSysObject sysObj = (IDfSysObject)sess.newObject("dm_document"); sysObj.setObjectName("testDoc"); sysObj.setContentType("crtext"); byte b[] = {35,36,37,38,39}; ByteArrayOutputStream out = new ByteArrayOutputStream(); out.write(b, 0, 5); sysObj.setContent(out); sysObj.save();
Parameters: content - the content as a ByteArrayOutputStream. Throws: DfException - if a server error occurs.