* org.apache.struts.action.ActionForm,
* javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse)
*/
public ActionForward modify(ActionMapping mapping, ActionForm form,HttpServletRequest req, HttpServletResponse resp) {
BlogInteractionEnterOrEditForm f = (BlogInteractionEnterOrEditForm)form;
MessageResources resources = getResources(req);
if (f.getSortLabel() == null || f.getSortLabel().equals("")){
throw new InputException(resources.getMessage(locale, "smssvc.labelMustBeProvided"));
}
long commandEntryId = f.getCommandEntryId();
CommandEntryManager commandEntryManager = new CommandEntryManager(locale, session);
CommandEntry commandEntry = commandEntryManager.getCommandEntry(commandEntryId);
if (commandEntry == null || !(commandEntry instanceof BlogCommandEntry)){
throw new InputException(getResources(req).getMessage(locale, "smssvc.editedInteractionDoesNotExistAnymore")); // may have been deleted
}
BlogCommandEntry blogCommandEntry = (BlogCommandEntry)commandEntry;
checkAccessRights(req, blogCommandEntry.getGroup());
commandEntryManager.evict(blogCommandEntry); // do not modify in this session yet (might be erroneous)
blogCommandEntry.setSortLabel(f.getSortLabel());
if (f.getBlogId() > 0) {
BlogManager blogMgr = new BlogManager(locale, session);
Blog blog = blogMgr.getBlog(f.getBlogId());
if (blog == null) {
throw new InputException(resources.getMessage(locale, "smssvc.selectedBlogNotFound"));
}
blogCommandEntry.setBlog(blog);
} else {
blogCommandEntry.setBlog(null);
}
blogCommandEntry.setTags(f.getTags());
blogCommandEntry.setTitle(f.getTitle());
blogCommandEntry.setContent(f.getContent());
blogCommandEntry.setMaxImageWidth(f.getMaxImageWidth()==null||f.getMaxImageWidth().length()==0?null:Integer.parseInt(f.getMaxImageWidth()));
LOGGER.info("User " + UserManagerBase.toString(webUser) + ": blog interaction entry with id: " + commandEntryId + " has been modified");
setCommandEntryInRequest(req, blogCommandEntry);
return mapping.findForward("modified");
}