Source Code Cross Referenced for view_mail.java in  » J2EE » Enhydra-Demos » scioworks » imap » presentation » imapWeb » 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 » J2EE » Enhydra Demos » scioworks.imap.presentation.imapWeb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* -----------------------------------------------------------------------------
002:         * Copyright (c) 2001, Low Kin Onn
003:         * All rights reserved.
004:         * Redistribution and use in source and binary forms, with or without
005:         * modification, are permitted provided that the following conditions are met:
006:         *
007:         *
008:         * Redistributions of source code must retain the above copyright notice, this
009:         * list of conditions and the following disclaimer.
010:         *
011:         * Redistributions in binary form must reproduce the above copyright notice,
012:         * this list of conditions and the following disclaimer in the documentation
013:         * and/or other materials provided with the distribution.
014:         *
015:         * Neither name of the Scioworks Pte. Ltd. nor the names of its contributors
016:         * may beused to endorse or promote products derived from this software without
017:         * specific prior written permission.
018:         *
019:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
020:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
021:         * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
022:         * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
023:         * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
024:         * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
025:         * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
026:         * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
027:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
028:         * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029:         *
030:         * -----------------------------------------------------------------------------
031:         */
032:
033:        package scioworks.imap.presentation.imapWeb;
034:
035:        import java.io.*;
036:        import java.net.URLEncoder;
037:        import java.util.Vector;
038:
039:        import javax.mail.*;
040:        import javax.mail.internet.*;
041:        import javax.activation.*;
042:
043:        import org.w3c.dom.*;
044:        import org.w3c.dom.html.*;
045:
046:        import com.lutris.appserver.server.httpPresentation.*;
047:
048:        import scioworks.imap.presentation.base.*;
049:        import scioworks.imap.presentation.imapWeb.*;
050:        import scioworks.imap.spec.beans.*;
051:        import scioworks.imap.spec.ImapWebException;
052:        import scioworks.imap.spec.util.*;
053:
054:        public class view_mail extends BasePO {
055:
056:            public String handleDefault() throws HttpPresentationException {
057:
058:                String fFolder = super .getStringParameter(PARAM_folder);
059:                long fMsgid = super .getLongParameter(PARAM_msgid);
060:
061:                try {
062:
063:                    IWMessage iwMsg = IWMessageFactory
064:                            .getIWMessage("scioworks.imap.business.beans.IWMessageImpl");
065:
066:                    Message msg = iwMsg.getMessage(super 
067:                            .getImapWebSessionData().getImapStore(), fFolder,
068:                            fMsgid);
069:                    // create the page
070:                    view_mailHTML page = (view_mailHTML) m_comms.xmlcFactory
071:                            .create(view_mailHTML.class);
072:
073:                    // set the hidden field values
074:                    ((HTMLInputElement) page.getElementFolder1())
075:                            .setValue(fFolder);
076:                    ((HTMLInputElement) page.getElementMsgid1()).setValue(Long
077:                            .toString(fMsgid));
078:
079:                    ((HTMLInputElement) page.getElementFolder2())
080:                            .setValue(fFolder);
081:                    ((HTMLInputElement) page.getElementMsgid2()).setValue(Long
082:                            .toString(fMsgid));
083:
084:                    ((HTMLInputElement) page.getElementFolder3())
085:                            .setValue(fFolder);
086:                    ((HTMLInputElement) page.getElementMsgid3()).setValue(Long
087:                            .toString(fMsgid));
088:
089:                    // set the drop down list of target folders for Move
090:                    Vector targetFolders = iwMsg.getFolderNames(super 
091:                            .getImapWebSessionData().getImapStore(), fFolder);
092:                    targetFolders.insertElementAt("-- Choose Folder --", 0);
093:                    super .processSelectList(page,
094:                            page.getElementTargetFolder(), targetFolders,
095:                            targetFolders, "-1");
096:
097:                    page.getElementDate().removeAttribute("id");
098:                    page.getElementTo().removeAttribute("id");
099:                    page.getElementFrom().removeAttribute("id");
100:                    page.getElementSubject().removeAttribute("id");
101:                    page.getElementEmailText().removeAttribute("id");
102:
103:                    // get reference to the message row
104:                    Node messageRow = page.getElementMessageRow();
105:                    Node messageRowParent = messageRow.getParentNode();
106:
107:                    // set the email header and details
108:                    page.setTextDate(msg.getSentDate().toString());
109:                    page.setTextTo(InternetAddress.toString(msg
110:                            .getAllRecipients()));
111:
112:                    MessagingUtil messagingUtil = MessagingUtilFactory
113:                            .getMessagingUtil("scioworks.imap.business.util.MessagingUtilImpl");
114:
115:                    page.setTextSubject(messagingUtil.formatSubject(msg
116:                            .getSubject()));
117:                    page.setTextFrom(msg.getFrom()[0].toString());
118:                    page.setTextEmailText(messagingUtil.formatBodyText(iwMsg
119:                            .getMessageBody(msg)));
120:
121:                    messageRowParent.appendChild(messageRow.cloneNode(true));
122:
123:                    // set the attachments
124:                    HTMLElement filenameEle = page.getElementFilename();
125:                    HTMLAnchorElement downloadLinkEle = page
126:                            .getElementDownloadLink();
127:
128:                    filenameEle.removeAttribute("id");
129:                    downloadLinkEle.removeAttribute("id");
130:
131:                    // Get reference to the row to be modified
132:                    HTMLTableRowElement attachmentListRow = page
133:                            .getElementAttachmentListRow();
134:                    Node attachmentListTable = attachmentListRow
135:                            .getParentNode();
136:
137:                    String currLink = downloadLinkEle.getHref() + "?"
138:                            + PARAM_event + "=" + EVENT_downloadAttachment
139:                            + "&" + PARAM_folder + "="
140:                            + URLEncoder.encode(fFolder) + "&" + PARAM_msgid
141:                            + "=" + Long.toString(fMsgid) + "&" + PARAM_part
142:                            + "=";
143:
144:                    if (msg.isMimeType("multipart/*")) {
145:                        Multipart mp = (Multipart) msg.getContent();
146:                        for (int i = 1; i < mp.getCount(); i++) {
147:                            processEmail(page, mp.getBodyPart(i), currLink
148:                                    + Integer.toString(i));
149:                        }
150:                        attachmentListTable.removeChild(attachmentListRow);
151:                    } else {
152:                        super 
153:                                .removeElement(page,
154:                                        (Element) attachmentListTable);
155:                    }
156:
157:                    messageRowParent.removeChild(messageRow);
158:
159:                    return page.toDocument();
160:
161:                } catch (NullPointerException ex) {
162:                    /*
163:                     * The response will be default HTML page 
164:                     * We need  to allow imapWeb_pres to be functional
165:                     */
166:                    return ((view_mailHTML) m_comms.xmlcFactory
167:                            .create(view_mailHTML.class)).toDocument();
168:
169:                } catch (ImapWebException e) {
170:                    return super .showErrorPage("Error getting message", e
171:                            .getMessage(), "", "");
172:
173:                } catch (MessagingException e) {
174:                    e.printStackTrace();
175:                    return super .showErrorPage("Error getting messages", e
176:                            .getMessage(), "", "");
177:
178:                } catch (IOException e) {
179:                    e.printStackTrace();
180:                    return super .showErrorPage("Error getting message", e
181:                            .getMessage(), "", "");
182:                }
183:            }
184:
185:            public void processEmail(view_mailHTML page, Part part,
186:                    String partId) throws HttpPresentationException,
187:                    MessagingException, IOException, ImapWebException {
188:
189:                if (part.isMimeType("multipart/*")) {
190:
191:                    Multipart mp = ((Multipart) part.getContent());
192:                    int count = mp.getCount();
193:                    for (int i = 1; i < mp.getCount(); i++) {
194:                        processEmail(page, mp.getBodyPart(i), partId + "." + i);
195:                    }
196:
197:                } else if (part.isMimeType("message/rfc822")) {
198:
199:                    // get reference to the message row
200:                    Node messageRow = page.getElementMessageRow();
201:                    Node messageRowParent = messageRow.getParentNode();
202:
203:                    Message msg = (Message) part.getContent();
204:                    page.setTextDate(msg.getSentDate().toString());
205:                    page.setTextTo(InternetAddress.toString(msg
206:                            .getAllRecipients()));
207:                    MessagingUtil messagingUtil = MessagingUtilFactory
208:                            .getMessagingUtil("scioworks.imap.business.util.MessagingUtilImpl");
209:
210:                    page.setTextSubject(messagingUtil.formatSubject(msg
211:                            .getSubject()));
212:                    page.setTextFrom(msg.getFrom()[0].toString());
213:
214:                    IWMessage iwMsg = IWMessageFactory
215:                            .getIWMessage("scioworks.imap.business.beans.IWMessageImpl");
216:
217:                    page.setTextEmailText(messagingUtil.formatBodyText(iwMsg
218:                            .getMessageBody(msg)));
219:
220:                    messageRowParent.appendChild(messageRow.cloneNode(true));
221:
222:                    if (msg.isMimeType("multipart/*")) {
223:                        Multipart mp = (Multipart) msg.getContent();
224:                        for (int i = 1; i < mp.getCount(); i++) {
225:                            processEmail(page, mp.getBodyPart(i), partId + "."
226:                                    + i);
227:                        }
228:                    }
229:
230:                } else {
231:                    // set the attachments
232:                    HTMLElement filenameEle = page.getElementFilename();
233:                    HTMLAnchorElement downloadLinkEle = page
234:                            .getElementDownloadLink();
235:
236:                    // Get reference to the row to be modified
237:                    HTMLTableRowElement attachmentListRow = page
238:                            .getElementAttachmentListRow();
239:                    Node attachmentListTable = attachmentListRow
240:                            .getParentNode();
241:
242:                    page.setTextFilename(part.getFileName());
243:                    downloadLinkEle.setHref(partId);
244:
245:                    attachmentListTable.appendChild(attachmentListRow
246:                            .cloneNode(true));
247:
248:                }
249:            }
250:
251:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.