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.webapp.action.core.BaseAction; 22 import com.blandware.atleap.webapp.form.GroupForm; 23 import com.blandware.atleap.webapp.util.core.WebappConstants; 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 54 public final class CallUpdateGroupAction extends BaseAction { 55 64 public ActionForward execute(ActionMapping mapping, ActionForm form, 65 HttpServletRequest request, HttpServletResponse response) throws Exception { 66 67 if ( isCancelled(request) ) { 68 return mapping.findForward("listGroups"); 69 } 70 71 if (!request.isUserInRole("core-group-update")) { 72 response.sendError(HttpServletResponse.SC_FORBIDDEN); 73 return null; 74 } 75 76 GroupForm groupForm = (GroupForm) form; 77 String groupName = null; 78 if ( groupForm.getName() != null ) { 79 groupName = groupForm.getName(); 80 } else if ( request.getSession().getAttribute(WebappConstants.GROUP_NAME_KEY) != null ) { 81 groupName = (String ) request.getSession().getAttribute(WebappConstants.GROUP_NAME_KEY); 82 } else { 83 if ( log.isWarnEnabled() ) { 84 log.warn("Missing group name. Returning to list..."); 85 } 86 return mapping.findForward("listGroups"); 87 } 88 89 GroupManager groupManager = (GroupManager) getBean(Constants.GROUP_MANAGER_BEAN); 90 Group group = groupManager.retrieveGroup(groupName); 91 if ( group == null ) { 92 ActionMessages errors = new ActionMessages(); 94 errors.add("groupNotFound", new ActionMessage("core.group.errors.notFound")); 95 saveErrors(request, errors); 96 return mapping.findForward("listGroups"); 97 } 98 99 WebappUtil.copyProperties(groupForm, group, request); 100 101 saveToken(request); 103 return mapping.findForward("updateGroup"); 104 } 105 106 } | Popular Tags |