int i = 0;
while (iter.hasNext()) {
CvFileVO fileVO = (CvFileVO)iter.next();
int fileID = fileVO.getFileId();
String fileName = fileVO.getTitle();
attachmentMap.add(new DDNameValue(fileID+"#"+fileName,fileName));
}
if (saveOrigBodyAsAttachment) {
CvFolderVO attachmentFolderVO = (CvFolderVO)remote.getAttachmentFolder(individualID);
int attachmentFolderID = attachmentFolderVO.getFolderId();
int newFileID = -1;
// somehow create a file using CvFileFacade, and get a CvFileVO from that.
CvFileVO fileVO = new CvFileVO();
SimpleDateFormat df = new SimpleDateFormat("MMMM_dd_yyyy_hh_mm_ss_S");
String prependDate = df.format(new Date());
fileVO.setName("OriginalMessage_#" + messageID.intValue() + "_" + prependDate + ".html");
fileVO.setTitle("OriginalMessage_#" + messageID.intValue());
fileVO.setDescription("");
fileVO.setFileSize(0.0f); // float
fileVO.setVersion("1.0");
fileVO.setStatus("PUBLISHED");
fileVO.setVisibility(CvFileVO.FV_PRIVATE);
fileVO.setPhysical(CvFileVO.FP_PHYSICAL);
fileVO.setPhysicalFolder(attachmentFolderID);
fileVO.setAuthorId(individualID);
fileVO.setIsTemporary(CvFileVO.FIT_YES);
ByteArrayInputStream inputStream = new ByteArrayInputStream(originalBody.getBytes());
try {
CvFileFacade fileFacade = new CvFileFacade();
newFileID = fileFacade.addFile(individualID, attachmentFolderID, fileVO, inputStream, dataSource);
}catch(CvFileException cfe){
// I guess do nothing
}
if (newFileID > 0) {
// Add the CvFileVO to attachmentList, and the following line for the attachmentMap
fileVO.setFileId(newFileID);
String FileName= "OriginalMessage_" + messageID.intValue();
attachmentMap.add(new DDNameValue(newFileID+"#"+FileName,FileName));
}
} // end if (saveOrigBodyAsAttachment)
if (! attachmentMap.isEmpty()) {
emailForm.set("attachmentList", attachmentMap);