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.IssueResourceValue;
039: import org.libresource.bugtracker.interfaces.LibresourceBugTrackerService;
040:
041: import org.libresource.files.ejb.model.FileResourceValue;
042:
043: import org.libresource.forum.ejb.model.MessageResourceValue;
044:
045: import org.libresource.kernel.KernelConstants;
046: import org.libresource.kernel.interfaces.KernelService;
047:
048: import org.libresource.web.Controller;
049:
050: import java.net.URI;
051:
052: import java.util.Arrays;
053: import java.util.Comparator;
054: import java.util.Vector;
055:
056: import javax.servlet.http.HttpServletRequest;
057: import javax.servlet.http.HttpServletResponse;
058:
059: public class IssueController implements Controller {
060: public Object process(URI uri, HttpServletRequest request,
061: HttpServletResponse response) throws Exception {
062: KernelService kernelService = (KernelService) Libresource
063: .getService(KernelConstants.SERVICE);
064: request.setAttribute("user", kernelService
065: .normalizeAbsoluteURIPath(kernelService
066: .getConnectedResource()));
067:
068: LibresourceBugTrackerService libresourceBugTrackerService = (LibresourceBugTrackerService) Libresource
069: .getService(BugTrackerConstants.SERVICE);
070:
071: IssueResourceValue issue = libresourceBugTrackerService
072: .getIssue(uri);
073: request.setAttribute("issue", issue);
074:
075: FileResourceValue[] files = (FileResourceValue[]) libresourceBugTrackerService
076: .listFilesInIssue(uri);
077: Comparator compFile = new Comparator() {
078: public int compare(Object f1, Object f2) {
079: if (!(f1 instanceof FileResourceValue)) {
080: throw new ClassCastException();
081: }
082:
083: return (((FileResourceValue) f1).getName())
084: .compareTo(((FileResourceValue) f2).getName());
085: }
086: };
087:
088: Arrays.sort(files, compFile);
089: request.setAttribute("files", files);
090:
091: Vector resolutions = libresourceBugTrackerService
092: .getListOfResolution();
093: request.setAttribute("resolutions", resolutions);
094:
095: MessageResourceValue[] comments = (MessageResourceValue[]) libresourceBugTrackerService
096: .listCommentsInIssue(uri);
097: request.setAttribute("comments", comments);
098:
099: if (request.getParameter("noaction") != null) {
100: return "/pages/modules/bugtracker/viewSimpleIssue.jsp";
101: }
102:
103: return "/pages/modules/bugtracker/viewIssue.jsp";
104: }
105: }
|