head	1.22;
access;
symbols
	TIGRIS_1_1_0RC2:1.16
	TIGRIS_1_1_0RC1:1.16
	TIGRIS_1_1:1.16.0.4
	TIGRIS_1_0_8:1.16
	TIGRIS_1_0_8RC3:1.16
	TIGRIS_1_0_8RC2:1.16
	TIGRIS_1_0_8RC1:1.16
	TIGRIS_1_0_7:1.16
	TIGRIS_1_0_7RC3:1.16
	TIGRIS_1_0_7RC2:1.16
	TIGRIS_1_0_7RC1:1.16
	TIGRIS_1_0_6:1.16
	TIGRIS_1_0_6RC5:1.16
	TIGRIS_1_0_6RC4:1.16
	TIGRIS_1_0_6RC3:1.16
	TIGRIS_1_0_6RC2:1.16
	TIGRIS_1_0_6RC1:1.16
	TIGRIS_1_0_5:1.16
	TIGRIS_1_0_5RC6:1.16
	TIGRIS_1_0_5RC5:1.16
	TIGRIS_1_0_5RC4:1.16
	TIGRIS_1_0_5RC3:1.16
	TIGRIS_1_0_5RC2:1.16
	TIGRIS_1_0_5RC1:1.16
	TIGRIS_1_0_4:1.16
	TIGRIS_1_0_3:1.16
	TIGRIS_1_0_2:1.16
	TIGRIS_1_0_1:1.16
	TIGRIS_1_0:1.16.0.6
	TIGRIS_1_0_0:1.16
	TIGRIS_1_0_0_RC1:1.16.0.2
	dlr:1.1.1
	TIGRIS_0_9_2_4:1.9
	TIGRIS_0_9_2_3:1.9
	HELM_PEER_PORT_BRANCH:1.1.1.1
	TURBINE_PEER:1.14
	TIGRIS_0_9_2_1:1.14
	TIGRIS_0_9_2:1.9.0.2
	TIGRIS_0_9_0:1.6.0.2;
locks; strict;
comment	@# @;


1.22
date	2001.08.28.17.45.19;	author leonardr;	state Exp;
branches;
next	1.21;

1.21
date	2001.08.11.09.08.09;	author dlr;	state Exp;
branches;
next	1.20;

1.20
date	2001.07.18.23.48.19;	author leonardr;	state Exp;
branches;
next	1.19;

1.19
date	2001.07.18.23.39.38;	author dlr;	state Exp;
branches;
next	1.18;

1.18
date	2001.07.18.10.05.16;	author dlr;	state Exp;
branches;
next	1.17;

1.17
date	2001.05.23.01.50.22;	author dlr;	state Exp;
branches;
next	1.16;

1.16
date	2001.03.07.01.53.28;	author lucas;	state Exp;
branches;
next	1.15;

1.15
date	2001.02.21.01.08.26;	author dlr;	state Exp;
branches;
next	1.14;

1.14
date	2001.01.26.18.29.11;	author edk;	state Exp;
branches
	1.14.2.1;
next	1.13;

1.13
date	2001.01.26.05.24.08;	author edk;	state dead;
branches;
next	1.12;

1.12
date	2001.01.25.02.42.47;	author edk;	state Exp;
branches;
next	1.11;

1.11
date	2001.01.25.02.17.58;	author lucas;	state Exp;
branches;
next	1.10;

1.10
date	2001.01.25.00.26.08;	author edk;	state Exp;
branches;
next	1.9;

1.9
date	2001.01.06.18.17.09;	author jrobbins;	state Exp;
branches;
next	1.8;

1.8
date	2000.12.22.21.03.23;	author edk;	state Exp;
branches;
next	1.7;

1.7
date	2000.12.22.14.41.31;	author edk;	state Exp;
branches;
next	1.6;

1.6
date	2000.12.09.01.32.38;	author elicia;	state Exp;
branches
	1.6.2.1;
next	1.5;

1.5
date	2000.12.08.11.53.38;	author edk;	state Exp;
branches;
next	1.4;

1.4
date	2000.12.08.10.01.05;	author edk;	state Exp;
branches;
next	1.3;

1.3
date	2000.12.08.09.45.10;	author edk;	state Exp;
branches;
next	1.2;

1.2
date	2000.12.08.03.22.42;	author elicia;	state Exp;
branches;
next	1.1;

1.1
date	2000.12.08.01.43.10;	author elicia;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2001.02.21.00.35.36;	author dlr;	state Exp;
branches;
next	;

1.6.2.1
date	2000.12.22.14.42.02;	author edk;	state Exp;
branches;
next	;

1.14.2.1
date	2001.01.28.01.02.20;	author dlr;	state dead;
branches;
next	1.14.2.2;

1.14.2.2
date	2001.02.20.09.49.21;	author edk;	state Exp;
branches;
next	;


desc
@@


1.22
log
@More methods migrated to ContextAPI.
@
text
@/* ================================================================
 * Copyright (c) 2000 Collab.Net.  All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 * 
 * 1. Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * 
 * 3. The end-user documentation included with the redistribution, if
 * any, must include the following acknowlegement: "This product includes
 * software developed by Collab.Net (http://www.Collab.Net/)."
 * Alternately, this acknowlegement may appear in the software itself, if
 * and wherever such third-party acknowlegements normally appear.
 * 
 * 4. The hosted project names must not be used to endorse or promote
 * products derived from this software without prior written
 * permission. For written permission, please contact info@@collab.net.
 * 
 * 5. Products derived from this software may not use the "Tigris" name
 * nor may "Tigris" appear in their names without prior written
 * permission of Collab.Net.
 * 
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * ====================================================================
 * 
 * This software consists of voluntary contributions made by many
 * individuals on behalf of Collab.Net.
 */


package org.tigris.helm.tool.mail;

import java.util.ArrayList;
import javax.servlet.ServletException;

import org.apache.turbine.util.Log;
import org.apache.commons.util.exception.NestableException;

import org.apache.velocity.context.Context;

import org.tigris.helm.om.User;
import org.tigris.helm.om.Project;
import org.tigris.helm.om.MailingList;
import org.tigris.helm.om.MailingListPeer;
import org.tigris.helm.tool.Emailer;
import org.tigris.helm.tool.mail.Util;
import org.tigris.helm.security.HelmServlet;
import org.tigris.helm.tool.ContextAPI;
import org.tigris.helm.security.RedirectException;

/**
 * Present a form for posting to the mailing list.
 *
 * @@author <a href="mailto:elicia@@collab.net">Elicia David</a>
 * @@version $Id: MailingListPost.java,v 1.21 2001/08/11 09:08:09 dlr Exp $
 */
public class MailingListPost extends HelmServlet {
    private static final boolean DEBUG = true;

    public void start() throws ServletException {
        super.start();
    }

    protected String processRequest(Context context)
            throws NestableException, RedirectException {

        String templateName = super.processRequest(context);
        String action = (String) context.get("action");
        if (DEBUG) Log.info("MailingListPost: action = " + action);

        User currentUser = getCurrentUser(context);

        Project currentProject = getCurrentProject(context);
        if (currentProject == null)
            redirectToError(context, "MailingListPost: No project specified");

        String listId = ContextAPI.getParameter(context, "listId");
        String replySubject = ContextAPI.getParameter(context, "replySubject");

        if (listId == null)
            redirectToError(context, "MailingListPost: No listId specified");

        MailingList mList = null;
        try {
            mList = MailingListPeer.getInstance(currentProject, listId);
        } catch (Exception e) {
            throw new NestableException("Invalid mailing list", e);
        }
        if (mList == null || !mList.exists())
            redirectToError(context, "listId " + listId + " does not exist");

        context.put("listId", listId);
        context.put("listname", mList.getListName());
        context.put("replySubject", replySubject);

        if (action.equals("Post Message"))
        {         
           String subject = ContextAPI.getParameter(context, "subject"); 
           String body = ContextAPI.getParameter(context, "body"); 

	   if (subject == null || subject.equals (""))
               ContextAPI.addMissingField(context, "subject");
	   if (body == null || body.equals (""))
               ContextAPI.addMissingField(context, "body");

           if (ContextAPI.isValidUserInput(context))
	   {
               // Send email to archive
               if (DEBUG) Log.debug("Sending mail to mailing list");
               try 
               {
                   String listAddress = mList.getAddress(null);
                   if (DEBUG) Log.info("listAddress=" + listAddress);
                   Emailer email = new Emailer();
                   email.sendEmailFrom(currentUser.getEmail(), listAddress,
                                       subject, body);
               } 
               catch (Exception e) 
               {
                   Log.error(e);
                   if (DEBUG) Log.info("unable to get mailing list address" +
                                       e.getMessage());
                   redirectToError(context, "invalid mailing list");
               }
               redirectTo("SummarizeList");
           } 
           else 
           {
               context.put("subject", subject);
               context.put("body", body);	 
           }
        }
        
        return templateName;
    }
}
@


1.21
log
@Upgrading to Turbine 3.0-dev, Fulcrum 1.0, and Torque 1.0.
@
text
@d72 1
a72 1
 * @@version $Id: MailingListPost.java,v 1.20 2001/07/18 23:48:19 leonardr Exp $
d94 2
a95 2
        String listId = getParameter(context, "listId");
        String replySubject = getParameter(context, "replySubject");
d115 2
a116 2
           String subject = getParameter(context, "subject"); 
           String body = getParameter(context, "body"); 
@


1.20
log
@Don't import class dlr just moved.
@
text
@d54 1
a54 1
import org.apache.turbine.util.TurbineException;
d72 1
a72 1
 * @@version $Id: MailingListPost.java,v 1.19 2001/07/18 23:39:38 dlr Exp $
d82 1
a82 1
            throws TurbineException, RedirectException {
d104 1
a104 1
            throw new TurbineException("Invalid mailing list", e);
@


1.19
log
@Removed Joist dependancies.
@
text
@d65 1
d72 1
a72 1
 * @@version $Id: MailingListPost.java,v 1.18 2001/07/18 10:05:16 dlr Exp $
d114 1
a114 2
        {
         
a117 2
           ArrayList missingFields = new ArrayList();

d119 1
a119 1
	       missingFields.add ("subject");
d121 1
a121 1
	       missingFields.add ("body");
d123 1
a123 1
           if (missingFields.isEmpty ())
d125 14
a138 11
              // Send email to archive
              if (DEBUG) Log.debug("Sending mail to mailing list");
              try {
                  String listAddress = mList.getAddress(null);
                  if (DEBUG) Log.info("listAddress=" + listAddress);
	          Emailer email = new Emailer();
	          email.sendEmailFrom(currentUser.getEmail(), listAddress,
                          subject, body);
              } catch (Exception e) {
                  Log.error(e);
                  if (DEBUG) Log.info("unable to get mailing list address" +
d140 9
a148 11
                  redirectToError(context, "invalid mailing list");
              }
              redirectTo("SummarizeList");
           } else {
	      appendToMessage (context, "Missing Fields", missingFields);
	      if (DEBUG)
	         Log.debug ("Missing Fields: " + missingFields.toString ());
              context.put("missingFields", missingFields);
              context.put("subject", subject);
              context.put("body", body);
	   }
d150 1
a150 1

@


1.18
log
@Ported Joist Redirect*Exception to Helm.
@
text
@a50 2
import java.sql.*;

a57 3
import org.tigris.helm.security.RedirectException;
import org.joist.database.DataManager;

d62 1
d65 1
a65 1
import org.joist.mail.Emailer;
d71 1
a71 1
 * @@version $Id: MailingListPost.java,v 1.17 2001/05/23 01:50:22 dlr Exp $
@


1.17
log
@Ported Helm from WebMacro to Velocity.
@
text
@d60 1
a60 1
import org.joist.security.RedirectException;
d75 1
a75 1
 * @@version $Id: MailingListPost.java,v 1.16 2001/03/07 01:53:28 lucas Exp $
@


1.16
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@d55 4
a58 2
import org.webmacro.util.Log;
import org.webmacro.servlet.*;
d75 1
a75 1
 * @@version $Id: MailingListPost.java,v 1.15 2001/02/21 01:08:26 dlr Exp $
d78 1
a78 2
    static private Log log = new Log("mlPost", "MailingListPost");
    static private boolean debug = true;
d84 2
a85 2
    protected String processRequest(Connection connection, WebContext context)
            throws HandlerException, RedirectException {
d87 1
a87 1
        String templateName = super.processRequest(connection, context);
d89 1
a89 1
        if (debug) log.info("MailingListPost: action = " + action);
d97 2
a98 2
        String listId = context.getForm("listId");
        String replySubject = context.getForm("replySubject");
d107 1
a107 3
            log.exception(e);
            if (debug) log.debug("unable to get MailingList" + e.getMessage());
            redirectToError(context, "invalid mailing list");
d119 2
a120 2
           String subject = context.getForm("subject"); 
           String body = context.getForm("body"); 
d132 1
a132 1
              if (debug) log.info("Sending mail to mailing list");
d135 1
a135 1
                  if (debug) log.info("listAddress=" + listAddress);
d140 2
a141 2
                  log.exception(e);
                  if (debug) log.info("unable to get mailing list address" +
d148 2
a149 2
	      if (debug)
	         log.debug ("Missing Fields: " + missingFields.toString ());
d158 1
a158 1
} /* end class MailingListPost */
@


1.15
log
@This is the highest revision from the HELM_PEER_PORT_BRANCH.  The previous import caused too many conflicts to resolve manually
@
text
@d64 1
a64 1
import org.tigris.helm.om.peer.MailingListPeer;
d73 1
a73 1
 * @@version $Id: MailingListPost.java,v 1.14.2.2 2001/02/20 09:49:21 edk Exp $
@


1.14
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@a57 2
import com.workingdogs.village.DataSetException;

d61 4
a66 2
import org.tigris.helm.project.Project;
import org.tigris.helm.domain.User;
d73 1
a73 1
 * @@version $Id: MailingListPost.java,v 1.9 2001/01/06 18:17:09 jrobbins Exp $
d92 2
a93 2
        Project project = getCurrentProject(context);
        if (project == null)
d104 1
a104 1
            mList = new MailingList(connection, dMgr, listId, project);
d114 1
a114 7
        try {
            context.put("listname", mList.getName());
        } catch (DataSetException e) {
            log.exception(e);
            redirectToError(context, "internal error bad mailing list");
        }

@


1.14.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@d73 1
a73 1
 * @@version $Id: MailingListPost.java,v 1.14 2001/01/26 18:29:11 edk Exp $
@


1.14.2.2
log
@* port MailingList* to the peer system
* add some necessary methods to MailingList, update AnzuTask to use those
* this compiles, but some methods still need to be implemented, so it
  doesn't all work
@
text
@d58 2
a62 4
import org.tigris.helm.om.User;
import org.tigris.helm.om.Project;
import org.tigris.helm.om.MailingList;
import org.tigris.helm.om.peer.MailingListPeer;
d65 2
d92 2
a93 2
        Project currentProject = getCurrentProject(context);
        if (currentProject == null)
d104 1
a104 1
            mList = MailingListPeer.getInstance(currentProject, listId);
d114 7
a120 1
        context.put("listname", mList.getListName());
@


1.13
log
@revert this stuff to its state as of 2001/01/24 12:42:00 GMT -- with
the following exceptions, which have some different modifications so
they'll work with changes which have happened in joist:

ProjectNewsEdit.java
SkinManager.java
SkinStyleElementValueManager.java
StyleElementManager.java
StyleManager.java

it compiles.  i dunno if it works, though.
@
text
@d58 1
a62 1
import org.tigris.helm.database.DBException;
a66 1
import org.tigris.helm.database.DBException;
d73 1
a73 1
 * @@version $Id: MailingListPost.java,v 1.12 2001/01/25 02:42:47 edk Exp $
d104 1
a104 1
            mList = new MailingList(dMgr, listId, project);
d116 1
a116 1
        } catch (DBException e) {
@


1.12
log
@more changes to match the new pattern
@
text
@d74 1
a74 1
 * @@version $Id: MailingListPost.java,v 1.11 2001/01/25 02:17:58 lucas Exp $
@


1.11
log
@fixed use of DBException
@
text
@a57 1
import com.workingdogs.village.DataSetException;
d62 1
d74 1
a74 1
 * @@version $Id: MailingListPost.java,v 1.10 2001/01/25 00:26:08 edk Exp $
@


1.10
log
@MailingList changes to more closely resemble other business objects (I
don't like certain parts of the pattern, but consistency is more important)
including changes to avoid keeping reference to Connections.
@
text
@d67 1
d74 1
a74 1
 * @@version $Id: MailingListPost.java,v 1.9 2001/01/06 18:17:09 jrobbins Exp $
d117 1
a117 1
        } catch (DataSetException e) {
@


1.9
log
@made it actually send email to the list, not directly to the archive
@
text
@d73 1
a73 1
 * @@version $Id: MailingListPost.java,v 1.8 2000/12/22 21:03:23 edk Exp $
d104 1
a104 1
            mList = new MailingList(connection, dMgr, listId, project);
@


1.8
log
@remove junk from something i was building, which isn't done yet
@
text
@d73 1
a73 1
 * @@version $Id: MailingListPost.java,v 1.7 2000/12/22 14:41:31 edk Exp $
d139 1
a139 1
              if (debug) log.info("Sending mail to archive");
d141 2
a142 2
                  String archiveAddress = mList.getArchiveAddress();
                  if (debug) log.info("archive=" + archiveAddress);
d144 1
a144 1
	          email.sendEmailFrom(currentUser.getEmail(), archiveAddress,
d148 1
a148 1
                  if (debug) log.info("unable to get archive address" +
@


1.7
log
@use the user's e-mail address for the from / envelop sender parts.
@
text
@d73 1
a73 1
 * @@version $Id: MailingListPost.java,v 1.6 2000/12/09 01:32:38 elicia Exp $
a151 1
              mList.updateArchive();
@


1.6
log
@putting reply subject in context for template
@
text
@d66 1
d73 1
a73 1
 * @@version $Id: MailingListPost.java,v 1.5 2000/12/08 11:53:38 edk Exp $
d90 2
d144 2
a145 1
	          email.sendEmail(archiveAddress, subject, body);
d152 1
@


1.6.2.1
log
@use the user's e-mail address for the from / envelop sender parts.
@
text
@a62 1
import org.tigris.helm.domain.User;
d72 1
a72 1
 * @@version $Id: MailingListPost.java,v 1.6 2000/12/09 01:32:38 elicia Exp $
a88 2
        User currentUser = getCurrentUser(context);

d141 1
a141 3
                  log.info("from is " + currentUser.getEmail());
	          email.sendEmailFrom(currentUser.getEmail(), archiveAddress,
                          subject, body);
@


1.5
log
@redirect to SummarizeList after posting (is this the right thing to do?)
@
text
@d72 1
a72 1
 * @@version $Id: MailingListPost.java,v 1.4 2000/12/08 10:01:05 edk Exp $
d94 2
d118 1
a118 1
        context.put("replySubject", "new message");
@


1.4
log
@change the mailing list constructor to take a Project -- to ensure that
the mailing list referenced by ID is actually from that Project.  this
sort of complication is another good reason to avoid using object IDs
externally if possible.
@
text
@d72 1
a72 1
 * @@version $Id: MailingListPost.java,v 1.3 2000/12/08 09:45:10 edk Exp $
d116 1
a116 1
        context.put("replySubject", "blahblahblah");
a139 1
                  
d146 1
a146 1
            
@


1.3
log
@use listId instead of listname ... i'd prefer to use the list name, but
the eyebrowse pages which link to this have easy access to the former --
and access to the latter would be much more work.
@
text
@d72 1
a72 1
 * @@version $Id: MailingListPost.java,v 1.2 2000/12/08 03:22:42 elicia Exp $
d99 1
a99 5
            mList = new MailingList(connection, dMgr, listId);
            // this logic needs to move into MailingList (!!)
            if (!project.getID().equals(mList.getProjectID()))
                throw new HandlerException("mailing list project id does " +
                        "not match current project");
@


1.2
log
@now sending email to archive
@
text
@d58 2
d72 1
a72 1
 * @@version $Id: MailingListPost.java,v 1.1 2000/12/08 01:43:10 elicia Exp $
d93 3
a95 4
        String list = context.getForm("list");
        if (list == null)
            redirectToError(context, "MailingListPost: No list specified");
        context.put("listname", list);
d99 5
a103 1
            mList = new MailingList(connection, dMgr, project.getID(), list);
d110 9
a118 1
            redirectToError(context, "list " + list + " does not exist");
a119 1
        context.put("listname", list);
@


1.1
log
@initial revision
@
text
@a49 2
import java.util.List;
import java.util.Iterator;
a57 4
import gnu.regexp.RE;

import com.workingdogs.village.DataSetException;

a58 1
import org.joist.util.ListElement;
d64 1
a64 5
import org.tigris.helm.domain.Domain;
import org.tigris.helm.database.MailingListManager;
import org.tigris.helm.DoesNotExist;
import org.tigris.helm.AlreadyExists;
import org.tigris.helm.security.AccessControlList;
d70 1
a70 1
 * @@version $Id: MailingListPost.java,v 1.4 2000/11/29 01:44:22 edk Exp $
d82 1
d84 2
a85 7
        ArrayList missingFields = new ArrayList();
        ArrayList validationErrors = new ArrayList();
        boolean listExists = false;

        Domain domain = getCurrentDomain(context);
        // put the domain in the context for use by anzu
        context.put("domain", domain.getName());
d91 4
a94 4
        context.put("listname", "");
        context.put("owner", "");
        context.put("description", "");
        context.put("prefix", "");
a95 3
        // Determine which button was pushed
        String action = (String) context.get("action");
        String type = null;
d97 52
a148 8
        String prefix = null;
        String subscribersRaw = "";
        String moderatorsRaw = "";
        Boolean trailerChecked = new Boolean(false);

        context.put("missingFields", missingFields);
        context.put("validationErrors", validationErrors);
        context.put("listExists", new Boolean(listExists));
@


1.1.1.1
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@d50 2
d60 4
d65 1
a67 4
import org.tigris.helm.om.User;
import org.tigris.helm.om.Project;
import org.tigris.helm.om.MailingList;
import org.tigris.helm.om.peer.MailingListPeer;
d70 6
a75 1
import org.joist.mail.Emailer;
d81 1
a81 1
 * @@version $Id: MailingListPost.java,v 1.14.2.2 2001/02/20 09:49:21 edk Exp $
a92 1

d94 7
a100 2
        String action = (String) context.get("action");
        if (debug) log.info("MailingListPost: action = " + action);
d102 2
a103 4
        User currentUser = getCurrentUser(context);

        Project currentProject = getCurrentProject(context);
        if (currentProject == null)
d106 4
a109 5
        String listId = context.getForm("listId");
        String replySubject = context.getForm("replySubject");

        if (listId == null)
            redirectToError(context, "MailingListPost: No listId specified");
d111 3
d115 8
a122 53
        try {
            mList = MailingListPeer.getInstance(currentProject, listId);
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.debug("unable to get MailingList" + e.getMessage());
            redirectToError(context, "invalid mailing list");
        }
        if (mList == null || !mList.exists())
            redirectToError(context, "listId " + listId + " does not exist");

        context.put("listId", listId);
        context.put("listname", mList.getListName());
        context.put("replySubject", replySubject);

        if (action.equals("Post Message"))
        {
         
           String subject = context.getForm("subject"); 
           String body = context.getForm("body"); 

           ArrayList missingFields = new ArrayList();

	   if (subject == null || subject.equals (""))
	       missingFields.add ("subject");
	   if (body == null || body.equals (""))
	       missingFields.add ("body");

           if (missingFields.isEmpty ())
	   {
              // Send email to archive
              if (debug) log.info("Sending mail to mailing list");
              try {
                  String listAddress = mList.getAddress(null);
                  if (debug) log.info("listAddress=" + listAddress);
	          Emailer email = new Emailer();
	          email.sendEmailFrom(currentUser.getEmail(), listAddress,
                          subject, body);
              } catch (Exception e) {
                  log.exception(e);
                  if (debug) log.info("unable to get mailing list address" +
                                       e.getMessage());
                  redirectToError(context, "invalid mailing list");
              }
              redirectTo("SummarizeList");
           } else {
	      appendToMessage (context, "Missing Fields", missingFields);
	      if (debug)
	         log.debug ("Missing Fields: " + missingFields.toString ());
              context.put("missingFields", missingFields);
              context.put("subject", subject);
              context.put("body", body);
	   }
        }
@


