I need to attach a file generated by Apache POI on an Xpage to a notes document. I have been attempting to implement a solution as suggested by Knut Herrmann:
var temp = java.lang.System.getProperty("java.io.tmpdir");
var file = new java.io.File(temp + "YourFile.docx");
var fileOutputStream = new java.io.FileOutputStream(file);
xwpfdocument.write(fileOutputStream);
fileOutputStream.close();
var doc:NotesDocument = currentDocument.getDocument();
var rdoc:NotesDocument = database.createDocument();
rdoc.appendItemValue("Form", "frmRespTempl");
rdoc.appendItemValue("Subject", "Embedded Word Document");
var rtitem:RichTextItem = rdoc.createRichTextItem("Body");
rtitem.embedObject(lotus.domino.local.EmbeddedObject.EMBED_ATTACHMENT,"",file.getAbsolutePath(), null);
rdoc.makeResponse(doc);
rdoc.save();
POI for XPages - save Word document as attachment in rich text field
however, in order to make xwpfdocument.write(fileOutputStream) work, the java policy file needs to be modified which is a security risk.
I had no luck making the java solutions work either. Is there any other way to go about making this code work? What exactly is the risk of modifying the java policy?
Thanks