001: /*
002: ====================================================================
003: Project Name: bugtracker
004: File Name: /src/com/espada/bugtracker/servlets/AssignProjects.java
005: Author: Kishan Peiris <kishan@espadanet.com>
006: Description: List users and their user roles base on a project
007: CVS Repository: goliath:/projects/repository/cvsroot/
008: CVS Module: bugtracker
009: Version: CVS $Id: AssignProjects.java,v 1.6 2001/04/16 09:26:58 manik Exp $
010: ====================================================================
011:
012: */
013:
014: package com.espada.bugtracker.servlets;
015:
016: import com.sr.espada.se.util.config.*;
017: import com.sr.espada.se.util.logwriter.*;
018: import java.util.*;
019:
020: // webmacro resources
021: import org.webmacro.*;
022: import org.webmacro.broker.*;
023: import org.webmacro.resource.*;
024: import org.webmacro.servlet.WebContext;
025:
026: // servlet libraries
027: import javax.servlet.http.*;
028: import javax.servlet.*;
029:
030: // bugtracker java apps
031: import com.espada.bugtracker.app.*;
032:
033: public class AssignProjects extends BTServlet {
034:
035: /**
036: * This is the core WebMacro interface which we use to create Contexts,
037: * load Templates, and begin other WebMacro operations.
038: */
039:
040: /**************************** Start Of Method listProjectsUsers ********************************************/
041: /** List all available projects...*/
042:
043: protected void doAction(HttpServletRequest request,
044: HttpServletResponse response, WebContext c) {
045: defaultTemplate = "assignProjects.wm";
046: HttpSession session = request.getSession();
047: String SuccessLoggedIn = (String) session
048: .getAttribute("loggedIn");
049: String pageLocation = new String();
050: boolean loggedIn = false;
051: int userrole = 0;
052: int TotalUsers = 0;
053: int proId = 0;
054: int roleId = 0;
055: if (SuccessLoggedIn != null) {
056: if (SuccessLoggedIn.equals("true")) {
057: defaultTemplate = "assignProjects.wm";
058: int UID = ((Integer) session.getAttribute("UID"))
059: .intValue();
060: loggedIn = true;
061: c.put("USER", session.getAttribute("USER"));
062:
063: /***************** List all Projects *************/
064: Vector v = (Vector) session.getAttribute("PROJROLES");
065: roleId = Integer.parseInt((String) session
066: .getAttribute("USERROLE"));
067:
068: if (v.size() > 0) {
069: proId = (request.getParameter("proId") != null) ? Integer
070: .parseInt(request.getParameter("proId"))
071: : proId;
072: Vector r = Roles.getAllRoles(roleId);
073:
074: /***************** List all Users and Roles for a selected Project *************/
075:
076: if (request.getParameter("add") != null) {
077: Vector _p = User.getUserRolesByProject(proId);
078: TotalUsers = _p.size();
079: c.put("users", _p);
080: }
081:
082: c.put("projects", v);
083: c.put("Uroles", r);
084: c.put("proId", String.valueOf(proId));
085: c.put("AllUsers", String.valueOf(TotalUsers));
086:
087: } else {
088: defaultTemplate = "errorMesg.wm";
089: c.put("errorId", "23");
090: LogWriter.write("No avbl projects.");
091:
092: }
093:
094: } else {
095: loggedIn = false;
096: defaultTemplate = "errorMesg.wm";
097: c.put("errorId", "9");
098:
099: }
100:
101: } else {
102: loggedIn = false;
103: defaultTemplate = "errorMesg.wm";
104: c.put("errorId", "9");
105: }
106:
107: c.put("loggedIn", String.valueOf(loggedIn));
108: c.put("USER", session.getAttribute("USER"));
109: c.put("myRoleId", session.getAttribute("USERROLE"));
110:
111: } //end of method
112:
113: /**************************** End Of Method listProjectsUsers ********************************************/
114:
115: } //end of class
|