001: /**
002: * Copyright (c) 2003-2007, David A. Czarnecki
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms, with or without
006: * modification, are permitted provided that the following conditions are met:
007: *
008: * Redistributions of source code must retain the above copyright notice, this list of conditions and the
009: * following disclaimer.
010: * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
011: * following disclaimer in the documentation and/or other materials provided with the distribution.
012: * Neither the name of "David A. Czarnecki" and "blojsom" nor the names of its contributors may be used to
013: * endorse or promote products derived from this software without specific prior written permission.
014: * Products derived from this software may not be called "blojsom", nor may "blojsom" appear in their name,
015: * without prior written permission of David A. Czarnecki.
016: *
017: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
018: * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
019: * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
020: * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
021: * EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
022: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
023: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
024: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
025: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
026: * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
027: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
028: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
029: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
030: */package org.blojsom.plugin.moblog;
031:
032: import org.blojsom.util.BlojsomUtils;
033:
034: import java.util.HashMap;
035: import java.util.Map;
036:
037: /**
038: * Mailbox.
039: * <p/>
040: * This file is a container for everything the thread will need to connect to and to store into.
041: *
042: * @author David Czarnecki
043: * @author Mark Lussier
044: * @version $Id: Mailbox.java,v 1.3 2007/01/17 02:35:11 czarneckid Exp $
045: * @since blojsom 3.0
046: */
047: public class Mailbox {
048:
049: private static final String DEFAULT_FOLDER = "INBOX";
050:
051: private Integer _id;
052: private String _blogId;
053: private String _hostName;
054: private String _userId;
055: private String _password;
056: private String _folder = DEFAULT_FOLDER;
057: private String _outputDirectory;
058: private String _entriesDirectory;
059: private String _categoryId;
060: private String _urlPrefix;
061: private String _secretWord;
062: private boolean _enabled;
063: private Map _imageMimeTypes;
064: private Map _attachmentMimeTypes;
065: private Map _textMimeTypes;
066: private Map _authorizedAddresses;
067: private String _ignoreExpression;
068: private String _blogBaseURL;
069:
070: /**
071: * Default constructor.
072: */
073: public Mailbox() {
074: _enabled = false;
075: _imageMimeTypes = new HashMap();
076: _attachmentMimeTypes = new HashMap();
077: _textMimeTypes = new HashMap();
078: _authorizedAddresses = new HashMap();
079: }
080:
081: /**
082: * Construct a new mailbox for a given hostname, user, and password.
083: *
084: * @param hostname Mailbox hostname
085: * @param userid Mailbox user id
086: * @param password Mailbox user password
087: */
088: public Mailbox(String hostname, String userid, String password) {
089: _hostName = hostname;
090: _userId = userid;
091: _password = password;
092: }
093:
094: /**
095: * Retrieve the mailbox hostname
096: *
097: * @return Mailbox hostname (e.g. mail.domain.com)
098: */
099: public String getHostName() {
100: return _hostName;
101: }
102:
103: /**
104: * Set the mailbox hostname
105: *
106: * @param hostName Mailbox hostname (e.g. mail.domain.com)
107: */
108: public void setHostName(String hostName) {
109: _hostName = hostName;
110: }
111:
112: /**
113: * Retreive the mailbox user id
114: *
115: * @return Mailbox user id
116: */
117: public String getUserId() {
118: return _userId;
119: }
120:
121: /**
122: * Set the mailbox user id
123: *
124: * @param userId Mailbox user id
125: */
126: public void setUserId(String userId) {
127: _userId = userId;
128: }
129:
130: /**
131: * Retrieve the mailbox user password
132: *
133: * @return Mailbox user password
134: */
135: public String getPassword() {
136: return _password;
137: }
138:
139: /**
140: * Set the mailbox user password
141: *
142: * @param password Mailbox user password
143: */
144: public void setPassword(String password) {
145: _password = password;
146: }
147:
148: /**
149: * Retrieve the mail folder
150: *
151: * @return Mail folder
152: */
153: public String getFolder() {
154: return _folder;
155: }
156:
157: /**
158: * Set the mail folder
159: *
160: * @param folder Mail folder
161: */
162: public void setFolder(String folder) {
163: _folder = folder;
164: }
165:
166: /**
167: * Retrieve the output directory where attachments will be written
168: *
169: * @return Output directory
170: */
171: public String getOutputDirectory() {
172: return _outputDirectory;
173: }
174:
175: /**
176: * Set the output directory where attachments will be written
177: *
178: * @param outputDirectory Output directory
179: */
180: public void setOutputDirectory(String outputDirectory) {
181: _outputDirectory = outputDirectory;
182: }
183:
184: /**
185: * Retrieve the URL prefix for linking to attachments
186: *
187: * @return URL prefix (e.g. http://www.blog.com/resources/)
188: */
189: public String getUrlPrefix() {
190: return _urlPrefix;
191: }
192:
193: /**
194: * Set the URL prefix for linking to attachments
195: *
196: * @param urlPrefix (e.g. http://www.blog.com/resources/)
197: */
198: public void setUrlPrefix(String urlPrefix) {
199: _urlPrefix = urlPrefix;
200: }
201:
202: /**
203: * Retrive the directory where new blog entries will be created
204: *
205: * @return Entries directory
206: */
207: public String getEntriesDirectory() {
208: return _entriesDirectory;
209: }
210:
211: /**
212: * Set the directory where new blog entries will be created
213: *
214: * @param entriesDirectory Entries directory
215: */
216: public void setEntriesDirectory(String entriesDirectory) {
217: _entriesDirectory = entriesDirectory;
218: }
219:
220: /**
221: * Retrieve the category ID for new moblog entries
222: *
223: * @return Category ID
224: */
225: public String getCategoryId() {
226: return _categoryId;
227: }
228:
229: /**
230: * Set the category ID for new moblog entries
231: *
232: * @param categoryId Category ID
233: */
234: public void setCategoryId(String categoryId) {
235: _categoryId = categoryId;
236: }
237:
238: /**
239: * Retrieve whether or not this mailbox is enabled
240: *
241: * @return <code>true</code> if the mailbox is enabled, <code>false</code> otherwise
242: */
243: public boolean isEnabled() {
244: return _enabled;
245: }
246:
247: /**
248: * Set whether or not this mailbox is enabled
249: *
250: * @param enabled <code>true</code> if the mailbox is enabled, <code>false</code> otherwise
251: */
252: public void setEnabled(boolean enabled) {
253: _enabled = enabled;
254: }
255:
256: /**
257: * Retrieve the {@link Map} of image mime-types
258: *
259: * @return {@link Map} of image mime-types
260: */
261: public Map getImageMimeTypes() {
262: return _imageMimeTypes;
263: }
264:
265: /**
266: * Retrieve the accepted image MIME types as a string list
267: *
268: * @return String list of accepted image mime types
269: */
270: public String getImageMimeTypesAsStringList() {
271: return BlojsomUtils.getKeysAsStringList(_imageMimeTypes);
272: }
273:
274: /**
275: * Set the {@link Map} of image mime-types
276: *
277: * @param imageMimeTypes {@link Map} of image mime-types
278: */
279: public void setImageMimeTypes(Map imageMimeTypes) {
280: _imageMimeTypes = imageMimeTypes;
281: }
282:
283: /**
284: * Retrieve the {@link Map} of attachment mime-types
285: *
286: * @return {@link Map} of image mime-types
287: */
288: public Map getAttachmentMimeTypes() {
289: return _attachmentMimeTypes;
290: }
291:
292: /**
293: * Retrieve the accepted attachment MIME types as a string list
294: *
295: * @return String list of accepted attachment mime types
296: */
297: public String getAttachmentMimeTypesAsStringList() {
298: return BlojsomUtils.getKeysAsStringList(_attachmentMimeTypes);
299: }
300:
301: /**
302: * Set the {@link Map} of attachment mime-types
303: *
304: * @param attachmentMimeTypes {@link Map} of attachment mime-types
305: */
306: public void setAttachmentMimeTypes(Map attachmentMimeTypes) {
307: _attachmentMimeTypes = attachmentMimeTypes;
308: }
309:
310: /**
311: * Retrieve the {@link Map} of text mime-types
312: *
313: * @return {@link Map} of image mime-types
314: */
315: public Map getTextMimeTypes() {
316: return _textMimeTypes;
317: }
318:
319: /**
320: * Retrieve the accepted text MIME types as a string list
321: *
322: * @return String list of accepted text mime types
323: */
324: public String getTextMimeTypesAsStringList() {
325: return BlojsomUtils.getKeysAsStringList(_textMimeTypes);
326: }
327:
328: /**
329: * Set the {@link Map} of text mime-types
330: *
331: * @param textMimeTypes {@link Map} of text mime-types
332: */
333: public void setTextMimeTypes(Map textMimeTypes) {
334: _textMimeTypes = textMimeTypes;
335: }
336:
337: /**
338: * Retrieve the secret word for this mailbox
339: *
340: * @return Secret word which must be present at the start of the subject of the e-mail
341: */
342: public String getSecretWord() {
343: return _secretWord;
344: }
345:
346: /**
347: * Set the secret word for this mailbox.
348: *
349: * @param secretWord Secret word which must be present at the start of the subject of the e-mail
350: */
351: public void setSecretWord(String secretWord) {
352: _secretWord = secretWord;
353: }
354:
355: /**
356: * Retrieve the authorized e-mail from addresses for this mailbox
357: *
358: * @return Authorized e-mail from addresses for this mailbox
359: */
360: public Map getAuthorizedAddresses() {
361: return _authorizedAddresses;
362: }
363:
364: /**
365: * Set the authorized e-mail from addresses for this mailbox
366: *
367: * @param authorizedAddresses Authorized e-mail from addresses for this mailbox
368: */
369: public void setAuthorizedAddresses(Map authorizedAddresses) {
370: _authorizedAddresses = authorizedAddresses;
371: }
372:
373: /**
374: * Retrieve the regular expression for ignoring bits of text
375: *
376: * @return Regular expression for ignoring bits of text
377: */
378: public String getIgnoreExpression() {
379: return _ignoreExpression;
380: }
381:
382: /**
383: * Set the regular expression for ignoring bits of text
384: *
385: * @param ignoreExpression Regular expression for ignoring bits of text
386: */
387: public void setIgnoreExpression(String ignoreExpression) {
388: _ignoreExpression = ignoreExpression;
389: }
390:
391: /**
392: * Get the blog ID
393: *
394: * @return Blog ID
395: */
396: public String getBlogId() {
397: return _blogId;
398: }
399:
400: /**
401: * Set the blog ID
402: *
403: * @param blogId Blog ID
404: */
405: public void setBlogId(String blogId) {
406: _blogId = blogId;
407: }
408:
409: /**
410: * Get the ID of the blog
411: *
412: * @return ID of the blog
413: */
414: public Integer getId() {
415: return _id;
416: }
417:
418: /**
419: * Set the ID of the blog
420: *
421: * @param id ID of the blog
422: */
423: public void setId(Integer id) {
424: _id = id;
425: }
426:
427: /**
428: * Get the blog base URL
429: *
430: * @return Blog base URL
431: */
432: public String getBlogBaseURL() {
433: return _blogBaseURL;
434: }
435:
436: /**
437: * Set the blog base URL
438: *
439: * @param blogBaseURL Blog base URL
440: */
441: public void setBlogBaseURL(String blogBaseURL) {
442: _blogBaseURL = blogBaseURL;
443: }
444: }
|