1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.james.transport.mailets.listservcommands;
23
24 import org.apache.avalon.framework.configuration.Configuration;
25 import org.apache.avalon.framework.configuration.ConfigurationException;
26 import org.apache.james.api.user.UsersRepository;
27 import org.apache.james.transport.mailets.ICommandListservManager;
28 import org.apache.james.util.XMLResources;
29 import org.apache.mailet.Mail;
30
31 import javax.mail.MessagingException;
32 import java.util.Iterator;
33 import java.util.Properties;
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 public class Info extends BaseCommand {
60
61
62 protected XMLResources[] xmlResources;
63
64 protected static final int HEADER = 0;
65 protected static final int INFO = 1;
66 protected static final int ADMIN_COMMANDS = 2;
67
68 public void init(ICommandListservManager commandListservManager, Configuration configuration) throws ConfigurationException {
69 super.init(commandListservManager, configuration);
70 xmlResources = initXMLResources(new String[]{"header", "info", "admincommands"});
71 }
72
73
74
75
76
77
78
79
80
81
82
83 public void onCommand(Mail mail) throws MessagingException {
84
85 Properties props = getStandardProperties();
86 props.put("MEMBER_LIST", getMemberList());
87
88 StringBuffer plainTextMessage = new StringBuffer();
89 String header = xmlResources[HEADER].getString("text", props);
90 plainTextMessage.append(header);
91
92 String infoMail = xmlResources[INFO].getString("text", props);
93 plainTextMessage.append(infoMail);
94
95 String adminCommands = xmlResources[ADMIN_COMMANDS].getString("text", props);
96 plainTextMessage.append(adminCommands);
97
98 String subject = xmlResources[INFO].getString("info.subject", props);
99
100 sendStandardReply(mail, subject, plainTextMessage.toString(), null);
101 }
102
103
104
105
106
107
108
109 protected String getMemberList() {
110
111 StringBuffer buffer = new StringBuffer(0x1000);
112 buffer.append("\r\n");
113 UsersRepository usersRepository = getUsersRepository();
114 for (Iterator it = usersRepository.list(); it.hasNext();) {
115 String userName = (String) it.next();
116 buffer.append(" ").append(userName);
117 buffer.append("\r\n");
118 }
119
120 return buffer.toString();
121 }
122 }