001: /*
002: ====================================================================
003: Project Name: bugtracker
004: File Name: /src/com/espada/bugtracker/servlets/ViewBugDetails.java
005: Author: Kishan Peiris <kishan@espadanet.com>
006: Description: View bug details
007: CVS Repository: goliath:/projects/repository/cvsroot/
008: CVS Module: bugtracker
009: Version: CVS $Id: $
010: ====================================================================
011: */
012:
013: package com.espada.bugtracker.servlets;
014:
015: import com.sr.espada.se.util.config.*;
016: import com.sr.espada.se.util.logwriter.*;
017: import com.sr.espada.se.util.mail.*;
018:
019: // webmacro resources
020: import org.webmacro.*;
021: import org.webmacro.broker.*;
022: import org.webmacro.resource.*;
023: import org.webmacro.servlet.WebContext;
024:
025: // servlet libraries
026: import javax.servlet.http.*;
027: import javax.servlet.*;
028:
029: // java library
030: import javax.mail.MessagingException;
031: import java.util.*;
032:
033: // bugtracker java apps
034: import com.espada.bugtracker.app.*;
035:
036: public class ViewBugDetails extends BTServlet {
037:
038: /** the default template to use **/
039: public String getInitialTemplate() {
040: return ("viewBug.wm");
041: }
042:
043: protected void doAction(HttpServletRequest request,
044: HttpServletResponse response, WebContext c) {
045: bugDetails(request, response, c);
046: }
047:
048: /**************************** Start Of Method bugDetails ********************************************/
049: /** View bug details of a selected project */
050:
051: public void bugDetails(HttpServletRequest request,
052: HttpServletResponse response, WebContext c) {
053: HttpSession session = request.getSession();
054:
055: String SuccessLoggedIn = (String) session
056: .getAttribute("loggedIn");
057:
058: boolean loggedIn = false;
059: String update = new String();
060:
061: if (SuccessLoggedIn != null) {
062: if (SuccessLoggedIn.equals("true")) {
063: defaultTemplate = "viewBug.wm";
064:
065: loggedIn = true;
066:
067: c.put("USER", session.getAttribute("USER"));
068:
069: c.put("currentProject", session
070: .getAttribute("currentProject"));
071:
072: c.put("waite", String.valueOf(session
073: .getAttribute("page")));
074:
075: /*******************************************************************************************/
076: /*******************
077: Creating bug severity array of objects
078: ********************/
079:
080: Vector sev = Severity.getSeverities(); //vector of severity
081:
082: /*******************************************************************************************/
083: /*******************
084: Creating bug status array of objects
085: ********************/
086:
087: Vector stv = Status.getStatusList(false);
088:
089: /*******************************************************************************************/
090: /*******************
091: Required parameters from WebMacro file
092: *******************/
093:
094: Bug b = new Bug(Integer.parseInt(request
095: .getParameter("bid")));
096:
097: String To = request.getParameter("repby");
098: String repEmail = request.getParameter("repemail");
099: String solution = request.getParameter("solution");
100: String title = request.getParameter("title");
101:
102: String emailSolution = new String();
103: String senderEmail = (String) session
104: .getAttribute("EMAIL");
105: String senderName = (String) session
106: .getAttribute("USER");
107:
108: c.put("b", b);
109: c.put("pros", sev);
110: c.put("statObj", stv);
111: c.put("RoleID", (String) session.getAttribute("PUR"));
112:
113: LogWriter.write("Add value : "
114: + request.getParameter("add"));
115:
116: /*if(request.getParameter("removeBug") != null)
117: {
118: if( b.delete() )
119: {
120: defaultTemplate = "errorMesg.wm";
121: c.put("errorId","22");
122: }
123: }
124: else */
125:
126: if (request.getParameter("add") != null) {
127: b.detail = request.getParameter("description");
128: b.reproduced = (request
129: .getParameter("reproducable") != null);
130: b.bugURL = request.getParameter("bugURL");
131: b.browserVersion = request
132: .getParameter("browserVersion");
133: b.status = new Status(Integer.parseInt(request
134: .getParameter("status")));
135: b.severity = new Severity(Integer.parseInt(request
136: .getParameter("severity")));
137:
138: update = b.update();
139:
140: if (update != null) {
141: c.put("errorId", "12");
142:
143: defaultTemplate = "errorMesg.wm";
144: LogWriter.write("Role is "
145: + session.getAttribute("PUR"));
146:
147: if (!solution.equals("Empty")) {
148:
149: emailSolution = "Hello.\n\nYour bug details at BUGTRACKER is as follows:\nBug ID :"
150: + b.bid
151: + "\n\nBug Description :"
152: + request
153: .getParameter("description")
154: + "\n\nSolution :"
155: + solution + "\n\nThank you.";
156:
157: try {
158: SimpleEmail SE = new SimpleEmail(
159: ConfigFactory.getInstance());
160: SE.setMsg(emailSolution);
161: SE.setFrom(senderEmail,
162: "BUGTRACKER APPLICATION :"
163: + senderName);
164:
165: //no-reply@infomutual.com", "BUGTRACKER APPLICATION"
166:
167: SE.addTo(repEmail, To);
168: SE.setSubject("Solution to a bug");
169: SE.send();
170:
171: c.put("repTo", To);
172: c.put("errorId", "15");
173: } catch (MessagingException e) {
174: c.put("errorId", "5");
175: } catch (ConfigFileMissingException ex) {
176: System.out.println("File Missing....!");
177: }
178:
179: c.put("repTo", To);
180: c.put("errorId", "15");
181: }
182:
183: }
184:
185: }
186:
187: } else {
188: loggedIn = false;
189:
190: defaultTemplate = "errorMesg.wm";
191:
192: c.put("errorId", "9");
193: }
194: } else {
195: loggedIn = false;
196:
197: defaultTemplate = "errorMesg.wm";
198:
199: c.put("errorId", "9");
200: }
201:
202: c.put("loggedIn", String.valueOf(loggedIn));
203: c.put("update", update);
204: c.put("myRoleId", session.getAttribute("USERROLE"));
205:
206: } //end of method
207:
208: public void deleteAbug(HttpServletRequest request,
209: HttpServletResponse response, WebContext c) {
210: HttpSession session = request.getSession();
211:
212: String SuccessLoggedIn = (String) session
213: .getAttribute("loggedIn");
214:
215: boolean loggedIn = false;
216: String update = new String();
217:
218: if (SuccessLoggedIn != null) {
219: if (SuccessLoggedIn.equals("true")) {
220: defaultTemplate = "viewBug.wm";
221:
222: loggedIn = true;
223:
224: c.put("USER", session.getAttribute("USER"));
225:
226: c.put("currentProject", session
227: .getAttribute("currentProject"));
228:
229: c.put("waite", String.valueOf(session
230: .getAttribute("page")));
231:
232: Bug b = new Bug(Integer.parseInt(request
233: .getParameter("bid")));
234:
235: if (b.delete()) {
236: defaultTemplate = "errorMesg.wm";
237: c.put("errorId", "22");
238: }
239:
240: } else {
241: loggedIn = false;
242:
243: defaultTemplate = "errorMesg.wm";
244:
245: c.put("errorId", "9");
246: }
247: } else {
248: loggedIn = false;
249:
250: defaultTemplate = "errorMesg.wm";
251:
252: c.put("errorId", "9");
253: }
254:
255: c.put("loggedIn", String.valueOf(loggedIn));
256: c.put("myRoleId", session.getAttribute("USERROLE"));
257:
258: } //end of method
259: /**************************** End Of Method bugDetails ********************************************/
260:
261: } //end of class
|