public void _saveCommunication(ActionRequest req, ActionResponse res,PortletConfig config,ActionForm form, User user)
throws Exception {
Communication c = (Communication) req.getAttribute(WebKeys.COMMUNICATION_EDIT);
CommunicationsForm cfform = (CommunicationsForm) form;
BeanUtils.copyProperties(req.getAttribute(WebKeys.COMMUNICATION_EDIT), cfform);
if(cfform.getModDate() == null){
c.setModDate(new java.util.Date());
}
c.setModifiedBy(user.getUserId());
_checkUserPermissions(c, user, PERMISSION_WRITE);
if (req.getParameter("typeContent").equals("HTMLPage") &&
!cfform.getCommunicationType().equalsIgnoreCase("alert")) {
c.setTextMessage("");
}
if (!cfform.getCommunicationType().equalsIgnoreCase("email")) {
c.setFromEmail("");
c.setFromName("");
c.setEmailSubject("");
c.setHtmlPage(null);
cfform.setHtmlPage(null);
}
if (!cfform.getCommunicationType().equalsIgnoreCase("external")) {
c.setTrackBackLinkInode(null);
c.setExternalCommunicationIdentifier("");
cfform.setTrackBackLinkInode(null);
}
try {
// HibernateUtil.saveOrUpdate(c);
HibernateUtil.saveOrUpdate(c);
} catch (DotHibernateException dhe) {
SessionMessages.add(req, "error", "error.communications.not-saved");
//setForward(req,"portlet.ext.communications.edit_communication");
throw new ActionException(dhe.getMessage());
}
// wipe the old HTML page entries
HTMLPage page = (HTMLPage) InodeFactory.getChildOfClass(c, HTMLPage.class);
if (InodeUtils.isSet(page.getInode()))
c.deleteChild(page);
if (req.getParameter("typeContent").equals("HTMLPage")) {
//try to get the Communication's page
if (InodeUtils.isSet(cfform.getHtmlPage())) {
page = (HTMLPage) InodeFactory.getInode(String.valueOf(cfform.getHtmlPage()), HTMLPage.class);
if (InodeUtils.isSet(page.getInode())) {
c.addChild(page);
c.setHtmlPage(page.getIdentifier());
}
}
}
// wipe the old VirtualLink entries
VirtualLink vl = (VirtualLink) InodeFactory.getChildOfClass(c, VirtualLink.class);
if (InodeUtils.isSet(vl.getInode()))
c.deleteChild(vl);
//try to get the Communication's virtual link
if (InodeUtils.isSet(cfform.getTrackBackLinkInode())) {
vl = VirtualLinkFactory.getVirtualLink(String.valueOf(cfform.getTrackBackLinkInode()));
if (InodeUtils.isSet(vl.getInode())) {
c.addChild(vl);
c.setTrackBackLinkInode(vl.getInode());
}
}