View Javadoc

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  package org.apache.james.transport.mailets.listservcommands;
21  
22  import org.apache.mailet.Mail;
23  import org.apache.mailet.MailAddress;
24  import org.apache.avalon.framework.configuration.ConfigurationException;
25  import org.apache.avalon.framework.configuration.Configuration;
26  import org.apache.james.transport.mailets.ICommandListservManager;
27  
28  import javax.mail.MessagingException;
29  import javax.mail.internet.ParseException;
30  import java.util.List;
31  import java.util.ArrayList;
32  
33  /***
34   * This command will send email to the current owner(s) of this mailing list
35   *
36   * @version CVS $Revision: 494012 $ $Date: 2007-01-08 10:23:58 +0000 (lun, 08 gen 2007) $
37   * @since 2.2.0
38   */
39  public class Owner extends BaseCommand {
40  
41      protected List m_listOwner = new ArrayList();
42  
43      /***
44       * Perform any required initialization
45       * @param configuration
46       * @throws ConfigurationException
47       */
48      public void init(ICommandListservManager commandListservManager, Configuration configuration) throws ConfigurationException {
49          super.init(commandListservManager, configuration);
50          try {
51              m_listOwner.add(new MailAddress(getCommandListservManager().getListOwner()));
52          } catch (ParseException e) {
53              throw new ConfigurationException(e.getMessage(), e);
54          }
55      }
56  
57      /***
58       * Process this command to your hearts content
59       * @param mail
60       * @throws MessagingException
61       */
62      public void onCommand(Mail mail) throws MessagingException {
63          getMailetContext().sendMail(mail.getSender(), m_listOwner, mail.getMessage());
64      }
65  }