KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > acting > SendmailAction


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.acting;
17
18 import org.apache.avalon.framework.parameters.Parameters;
19
20 import org.apache.cocoon.environment.ObjectModelHelper;
21 import org.apache.cocoon.environment.Redirector;
22 import org.apache.cocoon.environment.Request;
23 import org.apache.cocoon.environment.SourceResolver;
24
25 import java.util.Map JavaDoc;
26
27 /**
28  * The SendmailAction class sends email. Please use the {@link Sendmail Sendmail}
29  * action instead. The action needs four parameters:
30  *
31  * <dl>
32  * <dt>from</dt>
33  * <dd>the email address the mail appears to be from</dd>
34  * <dt>to</dt>
35  * <dd>the email address(es) the mail it sent to</dd>
36  * <dt>replyTo</dt>
37  * <dd>the email address(es) replies should be sent to</dd>
38  * <dt>subject</dt>
39  * <dd>the subject of the email</dd>
40  * <dt>body</dt>
41  * <dd>the body of the email</dd>
42  * </dl>
43  *
44  * Action attempts to get all of these parameters from the sitemap, but
45  * if they do not exist there it will read them from the request parameters.
46  *
47  * <p>It also supports all of the {@link Sendmail} action sitemap parameters</p>
48  *
49  * @deprecated Please use the {@link Sendmail Sendmail} action instead.
50  * @author <a HREF="mailto:balld@apache.org">Donald Ball</a>
51  * @author <a HREF="mailto:haul@apache.org">Christian Haul</a>
52  * @version CVS $Id: SendmailAction.java 155031 2005-02-23 17:32:37Z vgritsenko $
53  */

54 public class SendmailAction extends Sendmail {
55
56     public Map JavaDoc act(Redirector redirector,
57                    SourceResolver resolver,
58                    Map JavaDoc objectModel,
59                    String JavaDoc source,
60                    Parameters parameters)
61     throws Exception JavaDoc {
62
63         Request request = ObjectModelHelper.getRequest(objectModel);
64         if (!parameters.isParameter("from")) {
65             parameters.setParameter("from", request.getParameter("from"));
66         }
67         if (!parameters.isParameter("to")) {
68             parameters.setParameter("to", request.getParameter("to"));
69         }
70         if (!parameters.isParameter("replyTo")) {
71             parameters.setParameter("replyTo", request.getParameter("replyTo"));
72         }
73         if (!parameters.isParameter("subject")) {
74             parameters.setParameter("subject", request.getParameter("subject"));
75         }
76         if (!parameters.isParameter("body")) {
77             parameters.setParameter("body", request.getParameter("body"));
78         }
79
80         return super.act(redirector, resolver, objectModel, source, parameters);
81     }
82 }
83
Popular Tags