001: /*
002: ====================================================================
003: Project Name: bugtracker
004: File Name: /src/com/espada/bugtracker/servlets/NewBugDetails.java
005: Author: Kishan Peiris <kishan@espadanet.com>
006: Description: Create's new bugs for a selected project
007: CVS Repository: goliath:/projects/repository/cvsroot/
008: CVS Module: bugtracker
009: Version: CVS $Id: $
010: ====================================================================
011:
012: ====================================================================
013: Copyright (C) 2001, Silk Road (Pvt.) Ltd.
014: ====================================================================
015: */
016:
017: package com.espada.bugtracker.servlets;
018:
019: import com.sr.espada.se.util.config.*;
020: import com.sr.espada.se.util.logwriter.*;
021: import java.util.*;
022:
023: // webmacro resources
024: import org.webmacro.*;
025: import org.webmacro.broker.*;
026: import org.webmacro.resource.*;
027: import org.webmacro.servlet.WebContext;
028:
029: // servlet libraries
030: import javax.servlet.http.*;
031: import javax.servlet.*;
032:
033: // bugtracker java apps
034: import com.espada.bugtracker.app.*;
035:
036: public class NewBugDetails extends BTServlet {
037:
038: /**
039: * This is the core WebMacro interface which we use to create Contexts,
040: * load Templates, and begin other WebMacro operations.
041: */
042:
043: /** the default template to use **/
044: protected String getInititalTemplate() {
045: return ("newBug.wm");
046: }
047:
048: private boolean added = false;
049:
050: protected void doAction(HttpServletRequest request,
051: HttpServletResponse response, WebContext c) {
052: bugDetails(request, response, c);
053: }
054:
055: /********************************** Start Of Method bugDetails *********************************************/
056: /** Adding new bug details....*/
057:
058: private void bugDetails(HttpServletRequest request,
059: HttpServletResponse response, WebContext c) {
060: HttpSession session = request.getSession();
061:
062: String SuccessLoggedIn = (String) session
063: .getAttribute("loggedIn");
064:
065: boolean loggedIn = false;
066:
067: String stat = new String();
068:
069: int i;
070:
071: if (SuccessLoggedIn != null) {
072: if (SuccessLoggedIn.equals("true")) {
073: defaultTemplate = "newBug.wm";
074:
075: loggedIn = true;
076:
077: c.put("USER", session.getAttribute("USER"));
078:
079: c.put("currentProject", session
080: .getAttribute("currentProject"));
081: c.put("waite", String.valueOf(session
082: .getAttribute("page")));
083:
084: /*******************************************************************************************/
085: /*******************
086: Creating bug severity array of objects
087: ********************/
088:
089: Severity server = new Severity(); //object of severity
090: Vector sev = Severity.getSeverities(); //vector of severity
091: Vector s = new Vector(); //to copy as an array of object severity
092:
093: for (i = 0; i < sev.size(); i++) //number of selected items
094: {
095:
096: server = ((Severity) sev.get(i)); //assigning lements
097:
098: s.addElement(server); //adding all objects
099:
100: }
101:
102: Severity pros[] = new Severity[s.size()];//severity type array
103: s.copyInto(pros); //cope all into new array object pros
104:
105: /*******************************************************************************************/
106: /*******************
107: Creating bug status array of objects
108: ********************/
109:
110: Vector stv = Status.getStatusList(true);
111: Vector ss = new Vector();
112: Status bstat = new Status();
113:
114: for (i = 0; i < stv.size(); i++) {
115:
116: bstat = ((Status) stv.get(i));
117:
118: ss.addElement(bstat);
119:
120: }
121:
122: Status statObj[] = new Status[ss.size()];
123: ss.copyInto(statObj);
124:
125: c.put("pros", pros);
126: c.put("statObj", statObj);
127:
128: /*******************************************************************************************/
129:
130: if (request.getParameter("add") != null) {
131: //assign all the parameter values to locale variables
132: String title = request.getParameter("title");
133: String description = request
134: .getParameter("description");
135: int rep = request.getParameter("reproducable") == null ? 0
136: : 1;
137: int status = Integer.parseInt(request
138: .getParameter("status"));
139: int severity = Integer.parseInt(request
140: .getParameter("severity"));
141: int user = ((Integer) session.getAttribute("UID"))
142: .intValue();
143: int pid = Integer.parseInt(request
144: .getParameter("projID"));
145: String bugURL = request.getParameter("bugURL");
146: String browserVersion = request
147: .getParameter("browserVersion");
148:
149: stat = Bug.createBug(title, description, rep,
150: status, severity, user, pid, bugURL,
151: browserVersion);
152:
153: if (stat != null) {
154: c.put("errorId", "11");
155:
156: defaultTemplate = "errorMesg.wm";
157: }
158: }
159:
160: /*********************************************************************************************/
161:
162: } else {
163:
164: loggedIn = false;
165:
166: defaultTemplate = "errorMesg.wm";
167:
168: c.put("errorId", "9");
169:
170: }
171: } else {
172:
173: loggedIn = false;
174:
175: defaultTemplate = "errorMesg.wm";
176:
177: c.put("errorId", "9");
178:
179: }
180:
181: c.put("loggedIn", String.valueOf(loggedIn));
182: c.put("myRoleId", session.getAttribute("USERROLE"));
183:
184: } //end of method
185:
186: /********************************** End Of Method bugDetails *********************************************/
187:
188: } //end of class
|