001: package org.contineo.core.communication;
002:
003: import java.util.StringTokenizer;
004:
005: import org.contineo.core.security.Menu;
006:
007: /**
008: * E-Mail account
009: *
010: * @author Michael Scholz, Marco Meschieri
011: */
012: public class EMailAccount {
013: private static final long serialVersionUID = 1L;
014:
015: private int accountId;
016:
017: private String userName;
018:
019: private String mailAddress;
020:
021: private String provider;
022:
023: private String host;
024:
025: private String port;
026:
027: private String accountUser;
028:
029: private String accountPassword;
030:
031: private Menu targetFolder;
032:
033: // Used only by Struts
034: private Integer targetFolderId;
035:
036: // Comma separated list of allowed extesions
037: private String allowedTypes = "pdf,doc,txt";
038:
039: private String language = "";
040:
041: private int deleteFromMailbox = 0;
042:
043: private int enabled = 1;
044:
045: /** Creates a new instance of EMailAccount */
046: public EMailAccount() {
047: accountId = 0;
048: userName = "";
049: mailAddress = "";
050: provider = "";
051: host = "";
052: port = "";
053: accountUser = "";
054: accountPassword = "";
055: targetFolder = null;
056: targetFolderId = null;
057: }
058:
059: public int getDeleteFromMailbox() {
060: return deleteFromMailbox;
061: }
062:
063: public void setDeleteFromMailbox(int deleteFromMailbox) {
064: if ((deleteFromMailbox < 0) || (deleteFromMailbox > 1)) {
065: this .deleteFromMailbox = 0;
066: } else {
067: this .deleteFromMailbox = deleteFromMailbox;
068: }
069: }
070:
071: public String getAllowedTypes() {
072: return allowedTypes;
073: }
074:
075: public void setAllowedTypes(String allowedTypes) {
076: this .allowedTypes = allowedTypes;
077: }
078:
079: public String getLanguage() {
080: return language;
081: }
082:
083: public void setLanguage(String language) {
084: this .language = language;
085: }
086:
087: public Integer getTargetFolderId() {
088: return targetFolderId;
089: }
090:
091: public void setTargetFolderId(Integer targetFolderId) {
092: this .targetFolderId = targetFolderId;
093: }
094:
095: public int getAccountId() {
096: return accountId;
097: }
098:
099: public String getMailAddress() {
100: return mailAddress;
101: }
102:
103: public String getProvider() {
104: return provider;
105: }
106:
107: public String getHost() {
108: return host;
109: }
110:
111: public String getPort() {
112: return port;
113: }
114:
115: public String getAccountUser() {
116: return accountUser;
117: }
118:
119: public String getAccountPassword() {
120: return accountPassword;
121: }
122:
123: public void setAccountId(int id) {
124: accountId = id;
125: }
126:
127: public void setMailAddress(String address) {
128: mailAddress = address;
129: }
130:
131: public void setProvider(String prov) {
132: provider = prov;
133: }
134:
135: public void setHost(String hst) {
136: host = hst;
137: }
138:
139: public void setPort(String prt) {
140: port = prt;
141: }
142:
143: public void setAccountUser(String auser) {
144: accountUser = auser;
145: }
146:
147: public void setAccountPassword(String apwd) {
148: accountPassword = apwd;
149: }
150:
151: public Menu getTargetFolder() {
152: return targetFolder;
153: }
154:
155: public void setTargetFolder(Menu targetFolder) {
156: this .targetFolder = targetFolder;
157: if (targetFolder != null)
158: this .targetFolderId = targetFolder.getMenuId();
159: else
160: this .targetFolderId = null;
161: }
162:
163: public String getUserName() {
164: return userName;
165: }
166:
167: public void setUserName(String userName) {
168: this .userName = userName;
169: }
170:
171: public int getEnabled() {
172: return enabled;
173: }
174:
175: public void setEnabled(int enabled) {
176: this .enabled = enabled;
177: }
178:
179: /**
180: * Check if the specified type is allowed or not.
181: *
182: * @param type The type to check
183: * @return True if <code>type</code> is included in
184: * <code>allowedTypes</code>
185: */
186: public boolean isAllowed(String type) {
187: StringTokenizer st = new StringTokenizer(allowedTypes, ",",
188: false);
189: while (st.hasMoreTokens()) {
190: if (st.nextToken().equalsIgnoreCase(type))
191: return true;
192:
193: }
194: return false;
195: }
196:
197: public void reset() {
198: accountId = 0;
199: mailAddress = "";
200: provider = "";
201: host = "";
202: port = "";
203: userName = "";
204: accountUser = "";
205: accountPassword = "";
206: targetFolder = null;
207: targetFolderId = null;
208: language = "";
209: deleteFromMailbox = 0;
210: }
211:
212: @Override
213: public String toString() {
214: return mailAddress;
215: }
216: }
|