001: package org.claros.commons.mail.utility;
002:
003: import javax.mail.Folder;
004:
005: import org.claros.commons.configuration.PropertyFile;
006: import org.claros.commons.mail.models.ConnectionProfile;
007:
008: /**
009: * @author Umut Gokbayrak
010: *
011: */
012: public class Constants {
013: public static final String POP3 = "pop3";
014: public static final String IMAP = "imap";
015:
016: public static final int CONNECTION_READ_ONLY = Folder.READ_ONLY;
017: public static final int CONNECTION_READ_WRITE = Folder.READ_WRITE;
018:
019: private static String STR_FOLDER_INBOX = "INBOX";
020: private static String STR_FOLDER_JUNK = "Junk Mail";
021: private static String STR_FOLDER_SENT = "Sent Mail";
022: private static String STR_FOLDER_TRASH = "Trash";
023: private static String STR_FOLDER_DRAFTS = "Drafts";
024:
025: static {
026: try {
027: STR_FOLDER_DRAFTS = PropertyFile.getConfiguration(
028: "/config/config.xml").getString(
029: "mail-folder-names.folder-drafts");
030: } catch (Exception e) {
031: STR_FOLDER_DRAFTS = "Drafts";
032: }
033: try {
034: STR_FOLDER_JUNK = PropertyFile.getConfiguration(
035: "/config/config.xml").getString(
036: "mail-folder-names.folder-junk");
037: } catch (Exception e) {
038: STR_FOLDER_JUNK = "Junk Mail";
039: }
040: try {
041: STR_FOLDER_SENT = PropertyFile.getConfiguration(
042: "/config/config.xml").getString(
043: "mail-folder-names.folder-sent");
044: } catch (Exception e) {
045: STR_FOLDER_SENT = "Sent Mail";
046: }
047: try {
048: STR_FOLDER_TRASH = PropertyFile.getConfiguration(
049: "/config/config.xml").getString(
050: "mail-folder-names.folder-trash");
051: } catch (Exception e) {
052: STR_FOLDER_TRASH = "Trash";
053: }
054: }
055:
056: /**
057: *
058: * @param profile
059: * @return
060: */
061: public static String FOLDER_INBOX(ConnectionProfile profile) {
062: return STR_FOLDER_INBOX;
063: }
064:
065: /**
066: *
067: * @param profile
068: * @return
069: */
070: public static String FOLDER_JUNK(ConnectionProfile profile) {
071: if (profile.getProtocol().equals(IMAP)) {
072: return profile.getFolderNameSpace() + STR_FOLDER_JUNK;
073: }
074: return STR_FOLDER_JUNK;
075: }
076:
077: /**
078: *
079: * @param profile
080: * @return
081: */
082: public static String FOLDER_SENT(ConnectionProfile profile) {
083: if (profile.getProtocol().equals(IMAP)) {
084: return profile.getFolderNameSpace() + STR_FOLDER_SENT;
085: }
086: return STR_FOLDER_SENT;
087: }
088:
089: /**
090: *
091: * @param profile
092: * @return
093: */
094: public static String FOLDER_TRASH(ConnectionProfile profile) {
095: if (profile.getProtocol().equals(IMAP)) {
096: return profile.getFolderNameSpace() + STR_FOLDER_TRASH;
097: }
098: return STR_FOLDER_TRASH;
099: }
100:
101: /**
102: *
103: * @param profile
104: * @return
105: */
106: public static String FOLDER_DRAFTS(ConnectionProfile profile) {
107: if (profile.getProtocol().equals(IMAP)) {
108: return profile.getFolderNameSpace() + STR_FOLDER_DRAFTS;
109: }
110: return STR_FOLDER_DRAFTS;
111: }
112: }
|