head	1.14;
access;
symbols
	TIGRIS_1_1_0RC2:1.4.6.1
	TIGRIS_1_1_0RC1:1.4.6.1
	TIGRIS_1_1:1.4.6.1.0.2
	TIGRIS_1_0_8:1.4.6.1
	TIGRIS_1_0_8RC3:1.4.6.1
	TIGRIS_1_0_8RC2:1.4.6.1
	TIGRIS_1_0_8RC1:1.4.6.1
	TIGRIS_1_0_7:1.4.6.1
	TIGRIS_1_0_7RC3:1.4.6.1
	TIGRIS_1_0_7RC2:1.4.6.1
	TIGRIS_1_0_7RC1:1.4.6.1
	TIGRIS_1_0_6:1.4.6.1
	TIGRIS_1_0_6RC5:1.4.6.1
	TIGRIS_1_0_6RC4:1.4.6.1
	TIGRIS_1_0_6RC3:1.4.6.1
	TIGRIS_1_0_6RC2:1.4.6.1
	TIGRIS_1_0_6RC1:1.4.6.1
	TIGRIS_1_0_5:1.4
	TIGRIS_1_0_5RC6:1.4
	TIGRIS_1_0_5RC5:1.4
	TIGRIS_1_0_5RC4:1.4
	TIGRIS_1_0_5RC3:1.4
	TIGRIS_1_0_5RC2:1.4
	TIGRIS_1_0_5RC1:1.4
	TIGRIS_1_0_4:1.4
	TIGRIS_1_0_3:1.4
	TIGRIS_1_0_2:1.4
	TIGRIS_1_0_1:1.4
	TIGRIS_1_0:1.4.0.6
	TIGRIS_1_0_0:1.4
	TIGRIS_1_0_0_RC1:1.4.0.2
	dlr:1.1.1
	HELM_PEER_PORT_BRANCH:1.1.1.1;
locks; strict;
comment	@# @;


1.14
date	2001.08.28.17.13.34;	author leonardr;	state Exp;
branches;
next	1.13;

1.13
date	2001.08.11.09.08.09;	author dlr;	state Exp;
branches;
next	1.12;

1.12
date	2001.08.03.00.37.00;	author ms;	state Exp;
branches;
next	1.11;

1.11
date	2001.07.18.10.05.16;	author dlr;	state Exp;
branches;
next	1.10;

1.10
date	2001.06.20.20.51.52;	author ms;	state Exp;
branches;
next	1.9;

1.9
date	2001.05.25.16.57.15;	author leonardr;	state Exp;
branches;
next	1.8;

1.8
date	2001.05.23.01.50.22;	author dlr;	state Exp;
branches;
next	1.7;

1.7
date	2001.05.21.17.22.26;	author dlr;	state Exp;
branches;
next	1.6;

1.6
date	2001.05.21.17.19.41;	author dlr;	state Exp;
branches;
next	1.5;

1.5
date	2001.05.10.01.45.17;	author ms;	state Exp;
branches;
next	1.4;

1.4
date	2001.03.10.07.52.57;	author edk;	state Exp;
branches
	1.4.6.1;
next	1.3;

1.3
date	2001.03.07.01.53.28;	author lucas;	state Exp;
branches;
next	1.2;

1.2
date	2001.02.21.01.08.26;	author dlr;	state Exp;
branches;
next	1.1;

1.1
date	2001.02.13.12.26.39;	author ms;	state Exp;
branches
	1.1.1.1
	1.1.2.1;
next	;

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

1.1.2.1
date	2001.02.13.13.03.59;	author ms;	state Exp;
branches;
next	1.1.2.2;

1.1.2.2
date	2001.02.13.13.19.38;	author ms;	state Exp;
branches;
next	;

1.4.6.1
date	2001.06.07.03.42.22;	author edk;	state Exp;
branches;
next	;


desc
@@


1.14
log
@Completed migration of more methods to ContextAPI.
@
text
@package org.tigris.helm.tool.mail;

import javax.mail.Session;

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

import org.apache.velocity.context.Context;

import org.tigris.helm.security.RedirectException;

import org.tigris.helm.om.MailingList;
import org.tigris.helm.om.Project;
import org.tigris.helm.om.MailingListPeer;
import org.tigris.helm.security.HelmServlet;
import org.tigris.helm.tool.ContextAPI;

import com.quiotix.util.PropUtil;

import org.tigris.eyebrowse.*;

/**
 * EbGetAttachmentServlet : apply helm business logic, then use 
 * GetAttachmentServlet to send attachments.
 *
 * @@author <a href="mailto:ms@@collab.net">Michael Salmon</a>
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 * @@version $Id: EbGetAttachment.java,v 1.13 2001/08/11 09:08:09 dlr Exp $
 */
public class EbGetAttachment extends HelmServlet
{
  private static boolean debug = true;

  public String processRequest(Context context) 
    throws NestableException, RedirectException
  {
    String templateName = super.processRequest(context);
    templateName = (String)myProperties.getProperty("SERVLET_TEMPLATE_ROOT") +
        "/" + (String)myProperties.get("servletTemplatePath");

    // we'll need to verify that the message is associated with the list
    // claimed
    int msgId = PropUtil.defaultInt(ContextAPI.getParameter(context, "msgId"), -1);
    String listName = PropUtil.defaultString(ContextAPI.getParameter(context, "listName"), null);
    int attachId = PropUtil.defaultInt(ContextAPI.getParameter(context, "attachId"), -1);
    if (msgId == -1) {
      throw new NestableException("Missing or invalid message id");
    } else if (listName == null) {
      throw new NestableException("Missing or invalid list name");
    } else if (attachId == -1) {
      throw new NestableException("Missing or invalid attachment id");
    }

    EyebrowseDb con = null;
    Session session = null;

    try 
    { 
      MailingListArchive mla = new MailingListArchive(listName);
      int listId = mla.getID();
      con = EyebrowseDb.getConnection();
      session = MailUtil.getJavaMailSession();

      // EyebrowseDb needs to be split up 'cause this is not a reasonable
      // use of inner classes
      EyebrowseDb.MessageInfo msgInfo = con.MessageExt_get(msgId);

      if (msgInfo.getListId() != listId)
        throw new NestableException("listId does not match message list id");

      //verify that the list is in the same project as the current project.
      try {
        Project currentProject = getCurrentProject(context);
        MailingList ml = MailingListPeer.getInstance(currentProject,
                                                     Integer.toString(listId));
        if (!ml.isViewableBy(getLoginUser(context).getACL())) {
          redirectToUnauthorized();
        }
      } catch (RedirectException e) {
        throw e;
      } catch (Exception e) {
        throw new NestableException("Error verifying access", e);
      }

      GetAttachmentServlet.sendMessageAttachment(msgInfo, session, attachId,
          ContextAPI.getResponse(context));
    } catch (Exception e) {
      throw new NestableException("Unable to send attachment", e);
    } finally {
      if (con != null)
        con.release();
      if (session != null)
        MailUtil.releaseJavaMailSession(session);
    }
    if (debug) Log.info("done in GetAttachment, returning " + templateName);
        
    // should be Empty.vm or equiv or this won't work out right.
    return templateName;
  }
}
@


1.13
log
@Upgrading to Turbine 3.0-dev, Fulcrum 1.0, and Torque 1.0.
@
text
@d28 1
a28 1
 * @@version $Id: EbGetAttachment.java,v 1.12 2001/08/03 00:37:00 ms Exp $
d86 1
a86 1
          getResponse(context));
@


1.12
log
@eyebrowse handles velocity now
@
text
@d6 1
a6 1
import org.apache.turbine.util.TurbineException;
d28 1
a28 1
 * @@version $Id: EbGetAttachment.java,v 1.11 2001/07/18 10:05:16 dlr Exp $
d35 1
a35 1
    throws TurbineException, RedirectException
d47 1
a47 1
      throw new TurbineException("Missing or invalid message id");
d49 1
a49 1
      throw new TurbineException("Missing or invalid list name");
d51 1
a51 1
      throw new TurbineException("Missing or invalid attachment id");
d69 1
a69 1
        throw new TurbineException("listId does not match message list id");
d82 1
a82 1
        throw new TurbineException("Error verifying access", e);
d88 1
a88 1
      throw new TurbineException("Unable to send attachment", e);
@


1.11
log
@Ported Joist Redirect*Exception to Helm.
@
text
@d16 1
d23 1
a23 1
 * HelmGetAttachmentServlet : apply helm business logic, then use 
d28 1
a28 1
 * @@version $Id: EbGetAttachment.java,v 1.10 2001/06/20 20:51:52 ms Exp $
d43 3
a45 3
    int msgId = PropUtil.defaultInt(getParameter(context, "msgId"), -1);
    String listName = PropUtil.defaultString(getParameter(context, "listName"), null);
    int attachId = PropUtil.defaultInt(getParameter(context, "attachId"), -1);
@


1.10
log
@fixed protection error
@
text
@d10 1
a10 1
import org.joist.security.RedirectException;
d27 1
a27 1
 * @@version $Id: EbGetAttachment.java,v 1.9 2001/05/25 16:57:15 leonardr Exp $
@


1.9
log
@.wm is now .vm
@
text
@d27 1
a27 1
 * @@version $Id: EbGetAttachment.java,v 1.8 2001/05/23 01:50:22 dlr Exp $
d67 1
a67 1
      if (msgInfo.listId != listId)
@


1.8
log
@Ported Helm from WebMacro to Velocity.
@
text
@d27 1
a27 1
 * @@version $Id: EbGetAttachment.java,v 1.7 2001/05/21 17:22:26 dlr Exp $
d96 1
a96 1
    // should be Empty.wm or equiv or this won't work out right.
@


1.7
log
@Rolled back previous batch edit which accidently included this file.
@
text
@a2 1
import java.sql.Connection;
d5 4
a8 3
import org.webmacro.servlet.WebContext;
import org.webmacro.servlet.HandlerException;
import org.webmacro.util.Log;
d27 1
a27 1
 * @@version $Id: EbGetAttachment.java,v 1.6 2001/05/21 17:19:41 dlr Exp $
a30 1
  private static Log log = new Log("getAtch", "HelmGetAttachmentServlet");
d33 2
a34 2
  public String processRequest(Connection connection, WebContext context) 
    throws HandlerException, RedirectException
d36 1
a36 1
    String templateName = super.processRequest(connection, context);
d42 3
a44 3
    int msgId    = PropUtil.defaultInt(context.getForm("msgId"), -1);
    String listName = PropUtil.defaultString(context.getForm("listName"), null);
    int attachId = PropUtil.defaultInt(context.getForm("attachId"), -1);
d46 1
a46 1
      throw new HandlerException("missing/invalid msgId");
d48 1
a48 1
      throw new HandlerException("missing/invalid listNam3");
d50 1
a50 1
      throw new HandlerException("missing/invalid attachId");
d68 1
a68 2
        throw new HandlerException("invalid args: listId does not match " +
            "message list id");
d81 1
a81 4
        e.printStackTrace();
        throw new HandlerException(
            "exception verifying access via MailingList obj: " +
            e.getMessage());
d85 1
a85 1
          context.getResponse());
d87 1
a87 3
      log.exception(e);
      if (debug)  log.info("unable to send attachment: " + e.getMessage());
      throw new HandlerException("unable to send attachment: "+e.getMessage());
d94 1
a94 1
    if (debug) log.info("done in GetAttachment, returning " + templateName);
@


1.6
log
@HelmServlet methods take a specific type of context object, rather than the adaptor.
@
text
@d27 1
a27 1
 * @@version $Id: EbGetAttachment.java,v 1.5 2001/05/10 01:45:17 ms Exp $
d74 1
a74 1
        Project currentProject = getCurrentProject(ctx);
d77 1
a77 1
        if (!ml.isViewableBy(getLoginUser(ctx).getACL())) {
@


1.5
log
@fixed to use listname rather then id
@
text
@d27 1
a27 1
 * @@version $Id: EbGetAttachment.java,v 1.4 2001/03/10 07:52:57 edk Exp $
d74 1
a74 1
        Project currentProject = getCurrentProject(context);
d77 1
a77 1
        if (!ml.isViewableBy(getLoginUser(context).getACL())) {
@


1.4
log
@check isViewableBy, which helps us do a better job enforcing permissions
as well as the isPrivate flag
@
text
@d27 1
a27 1
 * @@version $Id: EbGetAttachment.java,v 1.3 2001/03/07 01:53:28 lucas Exp $
d44 1
a44 1
    int listId   = PropUtil.defaultInt(context.getForm("listId"), -1);
d48 2
a49 2
    } else if (listId == -1) {
      throw new HandlerException("missing/invalid listId");
d57 4
a60 1
    try { 
@


1.4.6.1
log
@checking for access the right way, using listName rather than listId.
@
text
@d27 1
a27 1
 * @@version $Id: EbGetAttachment.java,v 1.4 2001/03/10 07:52:57 edk Exp $
d44 1
a45 2
    String listName = context.getForm("listName");

d48 2
d65 4
d72 2
a73 2
        MailingList ml =
            MailingListPeer.getInstanceByName(currentProject, listName);
a76 4
        if (!msgInfo.listName.equals(ml.getAddress(null)))
          throw new HandlerException("invalid args: list for message does " +
              "not match listName");

@


1.3
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@d27 1
a27 1
 * @@version $Id: EbGetAttachment.java,v 1.2 2001/02/21 01:08:26 dlr Exp $
d74 3
@


1.2
log
@This is the highest revision from the HELM_PEER_PORT_BRANCH.  The previous import caused too many conflicts to resolve manually
@
text
@d14 1
a14 1
import org.tigris.helm.om.peer.MailingListPeer;
d27 1
a27 1
 * @@version $Id: EbGetAttachment.java,v 1.1.2.2 2001/02/13 13:19:38 ms Exp $
@


1.1
log
@Adding these to helm for logical organization and for build depdancy
flow. To install these servlets eyebrowse must be built and installed
with the helm top-level make target's "eyebrowse" and
"eyebrowse-install". If succesful these servlets will be installed also.
@
text
@a0 33
/*
 * Copyright (c) 2000, Quiotix Corporation
 *        All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 * 
 *      Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 * 
 *      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.
 * 
 *      Neither name of Quiotix Corporation nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS 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 THE COPYRIGHT
 * HOLDER OR 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.
 */


d3 2
a4 3
import org.tigris.helm.tool.mail.MailingList;
import org.tigris.helm.project.Project;
import org.tigris.helm.security.HelmServlet;
d9 1
d12 4
a15 1
import java.sql.Connection;
d17 1
a17 1
import javax.mail.Session;
a20 2
import com.quiotix.util.PropUtil;

d24 5
a28 1
*/
d72 2
a73 2
        MailingList ml = new MailingList(connection,
            getDataManager(context), Integer.toString(listId), currentProject);
@


1.1.1.1
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@d1 33
d36 3
a38 2
import java.sql.Connection;
import javax.mail.Session;
a42 1

d45 1
a45 4
import org.tigris.helm.om.MailingList;
import org.tigris.helm.om.Project;
import org.tigris.helm.om.peer.MailingListPeer;
import org.tigris.helm.security.HelmServlet;
d47 1
a47 1
import com.quiotix.util.PropUtil;
d51 2
d56 1
a56 5
 *
 * @@author <a href="mailto:ms@@collab.net">Michael Salmon</a>
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 * @@version $Id: EbGetAttachment.java,v 1.1.2.2 2001/02/13 13:19:38 ms Exp $
 */
d100 2
a101 2
        MailingList ml = MailingListPeer.getInstance(currentProject,
                                                     Integer.toString(listId));
@


1.1.2.1
log
@Ported changes to HEAD to branch. Moved servlets into logical container
of org.tigris.helm.tool.mail and changed build system and jserv config
to match changes.
@
text
@@


1.1.2.2
log
@Merged Dlr's eyebrowse servlets that follow the peer model into helm.
@
text
@d1 33
d36 3
a38 2
import java.sql.Connection;
import javax.mail.Session;
a42 1

d45 1
a45 4
import org.tigris.helm.om.MailingList;
import org.tigris.helm.om.Project;
import org.tigris.helm.om.peer.MailingListPeer;
import org.tigris.helm.security.HelmServlet;
d47 1
a47 1
import com.quiotix.util.PropUtil;
d51 2
d56 1
a56 5
 *
 * @@author <a href="mailto:ms@@collab.net">Michael Salmon</a>
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 * @@version $Id: EbGetAttachment.java,v 1.3.6.1 2001/02/09 20:45:35 dlr Exp $
 */
d100 2
a101 2
        MailingList ml = MailingListPeer.getInstance(currentProject,
                                                     Integer.toString(listId));
@


