DFC 6.7
I have a requirement to copy documents from one docbase to another using DFC. However, the trick is that, the source and target object types are different (but somewhat similar). I have a mapping for the attributes. What would be the best way to approach this from a DFC perspective? I assume idfCopy doesn't help here because of the different types.
Here is a list of high level steps I was thinking of:
- Get a session in source docbase
- Get a session in target docbase
- Read attributes from source and write to the new type in target
something like trgObject.setString("srcAttribute", srcObject.getString("trgAttribute"));
- Get content from source and set it on the target object
something like
ByteArrayInputStream baisContent = srcObject.getContent();
int numOfBytes = baisContent.available();
byte inputBuffer[] = new byte[numOfBytes];
int bytesRead = baisContent.read(inputBuffer, 0, numOfBytes);
ByteArrayOutputStream outStreamContent = new ByteArrayOutputStream(bytesRead);
outStreamContent.write(inputBuffer, 0, numOfBytes);
trgObject.setContent(outStreamContent);
Any other suggestions are greatly appreciated!