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