001: /*
002: ====================================================================
003: Project Name: bugtracker
004: File Name: /src/com/espada/bugtracker/servlets/CreateProject.java
005: Author: Kishan Peiris <kishan@espadanet.com>
006: Description: Creates a new projects
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.logwriter.*;
020: import com.sr.espada.se.util.config.*;
021:
022: // webmacro resources
023: import org.webmacro.*;
024: import org.webmacro.broker.*;
025: import org.webmacro.resource.*;
026: import org.webmacro.servlet.WebContext;
027:
028: // servlet libraries
029: import javax.servlet.http.*;
030: import javax.servlet.*;
031:
032: // bugtracker java apps
033: import com.espada.bugtracker.app.*;
034:
035: public class CreateProject extends BTServlet {
036: protected void doAction(HttpServletRequest request,
037: HttpServletResponse response, WebContext c) {
038: projectNew(request, response, c);
039: };
040:
041: public String getInitialTemplate() {
042: return ("newproj.wm");
043: }
044:
045: /********************************** Start Of Method projectNew *********************************************/
046: /** Creates a new project...*/
047: private void projectNew(HttpServletRequest request,
048: HttpServletResponse response, WebContext c) {
049:
050: HttpSession session = request.getSession();
051:
052: String SuccessLoggedIn = (String) session
053: .getAttribute("loggedIn");
054:
055: boolean loggedIn = false;
056:
057: Project proj = null;
058:
059: int UID = ((Integer) session.getAttribute("UID")).intValue();
060:
061: String createName = request.getParameter("projname");
062:
063: if (SuccessLoggedIn != null) {
064: if (SuccessLoggedIn.equals("true")) {
065: loggedIn = true;
066:
067: defaultTemplate = "newproj.wm";
068:
069: c.put("USER", session.getAttribute("USER"));
070:
071: if (request.getParameter("add") != null) {
072: proj = Project.createProject(createName, UID);
073:
074: if (createName.equals(proj.getName())) {
075: c.put("errorId", "8");
076:
077: c.put("createName", createName);
078: c.put("proId", String.valueOf(proj.getPID()));
079:
080: defaultTemplate = "errorMesg.wm";
081:
082: // lets add all site-admins to this new project as well.
083: java.util.Vector usrs = User.getUsers();
084: for (int ctr = 0; ctr < usrs.size(); ctr++)
085: if (((User) usrs.get(ctr)).isAdmin())
086: ((User) usrs.get(ctr)).makeAdmin();
087:
088: }
089: }
090:
091: } else {
092:
093: loggedIn = false;
094:
095: defaultTemplate = "errorMesg.wm";
096:
097: c.put("errorId", "9");
098:
099: }
100: } else {
101:
102: defaultTemplate = "errorMesg.wm";
103:
104: c.put("errorId", "9");
105:
106: }
107:
108: c.put("loggedIn", (String) session.getAttribute("loggedIn"));
109: c.put("myRoleId", session.getAttribute("USERROLE"));
110:
111: } //end of method
112:
113: /********************************** End Of Method projectNew *********************************************/
114:
115: } //end of class
|