1 package hero.struts.actions; 2 3 import java.io.IOException ; 4 import javax.servlet.ServletException ; 5 import javax.servlet.http.HttpServletRequest ; 6 import javax.servlet.http.HttpSession ; 7 import javax.servlet.http.HttpServletResponse ; 8 import org.apache.struts.action.ActionError; 9 import org.apache.struts.action.ActionErrors; 10 import org.apache.struts.action.ActionForm; 11 import org.apache.struts.action.ActionMapping; 12 import org.apache.struts.action.ActionForward; 13 import java.util.*; 14 15 import hero.interfaces.*; 16 17 23 24 public class ProjectAction extends AbstStrutsActionBase 25 { 26 public boolean authenticate(String username, String password) 27 { 28 return(true); 29 } 30 38 public ActionForward perform(ActionMapping mapping, ActionForm form, 39 HttpServletRequest request, HttpServletResponse response) throws IOException , ServletException 40 { 41 ActionForward actionForward = mapping.findForward(ADMIN); 42 ActionErrors errors = new ActionErrors(); 44 45 String action = request.getParameter("action"); 46 HttpSession session = request.getSession(); 47 String project = (String )session.getAttribute("projectname"); 48 49 if (!isCancelled(request)) 50 { 51 if (action.equals("ProjectDetails")) 52 { 53 try{ 54 55 hero.interfaces.ProjectSessionLocalHome projecth = (ProjectSessionLocalHome)hero.interfaces.ProjectSessionUtil.getLocalHome(); 56 hero.interfaces.ProjectSessionLocal projectsession = projecth.create(); 57 projectsession.initProject(project); 58 59 60 request.getSession(true).setAttribute("project", projectsession); 61 request.getSession(true).setAttribute("proAct", "true"); 62 request.getSession(true).setAttribute("edit", "false"); 63 actionForward = mapping.findForward(PROJECT); 64 }catch(Exception e2){errors.add("project_error", new ActionError("error.projectdetails.mismatch"));actionForward = mapping.findForward(PROJECTDETAILS);} 65 } 66 if (action.equals("configproject")) { 67 try { 68 69 hero.interfaces.ProjectSessionLocalHome projecth = (ProjectSessionLocalHome)hero.interfaces.ProjectSessionUtil.getLocalHome(); 70 hero.interfaces.ProjectSessionLocal projectsession = projecth.create(); 71 projectsession.initProject(project); 72 session.setAttribute("hooks", new Vector(projectsession.getHooks())); 73 session.setAttribute("properties", new Vector(projectsession.getProperties())); 74 session.setAttribute("interHooks", new Vector(projectsession.getInterHooks())); 75 Collection users = projectsession.getUsers(); 76 Iterator iusers = users.iterator(); 77 78 Vector usersP = new Vector(); 79 Vector rolesP = new Vector(); 80 int i,j; 81 82 while(iusers.hasNext()) 83 { 84 String actualUser = (String )iusers.next(); 85 Collection uRoles = projectsession.getUserRoles(actualUser); 86 Collection pRoles = projectsession.getRoles(); 87 88 Iterator iuroles = uRoles.iterator(); 89 while(iuroles.hasNext()) 90 { 91 BnRoleLocal actualuRole = (BnRoleLocal)iuroles.next(); 92 Iterator iproles = pRoles.iterator(); 93 while(iproles.hasNext()) 94 { 95 BnRoleLocal actualpRole = (BnRoleLocal)iproles.next(); 96 if (actualuRole.getId() == actualpRole.getId()) 97 { 98 usersP.add(actualUser); 99 rolesP.add(actualuRole.getName()); 100 } 101 } 102 } 103 104 } 105 session.setAttribute("usersP", usersP); 106 session.setAttribute("rolesP", rolesP); 107 108 actionForward = mapping.findForward(CONFIGPROJECT); 109 }catch(Exception e2){errors.add("project_error", new ActionError("error.projectdetails.mismatch"));actionForward = mapping.findForward(PROJECTDETAILS);} 110 } 111 if (action.equals("viewproject")) 112 actionForward = mapping.findForward(PROJECT); 113 } 114 115 if (!errors.empty()) { 116 saveErrors(request, errors); 117 } 118 119 return (actionForward); 121 } 122 } 123
| Popular Tags
|