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 package org.apache.james.postage.configuration;
22
23 import org.apache.james.postage.user.UserList;
24
25 import java.util.ArrayList;
26 import java.util.List;
27 import java.util.Collections;
28 import java.util.Iterator;
29 import java.util.LinkedHashMap;
30 import java.util.Map;
31
32 public class PostageConfiguration {
33 private String m_id;
34
35 private int m_durationMinutes = 10;
36
37 private boolean m_internalReuseExisting = true;
38
39 private Map m_descriptionItems = new LinkedHashMap();
40
41 private UserList m_externalUsers = null;
42
43 private UserList m_internalUsers = null;
44
45 private String m_testserverHost = null;
46
47 private int m_testserverPortSMTPForwarding = -1;
48
49 private int m_testserverSMTPForwardingWaitSeconds = 0;
50
51 private int m_testserverPortSMTPInbound = -1;
52
53 private int m_testserverPortPOP3 = -1;
54
55 private int m_testserverPOP3FetchesPerMinute = 1;
56
57 private int m_testserverRemoteManagerPort = -1;
58
59 private String m_testserverRemoteManagerUsername = null;
60
61 private String m_testserverRemoteManagerPassword = null;
62
63 private String m_testserverSpamAccountUsername = null;
64
65 private String m_testserverSpamAccountPassword = null;
66
67 private int m_testserverJMXRemotingPort = -1;
68
69 private List m_profiles = new ArrayList();
70
71 public PostageConfiguration(String id) {
72 m_id = id;
73 }
74
75 public String getId() {
76 return m_id;
77 }
78
79 public int getDurationMinutes() {
80 return m_durationMinutes;
81 }
82
83 public void setDurationMinutes(int durationMinutes) {
84 m_durationMinutes = durationMinutes;
85 }
86
87 public boolean isInternalReuseExisting() {
88 return m_internalReuseExisting;
89 }
90
91 public void addDescriptionItem(String name, String value) {
92 m_descriptionItems.put(name, value);
93 }
94
95 public Map getDescriptionItems() {
96 return Collections.unmodifiableMap(m_descriptionItems);
97 }
98
99 public void setInternalReuseExisting(boolean internalReuseExisting) {
100 m_internalReuseExisting = internalReuseExisting;
101 }
102
103 public UserList getExternalUsers() {
104 return m_externalUsers;
105 }
106
107 public void setExternalUsers(UserList externalUsers) {
108 m_externalUsers = externalUsers;
109 }
110
111 public UserList getInternalUsers() {
112 return m_internalUsers;
113 }
114
115 public void setInternalUsers(UserList internalUsers) {
116 m_internalUsers = internalUsers;
117 }
118
119 public String getTestserverHost() {
120 return m_testserverHost;
121 }
122
123 public void setTestserverHost(String testserverHost) {
124 m_testserverHost = testserverHost;
125 }
126
127 public int getTestserverPortSMTPForwarding() {
128 return m_testserverPortSMTPForwarding;
129 }
130
131 public void setTestserverPortSMTPForwarding(int testserverPortSMTPForwarding) {
132 m_testserverPortSMTPForwarding = testserverPortSMTPForwarding;
133 }
134
135 public int getTestserverSMTPForwardingWaitSeconds() {
136 return m_testserverSMTPForwardingWaitSeconds;
137 }
138
139 public void setTestserverSMTPForwardingWaitSeconds(int testserverSMTPForwardingWaitSeconds) {
140 m_testserverSMTPForwardingWaitSeconds = testserverSMTPForwardingWaitSeconds;
141 }
142
143 public int getTestserverPortSMTPInbound() {
144 return m_testserverPortSMTPInbound;
145 }
146
147 public void setTestserverPortSMTPInbound(int testserverPortSMTPInbound) {
148 m_testserverPortSMTPInbound = testserverPortSMTPInbound;
149 }
150
151 public int getTestserverPortPOP3() {
152 return m_testserverPortPOP3;
153 }
154
155 public void setTestserverPortPOP3(int testserverPortPOP3) {
156 m_testserverPortPOP3 = testserverPortPOP3;
157 }
158
159 public int getTestserverPOP3FetchesPerMinute() {
160 return m_testserverPOP3FetchesPerMinute;
161 }
162
163 public void setTestserverPOP3FetchesPerMinute(int testserverPOP3FetchesPerMinute) {
164 m_testserverPOP3FetchesPerMinute = testserverPOP3FetchesPerMinute;
165 }
166
167 public int getTestserverRemoteManagerPort() {
168 return m_testserverRemoteManagerPort;
169 }
170
171 public void setTestserverRemoteManagerPort(int testserverRemoteManagerPort) {
172 m_testserverRemoteManagerPort = testserverRemoteManagerPort;
173 }
174
175 public String getTestserverRemoteManagerUsername() {
176 return m_testserverRemoteManagerUsername;
177 }
178
179 public void setTestserverRemoteManagerUsername(String testserverRemoteManagerUsername) {
180 m_testserverRemoteManagerUsername = testserverRemoteManagerUsername;
181 }
182
183 public String getTestserverRemoteManagerPassword() {
184 return m_testserverRemoteManagerPassword;
185 }
186
187 public void setTestserverRemoteManagerPassword(String testserverRemoteManagerPassword) {
188 m_testserverRemoteManagerPassword = testserverRemoteManagerPassword;
189 }
190
191 public String getTestserverSpamAccountUsername() {
192 return m_testserverSpamAccountUsername;
193 }
194
195 public void setTestserverSpamAccountUsername(String testserverSpamAccountUsername) {
196 m_testserverSpamAccountUsername = testserverSpamAccountUsername;
197 }
198
199 public String getTestserverSpamAccountPassword() {
200 return m_testserverSpamAccountPassword;
201 }
202
203 public void setTestserverSpamAccountPassword(String testserverSpamAccountPassword) {
204 m_testserverSpamAccountPassword = testserverSpamAccountPassword;
205 }
206
207 public int getTestserverPortJMXRemoting() {
208 return m_testserverJMXRemotingPort;
209 }
210
211 public void setTestserverPortJMXRemoting(int testserverJMXRemotingPort) {
212 m_testserverJMXRemotingPort = testserverJMXRemotingPort;
213 }
214
215 public void addProfile(SendProfile profile) {
216 m_profiles.add(profile);
217 }
218
219 public List getProfiles() {
220 return Collections.unmodifiableList(m_profiles);
221 }
222
223 public SendProfile findProfile(boolean sourceInternal, boolean targetInternal) {
224 Iterator iterator = m_profiles.iterator();
225 while (iterator.hasNext()) {
226 SendProfile sendProfile = (SendProfile)iterator.next();
227 if (sendProfile.isSourceInternal() == sourceInternal && sendProfile.isTargetInternal() == targetInternal) {
228 return sendProfile;
229 }
230 }
231 return null;
232 }
233
234 public int getTotalMailsPerMin() {
235 Iterator iterator = m_profiles.iterator();
236 int total = 0;
237 while (iterator.hasNext()) {
238 SendProfile sendProfile = (SendProfile)iterator.next();
239 total += sendProfile.getTotalMailsPerMin();
240 }
241 return total;
242 }
243 }