1 package org.contineo.actions.admin.group; 2 3 import java.util.Collection ; 4 import javax.servlet.http.HttpServletRequest ; 5 import javax.servlet.http.HttpServletResponse ; 6 import javax.servlet.http.HttpSession ; 7 import org.apache.log4j.Level; 8 import org.apache.log4j.Logger; 9 import org.apache.struts.action.Action; 10 import org.apache.struts.action.ActionForm; 11 import org.apache.struts.action.ActionForward; 12 import org.apache.struts.action.ActionMapping; 13 import org.contineo.admin.dao.GroupDAO; 14 import org.contineo.admin.dao.MenuDAO; 15 import org.contineo.core.LoggingManager; 16 import org.contineo.core.SessionManagement; 17 import org.contineo.forms.SelectGroupForm; 18 24 public class SelectGroupAction extends Action { 25 26 30 private Logger logger; 31 32 33 34 public SelectGroupAction() { 35 logger = LoggingManager.getLogger(this.getClass()); 36 } 37 38 public ActionForward execute(ActionMapping mapping, 39 ActionForm form, HttpServletRequest request, 40 HttpServletResponse response) { 41 ActionForward actionForward = new ActionForward(); 42 HttpSession session = request.getSession(); 43 if (SessionManagement.isValid(session)) { 44 try { 45 String username = (String )session.getAttribute("authuser"); 46 MenuDAO mdao = new MenuDAO(); 47 if (mdao.isReadEnable(12, username)) { 48 SelectGroupForm sgform = (SelectGroupForm)form; 49 String groupname = sgform.getGroupName(); 50 GroupDAO dao = new GroupDAO(); 51 Collection coll = null; 52 if (groupname == null || groupname.trim().equals("")) { 53 coll = dao.findAll(); 54 } else { 55 coll = dao.findByGroupName(groupname); 56 } 57 request.setAttribute("groups", coll); 58 actionForward = mapping.findForward("showgroup"); 59 } else 60 actionForward = mapping.findForward("noaccess"); 61 } catch (Exception e) { 62 if (logger.isEnabledFor(Level.ERROR)) 63 logger.error(e.getMessage()); 64 actionForward = mapping.findForward("error"); 65 } 66 } else 67 actionForward = mapping.findForward("invalid"); 68 return actionForward; 69 } 70 } 71 | Popular Tags |