1 person found this helpful
Not sure about the entire context you have here but you should be able to followup with using the attachmentManager.setAttachmentParent method which is the final piece of the puzzle for associating the attachment to an object in Jive (discussion, document etc).
Thanks Kevin, I have made the code changes by adding attachment parent but I am still getting NPE, Let's see if I can make this working.
Okay, so I tested this out and final piece of code which actually works to show attachment on document UI is -
AttachmentBean attachmentBean = new AttachmentBean();
// 2. Replaced the ID that exists in local
attachmentBean.setProperties(new HashMap<String, String>());
DbAttachment attachment = new DbAttachment(attachmentBean);
JiveObject jiveObject = jiveObjectLoader.getJiveObject(102, 1001L);
// 3. Create attachment.
attachment = (DbAttachment) attachmentManager.createAttachment(attachment.getAttachmentContentResource(), attachment.getName(), attachment.getContentType(), attachment.getData(), image);
//4. I'm casting jiveObject here, you may well try to cast the attachment content resource as Document
Document doc = (Document) jiveObject;
// 5. Adds version to the attachment
// 6. Finally, save the document.