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;
23
24 import org.apache.james.transport.mailets.listservcommands.IListServCommand;
25 import org.apache.james.api.user.UsersRepository;
26 import org.apache.james.util.XMLResources;
27 import org.apache.mailet.Mailet;
28 import org.apache.mailet.Mail;
29 import org.apache.mailet.MailAddress;
30 import org.apache.avalon.framework.configuration.ConfigurationException;
31
32 import javax.mail.MessagingException;
33 import java.util.Map;
34 import java.util.Properties;
35
36 /**
37 * ICommandListservManager is the interface that describes the functionality of any
38 * command based list serv managers.
39 *
40 * In order to obtain a reference to one, you can call:
41 * <pre>
42 * ICommandListservManager mgr = (ICommandListservManager)mailetContext.getAttribute(ICommandListservManager.ID + listName);
43 * </pre>
44 *
45 * @version CVS $Revision: 684466 $ $Date: 2008-08-10 12:42:08 +0100 (Sun, 10 Aug 2008) $
46 * @since 2.2.0
47 */
48 public interface ICommandListservManager extends Mailet {
49
50 public static final String ID = ICommandListservManager.class.getName();
51
52 /**
53 * Get the name of this list
54 * @param displayFormat is whether you want a display version of this or not
55 * @return the official display name of this list
56 */
57 public String getListName(boolean displayFormat);
58
59 /**
60 * Gets the owner of this list
61 * @return this is an address like listOwner@localhost
62 */
63 public String getListOwner();
64
65 /**
66 * Get the domain of the list
67 * @return a string like localhost
68 */
69 public String getListDomain();
70
71 /**
72 * Get a specific command
73 * @param name case in-sensitive
74 * @return a {@link IListServCommand} if found, null otherwise
75 */
76 public IListServCommand getCommand(String name);
77
78 /**
79 * Get all the available commands
80 * @return a map of {@link IListServCommand}s
81 */
82 public Map getCommands();
83
84 /**
85 * Based on the to address get a valid or command or null
86 * @param mailAddress
87 * @return IListServCommand or null
88 */
89 public IListServCommand getCommandTarget(MailAddress mailAddress);
90
91 /**
92 * Get the current user repository for this list serv
93 * @return an instance of {@link UsersRepository} that is used for the member list of the list serv
94 */
95 public UsersRepository getUsersRepository();
96
97 /**
98 * An error occurred, send some sort of message to the sender
99 * @param subject the subject of the message to send
100 * @param mail
101 * @param errorMessage
102 */
103 public void onError(Mail mail, String subject, String errorMessage) throws MessagingException;
104
105 /**
106 * @return the configuration file for the xml resources
107 */
108 public String getResourcesFile();
109
110 /**
111 * Use this to get standard properties for future calls to {@link org.apache.james.util.XMLResources}
112 * @return properties with the "LIST_NAME" and the "DOMAIN_NAME" properties
113 */
114 public Properties getStandardProperties();
115
116 /**
117 * Initializes an array of resources
118 * @param names such as 'header, footer' etc...
119 * @return an initialized array of XMLResources
120 * @throws org.apache.avalon.framework.configuration.ConfigurationException
121 */
122 public XMLResources[] initXMLResources(String[] names) throws ConfigurationException;
123 }