001: /**
002: * LibreSource
003: * Copyright (C) 2004-2008 Artenum SARL / INRIA
004: * http://www.libresource.org - contact@artenum.com
005: *
006: * This file is part of the LibreSource software,
007: * which can be used and distributed under license conditions.
008: * The license conditions are provided in the LICENSE.TXT file
009: * at the root path of the packaging that enclose this file.
010: * More information can be found at
011: * - http://dev.libresource.org/home/license
012: *
013: * Initial authors :
014: *
015: * Guillaume Bort / INRIA
016: * Francois Charoy / Universite Nancy 2
017: * Julien Forest / Artenum
018: * Claude Godart / Universite Henry Poincare
019: * Florent Jouille / INRIA
020: * Sebastien Jourdain / INRIA / Artenum
021: * Yves Lerumeur / Artenum
022: * Pascal Molli / Universite Henry Poincare
023: * Gerald Oster / INRIA
024: * Mariarosa Penzi / Artenum
025: * Gerard Sookahet / Artenum
026: * Raphael Tani / INRIA
027: *
028: * Contributors :
029: *
030: * Stephane Bagnier / Artenum
031: * Amadou Dia / Artenum-IUP Blois
032: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
033: */package org.libresource.web.controllers.bugtracker;
034:
035: import org.libresource.Libresource;
036:
037: import org.libresource.bugtracker.BugTrackerConstants;
038: import org.libresource.bugtracker.ejb.model.BugTrackerResourceValue;
039: import org.libresource.bugtracker.interfaces.LibresourceBugTrackerService;
040:
041: import org.libresource.kernel.KernelConstants;
042: import org.libresource.kernel.LibresourceSecurityException;
043: import org.libresource.kernel.interfaces.KernelService;
044:
045: import org.libresource.web.Controller;
046:
047: import java.net.URI;
048:
049: import java.util.Vector;
050:
051: import javax.servlet.http.HttpServletRequest;
052: import javax.servlet.http.HttpServletResponse;
053:
054: public class AddInBugTrackerController implements Controller {
055: public Object process(URI uri, HttpServletRequest request,
056: HttpServletResponse response) throws Exception {
057: if (request.getParameter("cancel") != null) {
058: return uri;
059: }
060:
061: KernelService kernelService = (KernelService) Libresource
062: .getService(KernelConstants.SERVICE);
063:
064: if (!kernelService.checkSecurity(uri,
065: BugTrackerConstants.SECURITY_POSTCOMMENT)) {
066: throw new LibresourceSecurityException(uri,
067: BugTrackerConstants.SECURITY_POSTCOMMENT);
068: }
069:
070: if (request.getParameter("summary") == null) {
071: LibresourceBugTrackerService libresourceBugTrackerService = (LibresourceBugTrackerService) Libresource
072: .getService(BugTrackerConstants.SERVICE);
073: Vector types = libresourceBugTrackerService.getListOfType();
074: request.setAttribute("types", types);
075:
076: Vector priorities = libresourceBugTrackerService
077: .getListOfPriority();
078: request.setAttribute("priorities", priorities);
079:
080: return "/pages/modules/bugtracker/addInBugTracker.jsp";
081: }
082:
083: if (request.getParameter("summary").trim().length() == 0) {
084: LibresourceBugTrackerService libresourceBugTrackerService = (LibresourceBugTrackerService) Libresource
085: .getService(BugTrackerConstants.SERVICE);
086: request.setAttribute("body", request.getParameter("body"));
087: request.setAttribute("type", request.getParameter("type"));
088: request.setAttribute("priority", request
089: .getParameter("priority"));
090: request.setAttribute("author", request
091: .getParameter("author"));
092:
093: Vector types = libresourceBugTrackerService.getListOfType();
094: request.setAttribute("types", types);
095:
096: Vector priorities = libresourceBugTrackerService
097: .getListOfPriority();
098: request.setAttribute("priorities", priorities);
099: request.setAttribute("error_summary",
100: "The summary of the issue is required");
101:
102: return "/pages/modules/bugtracker/addInBugTracker.jsp";
103: }
104:
105: LibresourceBugTrackerService libresourceBugTrackerService = (LibresourceBugTrackerService) Libresource
106: .getService(BugTrackerConstants.SERVICE);
107: BugTrackerResourceValue bugtracker = (BugTrackerResourceValue) libresourceBugTrackerService
108: .getBugTracker(uri);
109: String assignee = bugtracker.getAssignee();
110: libresourceBugTrackerService.addIssueToBugTracker(uri, request
111: .getParameter("summary"), request.getParameter("body"),
112: request.getParameter("type"), request
113: .getParameter("priority"), "UNRESOLVED");
114:
115: return uri;
116: }
117: }
|