1 16 package com.blandware.atleap.webapp.action.core.group; 17 18 import com.blandware.atleap.common.Constants; 19 import com.blandware.atleap.model.core.Group; 20 import com.blandware.atleap.service.core.GroupManager; 21 import com.blandware.atleap.service.exception.BeanAlreadyExistsException; 22 import com.blandware.atleap.webapp.action.core.BaseAction; 23 import com.blandware.atleap.webapp.form.GroupForm; 24 import com.blandware.atleap.webapp.util.core.WebappUtil; 25 import org.apache.struts.action.ActionForm; 26 import org.apache.struts.action.ActionForward; 27 import org.apache.struts.action.ActionMapping; 28 import org.apache.struts.action.ActionMessage; 29 import org.apache.struts.action.ActionMessages; 30 31 import javax.servlet.http.HttpServletRequest ; 32 import javax.servlet.http.HttpServletResponse ; 33 34 57 public final class CreateGroupAction extends BaseAction { 58 67 public ActionForward execute(ActionMapping mapping, ActionForm form, 68 HttpServletRequest request, HttpServletResponse response) throws Exception { 69 70 if ( !isCancelled(request) ) { 71 72 GroupForm groupForm = (GroupForm) form; 73 Group group = new Group(); 74 WebappUtil.copyProperties(group, groupForm, request); 75 group.setFixed(Boolean.FALSE); 76 GroupManager groupManager = (GroupManager) getBean(Constants.GROUP_MANAGER_BEAN); 77 try { 78 groupManager.createGroup(group); 79 } catch ( BeanAlreadyExistsException e ) { 80 ActionMessages errors = new ActionMessages(); 82 errors.add("groupAlreadyExists", new ActionMessage("core.group.errors.alreadyExists")); 83 saveErrors(request, errors); 84 saveToken(request); 85 return mapping.getInputForward(); 86 } 87 } 88 return mapping.findForward("listGroups"); 89 } 90 } | Popular Tags |