001: /*
002: ====================================================================
003: Project Name: bugtracker
004: File Name: /src/com/espada/bugtracker/servlets/EditUser.java
005: Author: Kishan Peiris <kishan@espadanet.com>
006: Description: An existing user can change personal details
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 EditUser 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: protected void doAction(HttpServletRequest request,
044: HttpServletResponse response, WebContext c) {
045: edit(request, response, c);
046: };
047:
048: /********************************** Start Of Method edit *************************************************/
049: /** Edit user details...*/
050: private void edit(HttpServletRequest request,
051: HttpServletResponse response, WebContext c) {
052: HttpSession session = request.getSession();
053: String SuccessLoggedIn = (String) session
054: .getAttribute("loggedIn");
055: int UID;
056: boolean loggedIn = false;
057: boolean update = false;
058:
059: if (SuccessLoggedIn != null) {
060:
061: if (SuccessLoggedIn.equals("true")) {
062: loggedIn = true;
063:
064: UID = ((Integer) session.getAttribute("UID"))
065: .intValue();
066:
067: User b = new User(UID);
068:
069: defaultTemplate = "editUser.wm";
070:
071: c.put("USER", (String) session.getAttribute("USER"));
072:
073: c.put("UROLE", String.valueOf(session
074: .getAttribute("UROLE")));
075:
076: //c.put("currentProject",session.getAttribute("currentProject"));
077:
078: c.put("b", b);
079:
080: if (request.getParameter("add") != null) {
081:
082: b.username = request.getParameter("username");
083: b.email = request.getParameter("email");
084: b.password = request.getParameter("pwd");
085: update = b.update();
086:
087: if (update) {
088: c.put("errorId", "13");
089: defaultTemplate = "errorMesg.wm";
090: } else {
091: c.put("errorId", "14");
092: defaultTemplate = "errorMesg.wm";
093: }
094:
095: }
096: } else {
097:
098: loggedIn = false;
099:
100: defaultTemplate = "errorMesg.wm";
101:
102: c.put("errorId", "9");
103:
104: }
105: } else {
106:
107: loggedIn = false;
108:
109: defaultTemplate = "errorMesg.wm";
110:
111: c.put("errorId", "9");
112:
113: }
114: c.put("myRoleId", session.getAttribute("USERROLE"));
115:
116: } //end of method
117:
118: /********************************** End Of Method edit *************************************************/
119: protected String getInitialTemplate() {
120: return ("editUser.wm");
121: }
122:
123: } //end of class
|