AdminBean adminBean = getAdminBean(httpServletRequest);
Site site = adminBean.getSite();
initSiteProfiles(form, adminBean.getSite());
Content content = new Content();
if (!insertMode) {
content = ContentDAO.load(site.getSiteId(), Format.getLong(form.getContentId()));
}
ActionMessages errors = validate(form, site.getSiteId(), insertMode);
if (errors.size() != 0) {
saveMessages(httpServletRequest, errors);
createAdditionalInfo(adminBean, content, form);
return mapping.findForward("error");
}
if (insertMode) {
content.setSite(site);
content.setContentRating(new Float(0));
content.setContentRatingCount(new Integer(0));
content.setContentHitCounter(new Integer(0));
content.setRecCreateBy(adminBean.getUser().getUserId());
content.setRecCreateDatetime(new Date(System.currentTimeMillis()));
}
if (form.isSiteProfileClassDefault()) {
saveDefault(content, form, adminBean);
form.setRecUpdateBy(content.getRecUpdateBy());
form.setRecUpdateDatetime(Format.getFullDatetime(content.getRecUpdateDatetime()));
User user = adminBean.getUser();
content.setUser(user);
if (insertMode) {
em.persist(content);
form.setContentId(Format.getLong(content.getContentId()));
}
else {
// em.update(content);
}
}
else {
saveLanguage(content, form, adminBean);
}
CategorySearchUtil.contentDescSearchUpdate(content, site, adminBean);
Iterator<?> iterator = content.getMenus().iterator();
while (iterator.hasNext()) {
Menu menu = (Menu) iterator.next();
CacheDAO.removeByKeyPrefix(site.getSiteId(), Constants.CACHE_MENU + "." + menu.getMenuSetName());
}
Indexer.getInstance(site.getSiteId()).updateContent(content);