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 javax.servlet.http.HttpServletRequest;
050: import javax.servlet.http.HttpServletResponse;
051:
052: public class EditBugTrackerController implements Controller {
053: public Object process(URI uri, HttpServletRequest request,
054: HttpServletResponse response) throws Exception {
055: if (request.getParameter("cancel") != null) {
056: return uri;
057: }
058:
059: KernelService kernelService = (KernelService) Libresource
060: .getService(KernelConstants.SERVICE);
061:
062: if (!kernelService.checkSecurity(uri,
063: KernelConstants.SECURITY_UPDATE)) {
064: throw new LibresourceSecurityException(uri,
065: KernelConstants.SECURITY_UPDATE);
066: }
067:
068: if (request.getParameter("name") == null) {
069: LibresourceBugTrackerService libresourceBugTrackerService = (LibresourceBugTrackerService) Libresource
070: .getService(BugTrackerConstants.SERVICE);
071: BugTrackerResourceValue bugTrackerResourceValue = libresourceBugTrackerService
072: .getBugTracker(uri);
073: request.setAttribute("name", bugTrackerResourceValue
074: .getName());
075: request.setAttribute("description", bugTrackerResourceValue
076: .getDescription());
077: request.setAttribute("assignee", bugTrackerResourceValue
078: .getAssignee());
079:
080: return "/pages/modules/bugtracker/editBugTracker.jsp";
081: }
082:
083: if (request.getParameter("name").trim().length() == 0) {
084: request.setAttribute("description", request
085: .getParameter("description"));
086: request.setAttribute("assignee", request
087: .getParameter("assignee"));
088: request.setAttribute("error_name",
089: "The name of the bugtracker is required");
090:
091: return "/pages/modules/bugtracker/editBugTracker.jsp";
092: }
093:
094: boolean validAssignee = kernelService.exist(new URI(request
095: .getParameter("assignee")));
096:
097: if (!validAssignee) {
098: request.setAttribute("name", request.getParameter("name"));
099: request.setAttribute("description", request
100: .getParameter("description"));
101: request.setAttribute("assignee", request
102: .getParameter("assignee"));
103: request.setAttribute("error_assignee",
104: "This user uri is not a valid user uri");
105:
106: return "/pages/modules/bugtracker/editBugTracker.jsp";
107: }
108:
109: LibresourceBugTrackerService libresourceBugTrackerService = (LibresourceBugTrackerService) Libresource
110: .getService(BugTrackerConstants.SERVICE);
111: libresourceBugTrackerService.editBugTracker(uri, request
112: .getParameter("name"), request
113: .getParameter("description"), request
114: .getParameter("assignee"));
115:
116: return uri;
117: }
118: }
|