1 /****************************************************************
2 * Licensed to the Apache Software Foundation (ASF) under one *
3 * or more contributor license agreements. See the NOTICE file *
4 * distributed with this work for additional information *
5 * regarding copyright ownership. The ASF licenses this file *
6 * to you under the Apache License, Version 2.0 (the *
7 * "License"); you may not use this file except in compliance *
8 * with the License. You may obtain a copy of the License at *
9 * *
10 * http://www.apache.org/licenses/LICENSE-2.0 *
11 * *
12 * Unless required by applicable law or agreed to in writing, *
13 * software distributed under the License is distributed on an *
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
15 * KIND, either express or implied. See the License for the *
16 * specific language governing permissions and limitations *
17 * under the License. *
18 ****************************************************************/
19
20
21
22 package org.apache.james.transport.mailets.listservcommands;
23
24 import org.apache.mailet.Mail;
25 import org.apache.mailet.MailAddress;
26 import org.apache.avalon.framework.configuration.ConfigurationException;
27 import org.apache.avalon.framework.configuration.Configuration;
28 import org.apache.james.transport.mailets.ICommandListservManager;
29
30 import javax.mail.MessagingException;
31 import javax.mail.internet.ParseException;
32 import java.util.List;
33 import java.util.ArrayList;
34
35 /**
36 * This command will send email to the current owner(s) of this mailing list
37 *
38 * @version CVS $Revision: 426007 $ $Date: 2006-07-27 09:52:06 +0100 (Thu, 27 Jul 2006) $
39 * @since 2.2.0
40 */
41 public class Owner extends BaseCommand {
42
43 protected List m_listOwner = new ArrayList();
44
45 /**
46 * Perform any required initialization
47 * @param configuration
48 * @throws ConfigurationException
49 */
50 public void init(ICommandListservManager commandListservManager, Configuration configuration) throws ConfigurationException {
51 super.init(commandListservManager, configuration);
52 try {
53 m_listOwner.add(new MailAddress(getCommandListservManager().getListOwner()));
54 } catch (ParseException e) {
55 throw new ConfigurationException(e.getMessage(), e);
56 }
57 }
58
59 /**
60 * Process this command to your hearts content
61 * @param mail
62 * @throws MessagingException
63 */
64 public void onCommand(Mail mail) throws MessagingException {
65 getMailetContext().sendMail(mail.getSender(), m_listOwner, mail.getMessage());
66 }
67 }