HttpSession session = request.getSession();
UserObject userObject = (UserObject)session.getAttribute("userobject");
int individualID = userObject.getIndividualID(); // logged in user
ActionErrors allErrors = new ActionErrors();
String forward = "closeWindow";
String errorForward = "errorOccurred";
// "newMailFolderForm", defined in struts-config-email.xml
DynaActionForm emailForm = (DynaActionForm)form;
try
{
MailHome home = (MailHome)CVUtility.getHomeObject("com.centraview.mail.MailHome", "Mail");
Mail remote = (Mail)home.create();
remote.setDataSource(dataSource);
// TODO: validate input;
MailFolderVO newFolder = new MailFolderVO();
Integer parentID = (Integer)emailForm.get("parentID");
Integer accountID = (Integer)emailForm.get("accountID");
String folderName = (String)emailForm.get("folderName");
newFolder.setParentID(parentID.intValue());
newFolder.setEmailAccountID(accountID.intValue());
newFolder.setFolderName(folderName);
newFolder.setFolderType(MailFolderVO.USER_FOLDER_TYPE);
int newFolderID = remote.addEmailFolder(newFolder, true);
if (newFolderID < 1)
{
forward = errorForward;
allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.freeForm", "The email folder could not be created. Please make sure all fields are filled in and try again. Also make sure you have privileges to create folders on your email server."));
this.saveErrors(request, allErrors);
}else{
emailForm.set("closeWindow", new Boolean(true));
}