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.mailing;
034:
035: import org.libresource.Libresource;
036:
037: import org.libresource.forum.ForumConstants;
038: import org.libresource.forum.interfaces.LibresourceForumService;
039:
040: import org.libresource.kernel.KernelConstants;
041: import org.libresource.kernel.interfaces.KernelService;
042:
043: import org.libresource.mailing.MailingListConstant;
044: import org.libresource.mailing.ejb.model.MailingListResourceValue;
045: import org.libresource.mailing.interfaces.LibresourceMailingService;
046:
047: import org.libresource.web.Controller;
048:
049: import java.net.URI;
050:
051: import javax.servlet.http.HttpServletRequest;
052: import javax.servlet.http.HttpServletResponse;
053:
054: public class ViewMailController implements Controller {
055: public Object process(URI uri, HttpServletRequest request,
056: HttpServletResponse response) throws Exception {
057: KernelService kernelService = (KernelService) Libresource
058: .getService(KernelConstants.SERVICE);
059: LibresourceMailingService mailingService = (LibresourceMailingService) Libresource
060: .getService(MailingListConstant.SERVICE);
061: LibresourceForumService forumService = (LibresourceForumService) Libresource
062: .getService(ForumConstants.SERVICE);
063: MailingListResourceValue mailingList = mailingService
064: .getMailingList(uri);
065:
066: request.setAttribute("mail", mailingList.getMail() + "@"
067: + mailingService.getMailSuffix());
068: request.setAttribute("description", mailingList
069: .getDescription());
070:
071: if (mailingService.isSubscriber(uri)) {
072: request.setAttribute("isSubscriber", "true");
073: }
074:
075: String name = request.getParameter("mail");
076:
077: if ((name == null) || (name.trim().length() == 0)) {
078: return uri + "?action=archive";
079: }
080:
081: URI msgUri = new URI(uri.getPath() + "/" + name);
082:
083: try {
084: request.setAttribute("parent", forumService
085: .getMessage(kernelService.getParent(msgUri)));
086: request.setAttribute("parentPath", request.getQueryString()
087: .substring(0,
088: request.getQueryString().lastIndexOf("/")));
089: } catch (Exception e) {
090: //
091: }
092:
093: request
094: .setAttribute("message", forumService
095: .getMessage(msgUri));
096: request.setAttribute("body", forumService.getMessage(msgUri)
097: .getBody().replaceAll("\n", "\n\n"));
098:
099: int index = name.lastIndexOf("/");
100:
101: if (index < 0) {
102: index = 0;
103: }
104:
105: request.setAttribute("subTree", mailingService
106: .getMessagesTreeUnderMessage(uri, name));
107:
108: return "/pages/modules/mailing/viewMailingList.jsp";
109: }
110: }
|