head	1.9;
access;
symbols
	TIGRIS_1_1_0RC2:1.5
	TIGRIS_1_1_0RC1:1.5
	TIGRIS_1_1:1.5.0.4
	TIGRIS_1_0_8:1.5
	TIGRIS_1_0_8RC3:1.5
	TIGRIS_1_0_8RC2:1.5
	TIGRIS_1_0_8RC1:1.5
	TIGRIS_1_0_7:1.5
	TIGRIS_1_0_7RC3:1.5
	TIGRIS_1_0_7RC2:1.5
	TIGRIS_1_0_7RC1:1.5
	TIGRIS_1_0_6:1.5
	TIGRIS_1_0_6RC5:1.5
	TIGRIS_1_0_6RC4:1.5
	TIGRIS_1_0_6RC3:1.5
	TIGRIS_1_0_6RC2:1.5
	TIGRIS_1_0_6RC1:1.5
	TIGRIS_1_0_5:1.5
	TIGRIS_1_0_5RC6:1.5
	TIGRIS_1_0_5RC5:1.5
	TIGRIS_1_0_5RC4:1.5
	TIGRIS_1_0_5RC3:1.5
	TIGRIS_1_0_5RC2:1.5
	TIGRIS_1_0_5RC1:1.5
	TIGRIS_1_0_4:1.5
	TIGRIS_1_0_3:1.5
	TIGRIS_1_0_2:1.5
	TIGRIS_1_0_1:1.5
	TIGRIS_1_0:1.5.0.6
	TIGRIS_1_0_0:1.5
	TIGRIS_1_0_0_RC1:1.5.0.2
	dlr:1.1.1
	TIGRIS_0_9_2_4:1.2
	TIGRIS_0_9_2_3:1.2
	HELM_PEER_PORT_BRANCH:1.1.1.2
	TURBINE_PEER:1.4
	TIGRIS_0_9_2_1:1.4
	TIGRIS_0_9_2:1.2.0.6
	TIGRIS_0_9_0:1.2.0.4
	TIGRIS_0_8_4:1.2.0.2
	NEWHELM:1.1.1.1
	TIGRIS_NOV_12_2000:1.1.1;
locks; strict;
comment	@# @;


1.9
date	2001.08.11.09.08.09;	author dlr;	state Exp;
branches;
next	1.8;

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

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

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

1.5
date	2001.02.21.01.08.26;	author dlr;	state Exp;
branches;
next	1.4;

1.4
date	2001.01.26.18.29.11;	author edk;	state Exp;
branches
	1.4.2.1;
next	1.3;

1.3
date	2001.01.26.05.24.08;	author edk;	state dead;
branches;
next	1.2;

1.2
date	2000.11.13.19.45.21;	author edk;	state Exp;
branches;
next	1.1;

1.1
date	2000.11.12.21.17.01;	author dlr;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2000.11.12.21.17.01;	author dlr;	state Exp;
branches;
next	1.1.1.2;

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

1.4.2.1
date	2001.01.28.01.02.20;	author dlr;	state dead;
branches;
next	1.4.2.2;

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


desc
@@


1.9
log
@Upgrading to Turbine 3.0-dev, Fulcrum 1.0, and Torque 1.0.
@
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 java.util.List;
import java.util.Iterator;
import java.util.StringTokenizer;

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

import org.apache.velocity.context.Context;

import gnu.regexp.RE;

import org.tigris.helm.security.RedirectException;
import org.tigris.helm.tool.ContextAPI;
import org.tigris.helm.tool.ListElement;

/**
 * Some utilities used by several different classes -- regexps and the
 * functions.
 *
 * @@author <a href="mailto:edk@@collab.net">Ed Korthof</a>
 * @@version $Id: Util.java,v 1.8 2001/07/18 23:40:44 dlr Exp $
 */
public class Util {
    // this is used for the listname and the prefix (the representation
    // of the listname optionally included in the subject header)
    static public RE listnameRE = null;
    static public RE emailRE = null;
    static public RE prefixRE = null;

    static {
        try {
            emailRE = new RE(
                    "^[\\w\\-\\._=\\!#\\*\\+]+@@([\\w\\-]+\\.)+[a-zA-Z]{2,3}$");
            listnameRE= new RE("^[a-zA-Z0-9_\\-]+$");
            prefixRE= new RE("^[- a-zA-Z0-9_\\[\\]]+$");
        } catch (gnu.regexp.REException e) {
            System.err.println("initialization error in regexp pattern");
            e.printStackTrace();
            throw new RuntimeException("invalid regexp syntax");
        }
    }
    
    public static String readFormInput(Context context, String name,
            RE regexp, boolean required, ArrayList missingFields,
            ArrayList validationErrors) throws NestableException {
        String value = ContextAPI.getParameter(context, name);
        Log.debug("name "+name+" => value "+value);
        if (value == null) value = "";
        context.put(name, value);
        if (value == null || value.equals("")) {
            if (required) {
                missingFields.add(name);
            }
        }
        if (!value.equals("") && regexp != null && !regexp.isMatch(value)) {
            validationErrors.add(name + " does not match the pattern");
        }
        return value;
    }

    public static ArrayList parseEmailList (String list,
            ArrayList validationErrors)
    {
        StringTokenizer tok = new StringTokenizer(list);
        ArrayList members = new ArrayList();
        while (tok.hasMoreTokens()) {
            String address  = tok.nextToken();
            if (!emailRE.isMatch(address)) {
                validationErrors.add("invalid e-mail address: " + address);
                continue;
            }
            members.add(address);
        }
        return members;
    }
}
@


1.8
log
@Removed Joist dependancies.
@
text
@d56 1
a56 1
import org.apache.turbine.util.TurbineException;
d71 1
a71 1
 * @@version $Id: Util.java,v 1.7 2001/07/18 10:05:16 dlr Exp $
d95 1
a95 1
            ArrayList validationErrors) throws TurbineException {
@


1.7
log
@Ported Joist Redirect*Exception to Helm.
@
text
@a54 3
import javax.servlet.*;
import javax.servlet.http.*;

a62 2
import org.joist.util.ListElement;

d64 1
d71 1
a71 1
 * @@version $Id: Util.java,v 1.6 2001/05/23 01:50:22 dlr Exp $
d126 1
a126 1
} /* end class Util */
@


1.6
log
@Ported Helm from WebMacro to Velocity.
@
text
@d65 1
a65 1
import org.joist.security.RedirectException;
d75 1
a75 1
 * @@version $Id: Util.java,v 1.5 2001/02/21 01:08:26 dlr Exp $
@


1.5
log
@This is the highest revision from the HELM_PEER_PORT_BRANCH.  The previous import caused too many conflicts to resolve manually
@
text
@d50 5
d58 2
a59 2
import org.webmacro.util.Log;
import org.webmacro.servlet.*;
d61 1
a61 4
import java.util.ArrayList;
import java.util.List;
import java.util.Iterator;
import java.util.StringTokenizer;
d68 2
d75 1
a75 1
 * @@version $Id: Util.java,v 1.4.2.2 2001/02/20 09:49:21 edk Exp $
a77 2
    static private Log log = new Log("mlUtil", "mlUtil");

d83 1
d97 1
a97 1
    public static String readFormInput(WebContext context, String name,
d99 3
a101 3
            ArrayList validationErrors) throws HandlerException {
        String value = (String)context.getForm(name);
        log.debug("name "+name+" => value "+value);
@


1.4
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@d71 1
a71 1
 * @@version $Id: Util.java,v 1.2 2000/11/13 19:45:21 edk Exp $
@


1.4.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@d71 1
a71 1
 * @@version $Id: Util.java,v 1.4 2001/01/26 18:29:11 edk Exp $
@


1.4.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
@@


1.3
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
@@


1.2
log
@updates from last night: use ArrayList instead of String[]'s; and correct
Util's prefix pattern
@
text
@d71 1
a71 1
 * @@version $Id: Util.java,v 1.5 2000/11/13 16:47:36 edk Exp $
@


1.1
log
@Initial revision
@
text
@d71 1
a71 1
 * @@version $Id: Util.java,v 1.3 2000/11/11 11:57:00 edk Exp $
d86 1
a86 1
            prefixRE= new RE("^[a-zA-Z0-9_\\-]+$");
d112 1
a112 1
    public static String[] parseEmailList (String list,
d125 1
a125 7
        String addresses[] = new String[members.size()];
        Iterator iter = members.iterator();
        int i = 0;
        while (iter.hasNext()) {
            addresses[i++] = (String) iter.next();
        }
        return addresses;
@


1.1.1.1
log
@Merging newhelm tree into helm, as per IZ issue #557.  Previous major version of helm is tagged TIGRIS_NOV_11_2000.
@
text
@@


1.1.1.2
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@d71 1
a71 1
 * @@version $Id: Util.java,v 1.4.2.2 2001/02/20 09:49:21 edk Exp $
d86 1
a86 1
            prefixRE= new RE("^[- a-zA-Z0-9_\\[\\]]+$");
d112 1
a112 1
    public static ArrayList parseEmailList (String list,
d125 7
a131 1
        return members;
@

