Source Code Cross Referenced for InboxControllerBase.java in  » Web-Mail » claros-intouch2-2.2-beta » org » claros » intouch » webmail » controllers » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Mail » claros intouch2 2.2 beta » org.claros.intouch.webmail.controllers 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.claros.intouch.webmail.controllers;
002:
003:        import javax.mail.Message;
004:
005:        import org.claros.commons.auth.models.AuthProfile;
006:        import org.claros.commons.configuration.PropertyFile;
007:        import org.claros.commons.mail.models.ConnectionMetaHandler;
008:        import org.claros.commons.mail.models.ConnectionProfile;
009:        import org.claros.intouch.webmail.factory.FolderControllerFactory;
010:        import org.claros.intouch.webmail.models.FolderDbObject;
011:
012:        /**
013:         * @author Umut Gokbayrak
014:         */
015:        public class InboxControllerBase {
016:            protected ConnectionProfile profile;
017:            protected AuthProfile auth;
018:            protected ConnectionMetaHandler handler = null;
019:
020:            /**
021:             * 
022:             * @param profile
023:             * @param auth
024:             * @param handler
025:             */
026:            public InboxControllerBase(AuthProfile auth,
027:                    ConnectionProfile profile, ConnectionMetaHandler handler) {
028:                this .profile = profile;
029:                this .auth = auth;
030:                this .handler = handler;
031:            }
032:
033:            /**
034:             * @param auth
035:             * @param msg
036:             * @return
037:             */
038:            public String findDestinationFolderId(Message msg) throws Exception {
039:                String strSpamCheck = PropertyFile.getConfiguration(
040:                        "/config/config.xml").getString(
041:                        "common-params.spam-check-enabled");
042:                boolean spamEnabled = false;
043:                try {
044:                    spamEnabled = Boolean.valueOf(strSpamCheck).booleanValue();
045:                } catch (Exception e) {
046:                }
047:
048:                boolean isSpam = false;
049:                if (spamEnabled) {
050:                    isSpam = SpamController.isSpam(auth, msg);
051:                }
052:                FolderControllerFactory factory = new FolderControllerFactory(
053:                        auth, profile, handler);
054:                FolderController fc = factory.getFolderController();
055:                String folderId = null;
056:                FolderDbObject folder = null;
057:
058:                if (isSpam) {
059:                    folder = fc.getJunkFolder();
060:                    if (profile.getProtocol().equals(
061:                            org.claros.commons.mail.utility.Constants.POP3)) {
062:                        folderId = folder.getId().toString();
063:                    } else {
064:                        folderId = folder.getFolderName();
065:                    }
066:                } else {
067:                    folder = fc.getInboxFolder();
068:                    if (profile.getProtocol().equals(
069:                            org.claros.commons.mail.utility.Constants.POP3)) {
070:                        folderId = folder.getId().toString();
071:                    } else {
072:                        folderId = folder.getFolderName();
073:                    }
074:                }
075:                return folderId;
076:
077:                /*
078:                // search if any user specified filter matches the content
079:                List filters = FilterController.getFilters(auth);
080:                if (filters != null) {
081:                	Filter filter = null;
082:                	for (int i=0; i<filters.size(); i++) {
083:                		filter = (Filter)filters.get(i);
084:                		String fPort = filter.getPortion();
085:                		String mPort = getPortion(msg, fPort).toUpperCase();
086:                		String fCond = filter.getCondition();
087:                		String fKeyWord = filter.getKeyword().toUpperCase();
088:                		if (fCond.equals(Constants.CONDITION_CONTAINS)) {
089:                			if (mPort.indexOf(fKeyWord) >= 0) {
090:                				if (filter.getAction().equals(Constants.ACTION_DELETE)) {
091:                					return null;
092:                				} else {
093:                					return filter.getDestination();
094:                				}
095:                			}
096:                		} else if (fCond.equals(Constants.CONDITION_EQUALS)) {
097:                			if (mPort.equals(fKeyWord)) {
098:                				if (filter.getAction().equals(Constants.ACTION_DELETE)) {
099:                					return null;
100:                				} else {
101:                					return filter.getDestination();
102:                				}
103:                			}
104:                		} if (fCond.equals(Constants.CONDITION_NOT_CONTAINS)) {
105:                			if (mPort.indexOf(fKeyWord) < 0) {
106:                				if (filter.getAction().equals(Constants.ACTION_DELETE)) {
107:                					return null;
108:                				} else {
109:                					return filter.getDestination();
110:                				}
111:                			}
112:                		}
113:                	}
114:                }
115:
116:                // if at the preferences page, user clicked not to perform a spam 
117:                // check on the contacts in address book.
118:                String safe = UserPrefsController.getUserSetting(auth, UserPrefConstants.safeContacts);
119:                if (safe == null) {
120:                	safe = "no";
121:                }
122:                boolean isSafe = (safe.equals("yes") ? true : false);
123:                boolean contactIsSafe = false;
124:                if (isSafe) {
125:                	// check to see if the user exists in the address book
126:                	Address[] adrs = msg.getFrom();
127:                	if (adrs != null && adrs.length == 1) {
128:                		Address adr = adrs[0];
129:                		if (adr instanceof InternetAddress) {
130:                			InternetAddress iAdr = (InternetAddress)adr;
131:                			Contact tmp = ContactsController.searchContactByEmail(auth.getUsername(), iAdr.getAddress());
132:                			if (tmp != null) {
133:                				contactIsSafe = true;
134:                			}
135:                		}
136:                	}
137:                }
138:
139:                FolderControllerFactory factory = new FolderControllerFactory(auth, profile, handler);
140:                FolderController fc = factory.getFolderController();
141:
142:                String folderId = null;
143:                FolderDbItem folder = null;
144:                if (!contactIsSafe) {
145:                	// none of the user specified filters matched. Do spam filtering.
146:                	// if enabled do spam analysis and probability is higher than
147:                	// user accepts, move it to junk mail folder.
148:                	boolean isSpam = false;
149:                	try {
150:                		isSpam = SpamController.isSpam(auth, msg);
151:                	} catch (Exception e) {
152:                		// if spam controller can no parse the message it is 
153:                		// probable that it is an illegal format. Treat as spam.
154:                		isSpam = true;
155:                	}
156:                	if (isSpam) {
157:                		folder = fc.getJunkFolder();
158:                		if (profile.getProtocol().equals(org.claros.commons.mail.utility.Constants.POP3)) {
159:                			folderId = folder.getId().toString();
160:                		} else {
161:                			folderId = folder.getFolderName();
162:                		}
163:                	} else {
164:                		folder = fc.getInboxFolder();
165:                		if (profile.getProtocol().equals(org.claros.commons.mail.utility.Constants.POP3)) {
166:                			folderId = folder.getId().toString();
167:                		} else {
168:                			folderId = folder.getFolderName();
169:                		}
170:                	}
171:                } else {
172:                	// if the contact is safe deliver mail to INBOX
173:                	folder = fc.getInboxFolder();
174:                	if (profile.getProtocol().equals(org.claros.commons.mail.utility.Constants.POP3)) {
175:                		folderId = folder.getId().toString();
176:                	} else {
177:                		folderId = org.claros.commons.mail.utility.Constants.FOLDER_INBOX;
178:                	}
179:                }
180:                return folderId;
181:                 */
182:            }
183:
184:            /**
185:             * @param msg
186:             * @param fPort
187:             * @return
188:             */
189:            /*
190:            private String getPortion(Message msg, String fPort) throws MessagingException {
191:            	if (fPort.equals(Constants.PORTION_SUBJECT)) {
192:            		return msg.getSubject();
193:            	} else if (fPort.equals(Constants.PORTION_FROM)) {
194:            		return Utility.addressArrToString(msg.getFrom());
195:            	} else if (fPort.equals(Constants.PORTION_TO)) {
196:            		return Utility.addressArrToString(msg.getRecipients(Message.RecipientType.TO));
197:            	} else if (fPort.equals(Constants.PORTION_CC)) {
198:            		return Utility.addressArrToString(msg.getRecipients(Message.RecipientType.CC));
199:            	} else if (fPort.equals(Constants.PORTION_MESSAGE_BODY)) {
200:            		Email email = MessageParser.parseMessage(msg);
201:            		return email.getBodyText();
202:            	}
203:            	return "";
204:            }
205:             */
206:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.