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.kernel.KernelConstants;
038: import org.libresource.kernel.interfaces.KernelService;
039:
040: import org.libresource.mailing.MailingListConstant;
041: import org.libresource.mailing.ejb.model.MailingListResourceValue;
042: import org.libresource.mailing.interfaces.LibresourceMailingService;
043:
044: import org.libresource.membership.MembershipConstants;
045: import org.libresource.membership.ejb.model.ProfileResourceValue;
046: import org.libresource.membership.interfaces.MembershipService;
047:
048: import org.libresource.web.Controller;
049:
050: import java.net.URI;
051:
052: import java.util.Iterator;
053: import java.util.Vector;
054:
055: import javax.servlet.http.HttpServletRequest;
056: import javax.servlet.http.HttpServletResponse;
057:
058: public class MailingListController implements Controller {
059: public Object process(URI uri, HttpServletRequest request,
060: HttpServletResponse response) throws Exception {
061: KernelService kernelService = (KernelService) Libresource
062: .getService(KernelConstants.SERVICE);
063: LibresourceMailingService mailingService = (LibresourceMailingService) Libresource
064: .getService(MailingListConstant.SERVICE);
065: MailingListResourceValue mailingList = mailingService
066: .getMailingList(uri);
067:
068: request.setAttribute("mail", mailingList.getMail() + "@"
069: + mailingService.getMailSuffix());
070:
071: if (mailingList.getMail().trim().length() == 0) {
072: request.setAttribute("mailEmpty", "true");
073: }
074:
075: request.setAttribute("description", mailingList
076: .getDescription());
077:
078: if (mailingService.isSubscriber(uri)) {
079: request.setAttribute("isSubscriber", new Boolean(true));
080:
081: MembershipService membershipService = (MembershipService) Libresource
082: .getService(MembershipConstants.SERVICE);
083: request.setAttribute("subscriber", membershipService
084: .getProfile().getUri());
085: }
086:
087: Vector subscribers = mailingService.getSubscribers(uri);
088: Vector users = new Vector();
089: Vector groups = new Vector();
090:
091: for (Iterator i = subscribers.iterator(); i.hasNext();) {
092: Object o = i.next();
093:
094: if (o.getClass() == ProfileResourceValue.class) {
095: users.add(o);
096: } else {
097: groups.add(o);
098: }
099: }
100:
101: request.setAttribute("users", users);
102: request.setAttribute("groups", groups);
103:
104: return "/pages/modules/mailing/viewMailingList.jsp";
105: }
106: }
|