CvFileFacade fileRemote = new CvFileFacade();
for (int i = 0; i < attachmentFileIDs.size(); i++) {
int fileID = ((Integer)attachmentFileIDs.get(i)).intValue();
// get the CvFileVO from the EJB layer
CvFileVO fileVO = fileRemote.getFile(individualID, fileID, dataSource);
if (fileVO != null) {
// add this attachment to the messageVO
messageVO.addAttachedFiles(fileVO);
}
}
}
// Send Email to all the Individual with the updated information of
// the Template
PrintTemplateHome PTHome = (PrintTemplateHome)CVUtility.getHomeObject(
"com.centraview.printtemplate.PrintTemplateHome", "Printtemplate");
PrintTemplate PTRemote = PTHome.create();
PTRemote.setDataSource(dataSource);
if (ptfrom != null && !ptfrom.equals("") && !ptfrom.equals("null")) {
int accountID = Integer.parseInt(ptfrom);
Message[0] = PTRemote.sendPTEmail(individualID, accountID, emailList, ptSubject,
ptContent, messageVO);
}
} else {
// generate the Previewed Template into a File.
try {
CvFileFacade cvf = new CvFileFacade();
CvFileHome homeFile = (CvFileHome)CVUtility.getHomeObject(
"com.centraview.file.CvFileHome", "CvFile");
CvFile remoteFile = homeFile.create();
remoteFile.setDataSource(dataSource);
CvFolderVO homeFld = remoteFile.getHomeFolder(individualID);
int rn = (new Random()).nextInt();
Calendar c = Calendar.getInstance();
java.util.Date dt = c.getTime();
DateFormat df = new SimpleDateFormat("MM_dd_yyyy");
String dateStamp = df.format(dt);
CvFileVO flvo = new CvFileVO();
flvo.setTitle("Print Template_" + rn);
flvo.setName("Template_" + "_" + rn + "_" + dateStamp + ".html");
Message[1] = "Template_" + "_" + rn + "_" + dateStamp + ".html";
flvo.setPhysicalFolder(homeFld.getFolderId());
flvo.setIsTemporary("NO");
flvo.setOwner(individualID);
flvo.setPhysical(CvFileVO.FP_PHYSICAL);
StringBuffer documentContent = new StringBuffer();
for (int i = 0; i < ptContent.size(); i++) {
documentContent.append(ptContent.get(i));
if (i != (ptContent.size() - 1)) {