KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > blojsom > plugin > moblog > Mailbox


1 /**
2  * Copyright (c) 2003-2006, David A. Czarnecki
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * Redistributions of source code must retain the above copyright notice, this list of conditions and the
9  * following disclaimer.
10  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
11  * following disclaimer in the documentation and/or other materials provided with the distribution.
12  * Neither the name of "David A. Czarnecki" and "blojsom" nor the names of its contributors may be used to
13  * endorse or promote products derived from this software without specific prior written permission.
14  * Products derived from this software may not be called "blojsom", nor may "blojsom" appear in their name,
15  * without prior written permission of David A. Czarnecki.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
18  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
19  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
21  * EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */

31 package org.blojsom.plugin.moblog;
32
33 import org.blojsom.util.BlojsomUtils;
34
35 import java.util.HashMap JavaDoc;
36 import java.util.Map JavaDoc;
37
38 /**
39  * Mailbox.
40  * <p/>
41  * This file is a container for everything the thread will need to connect to and to store into.
42  *
43  * @author David Czarnecki
44  * @author Mark Lussier
45  * @version $Id: Mailbox.java,v 1.2 2006/09/26 02:55:20 czarneckid Exp $
46  * @since blojsom 3.0
47  */

48 public class Mailbox {
49
50     private static final String JavaDoc DEFAULT_FOLDER = "INBOX";
51
52     private Integer JavaDoc _id;
53     private String JavaDoc _blogId;
54     private String JavaDoc _hostName;
55     private String JavaDoc _userId;
56     private String JavaDoc _password;
57     private String JavaDoc _folder = DEFAULT_FOLDER;
58     private String JavaDoc _outputDirectory;
59     private String JavaDoc _entriesDirectory;
60     private String JavaDoc _categoryId;
61     private String JavaDoc _urlPrefix;
62     private String JavaDoc _secretWord;
63     private boolean _enabled;
64     private Map JavaDoc _imageMimeTypes;
65     private Map JavaDoc _attachmentMimeTypes;
66     private Map JavaDoc _textMimeTypes;
67     private Map JavaDoc _authorizedAddresses;
68     private String JavaDoc _ignoreExpression;
69     private String JavaDoc _blogBaseURL;
70
71     /**
72      * Default constructor.
73      */

74     public Mailbox() {
75         _enabled = false;
76         _imageMimeTypes = new HashMap JavaDoc();
77         _attachmentMimeTypes = new HashMap JavaDoc();
78         _textMimeTypes = new HashMap JavaDoc();
79         _authorizedAddresses = new HashMap JavaDoc();
80     }
81
82     /**
83      * Construct a new mailbox for a given hostname, user, and password.
84      *
85      * @param hostname Mailbox hostname
86      * @param userid Mailbox user id
87      * @param password Mailbox user password
88      */

89     public Mailbox(String JavaDoc hostname, String JavaDoc userid, String JavaDoc password) {
90         _hostName = hostname;
91         _userId = userid;
92         _password = password;
93     }
94
95     /**
96      * Retrieve the mailbox hostname
97      *
98      * @return Mailbox hostname (e.g. mail.domain.com)
99      */

100     public String JavaDoc getHostName() {
101         return _hostName;
102     }
103
104     /**
105      * Set the mailbox hostname
106      *
107      * @param hostName Mailbox hostname (e.g. mail.domain.com)
108      */

109     public void setHostName(String JavaDoc hostName) {
110         _hostName = hostName;
111     }
112
113     /**
114      * Retreive the mailbox user id
115      *
116      * @return Mailbox user id
117      */

118     public String JavaDoc getUserId() {
119         return _userId;
120     }
121
122     /**
123      * Set the mailbox user id
124      *
125      * @param userId Mailbox user id
126      */

127     public void setUserId(String JavaDoc userId) {
128         _userId = userId;
129     }
130
131     /**
132      * Retrieve the mailbox user password
133      *
134      * @return Mailbox user password
135      */

136     public String JavaDoc getPassword() {
137         return _password;
138     }
139
140     /**
141      * Set the mailbox user password
142      *
143      * @param password Mailbox user password
144      */

145     public void setPassword(String JavaDoc password) {
146         _password = password;
147     }
148
149     /**
150      * Retrieve the mail folder
151      *
152      * @return Mail folder
153      */

154     public String JavaDoc getFolder() {
155         return _folder;
156     }
157
158     /**
159      * Set the mail folder
160      *
161      * @param folder Mail folder
162      */

163     public void setFolder(String JavaDoc folder) {
164         _folder = folder;
165     }
166
167     /**
168      * Retrieve the output directory where attachments will be written
169      *
170      * @return Output directory
171      */

172     public String JavaDoc getOutputDirectory() {
173         return _outputDirectory;
174     }
175
176     /**
177      * Set the output directory where attachments will be written
178      *
179      * @param outputDirectory Output directory
180      */

181     public void setOutputDirectory(String JavaDoc outputDirectory) {
182         _outputDirectory = outputDirectory;
183     }
184
185     /**
186      * Retrieve the URL prefix for linking to attachments
187      *
188      * @return URL prefix (e.g. http://www.blog.com/resources/)
189      */

190     public String JavaDoc getUrlPrefix() {
191         return _urlPrefix;
192     }
193
194     /**
195      * Set the URL prefix for linking to attachments
196      *
197      * @param urlPrefix (e.g. http://www.blog.com/resources/)
198      */

199     public void setUrlPrefix(String JavaDoc urlPrefix) {
200         _urlPrefix = urlPrefix;
201     }
202
203     /**
204      * Retrive the directory where new blog entries will be created
205      *
206      * @return Entries directory
207      */

208     public String JavaDoc getEntriesDirectory() {
209         return _entriesDirectory;
210     }
211
212     /**
213      * Set the directory where new blog entries will be created
214      *
215      * @param entriesDirectory Entries directory
216      */

217     public void setEntriesDirectory(String JavaDoc entriesDirectory) {
218         _entriesDirectory = entriesDirectory;
219     }
220
221     /**
222      * Retrieve the category ID for new moblog entries
223      *
224      * @return Category ID
225      */

226     public String JavaDoc getCategoryId() {
227         return _categoryId;
228     }
229
230     /**
231      * Set the category ID for new moblog entries
232      *
233      * @param categoryId Category ID
234      */

235     public void setCategoryId(String JavaDoc categoryId) {
236         _categoryId = categoryId;
237     }
238
239     /**
240      * Retrieve whether or not this mailbox is enabled
241      *
242      * @return <code>true</code> if the mailbox is enabled, <code>false</code> otherwise
243      */

244     public boolean isEnabled() {
245         return _enabled;
246     }
247
248     /**
249      * Set whether or not this mailbox is enabled
250      *
251      * @param enabled <code>true</code> if the mailbox is enabled, <code>false</code> otherwise
252      */

253     public void setEnabled(boolean enabled) {
254         _enabled = enabled;
255     }
256
257     /**
258      * Retrieve the {@link Map} of image mime-types
259      *
260      * @return {@link Map} of image mime-types
261      */

262     public Map JavaDoc getImageMimeTypes() {
263         return _imageMimeTypes;
264     }
265
266     /**
267      * Retrieve the accepted image MIME types as a string list
268      *
269      * @return String list of accepted image mime types
270      */

271     public String JavaDoc getImageMimeTypesAsStringList() {
272         return BlojsomUtils.getKeysAsStringList(_imageMimeTypes);
273     }
274
275     /**
276      * Set the {@link Map} of image mime-types
277      *
278      * @param imageMimeTypes {@link Map} of image mime-types
279      */

280     public void setImageMimeTypes(Map JavaDoc imageMimeTypes) {
281         _imageMimeTypes = imageMimeTypes;
282     }
283
284     /**
285      * Retrieve the {@link Map} of attachment mime-types
286      *
287      * @return {@link Map} of image mime-types
288      */

289     public Map JavaDoc getAttachmentMimeTypes() {
290         return _attachmentMimeTypes;
291     }
292
293     /**
294      * Retrieve the accepted attachment MIME types as a string list
295      *
296      * @return String list of accepted attachment mime types
297      */

298     public String JavaDoc getAttachmentMimeTypesAsStringList() {
299         return BlojsomUtils.getKeysAsStringList(_attachmentMimeTypes);
300     }
301
302     /**
303      * Set the {@link Map} of attachment mime-types
304      *
305      * @param attachmentMimeTypes {@link Map} of attachment mime-types
306      */

307     public void setAttachmentMimeTypes(Map JavaDoc attachmentMimeTypes) {
308         _attachmentMimeTypes = attachmentMimeTypes;
309     }
310
311     /**
312      * Retrieve the {@link Map} of text mime-types
313      *
314      * @return {@link Map} of image mime-types
315      */

316     public Map JavaDoc getTextMimeTypes() {
317         return _textMimeTypes;
318     }
319
320     /**
321      * Retrieve the accepted text MIME types as a string list
322      *
323      * @return String list of accepted text mime types
324      */

325     public String JavaDoc getTextMimeTypesAsStringList() {
326         return BlojsomUtils.getKeysAsStringList(_textMimeTypes);
327     }
328
329     /**
330      * Set the {@link Map} of text mime-types
331      *
332      * @param textMimeTypes {@link Map} of text mime-types
333      */

334     public void setTextMimeTypes(Map JavaDoc textMimeTypes) {
335         _textMimeTypes = textMimeTypes;
336     }
337
338     /**
339      * Retrieve the secret word for this mailbox
340      *
341      * @return Secret word which must be present at the start of the subject of the e-mail
342      */

343     public String JavaDoc getSecretWord() {
344         return _secretWord;
345     }
346
347     /**
348      * Set the secret word for this mailbox.
349      *
350      * @param secretWord Secret word which must be present at the start of the subject of the e-mail
351      */

352     public void setSecretWord(String JavaDoc secretWord) {
353         _secretWord = secretWord;
354     }
355
356     /**
357      * Retrieve the authorized e-mail from addresses for this mailbox
358      *
359      * @return Authorized e-mail from addresses for this mailbox
360      */

361     public Map JavaDoc getAuthorizedAddresses() {
362         return _authorizedAddresses;
363     }
364
365     /**
366      * Set the authorized e-mail from addresses for this mailbox
367      *
368      * @param authorizedAddresses Authorized e-mail from addresses for this mailbox
369      */

370     public void setAuthorizedAddresses(Map JavaDoc authorizedAddresses) {
371         _authorizedAddresses = authorizedAddresses;
372     }
373
374     /**
375      * Retrieve the regular expression for ignoring bits of text
376      *
377      * @return Regular expression for ignoring bits of text
378      */

379     public String JavaDoc getIgnoreExpression() {
380         return _ignoreExpression;
381     }
382
383     /**
384      * Set the regular expression for ignoring bits of text
385      *
386      * @param ignoreExpression Regular expression for ignoring bits of text
387      */

388     public void setIgnoreExpression(String JavaDoc ignoreExpression) {
389         _ignoreExpression = ignoreExpression;
390     }
391
392     /**
393      * Get the blog ID
394      *
395      * @return Blog ID
396      */

397     public String JavaDoc getBlogId() {
398         return _blogId;
399     }
400
401     /**
402      * Set the blog ID
403      *
404      * @param blogId Blog ID
405      */

406     public void setBlogId(String JavaDoc blogId) {
407         _blogId = blogId;
408     }
409
410     /**
411      * Get the ID of the blog
412      *
413      * @return ID of the blog
414      */

415     public Integer JavaDoc getId() {
416         return _id;
417     }
418
419     /**
420      * Set the ID of the blog
421      *
422      * @param id ID of the blog
423      */

424     public void setId(Integer JavaDoc id) {
425         _id = id;
426     }
427
428     /**
429      * Get the blog base URL
430      *
431      * @return Blog base URL
432      */

433     public String JavaDoc getBlogBaseURL() {
434         return _blogBaseURL;
435     }
436
437     /**
438      * Set the blog base URL
439      *
440      * @param blogBaseURL Blog base URL
441      */

442     public void setBlogBaseURL(String JavaDoc blogBaseURL) {
443         _blogBaseURL = blogBaseURL;
444     }
445 }
446
Popular Tags