Source Code Cross Referenced for UWCMailHelper.java in  » Portal » Open-Portal » com » sun » portal » providers » mail » 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 » Portal » Open Portal » com.sun.portal.providers.mail 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *  $Id: UWCMailHelper.java,v 1.7 2005/09/21 10:48:15 dg154973 Exp $ Copyright 2004
003:         *  Sun Microsystems, Inc. All rights reserved. Use of this product is subject
004:         *  to license terms. Federal Acquisitions: Commercial Software -- Government
005:         *  Users Subject to Standard License Terms and Conditions. Sun, Sun
006:         *  Microsystems, the Sun logo, and iPlanet are trademarks or registered
007:         *  trademarks of Sun Microsystems, Inc. in the United States and other
008:         *  countries.
009:         */package com.sun.portal.providers.mail;
010:
011:        import com.sun.ssoadapter.SSOAdapter;
012:        import com.sun.ssoadapter.SSOAdapterException;
013:        import com.sun.ssoadapter.SSOAdapterFactory;
014:        import com.iplanet.sso.SSOToken;
015:        import com.iplanet.sso.SSOTokenEvent;
016:        import com.iplanet.sso.SSOException;
017:        import com.sun.portal.providers.context.Theme;
018:        import java.net.URL;
019:        import java.net.URLEncoder;
020:        import java.util.Hashtable;
021:        import java.util.StringTokenizer;
022:        import java.util.Map;
023:        import java.util.Set;
024:        import java.util.Iterator;
025:        import java.util.List;
026:        import java.util.Properties;
027:        import java.util.logging.Level;
028:        import java.util.logging.Logger;
029:        import javax.mail.Folder;
030:        import javax.mail.Message;
031:        import javax.mail.UIDFolder;
032:        import javax.servlet.http.HttpServletRequest;
033:        import javax.servlet.http.HttpServletResponse;
034:        import com.sun.portal.providers.ProviderEditUtility;
035:        import com.sun.portal.providers.context.ProviderContext;
036:        import com.sun.portal.providers.Provider;
037:        import com.sun.portal.providers.ProfileProviderAdapter;
038:        import com.sun.portal.providers.ApplicationHelper;
039:        import com.sun.portal.providers.ProviderException;
040:        import com.sun.portal.providers.context.ProviderContextException;
041:        import com.sun.portal.log.common.PortalLogger;
042:
043:        import java.io.UnsupportedEncodingException;
044:
045:        /**
046:         *  <p>
047:         *
048:         *  A UWCMailHelper implementation must provide the following method(s):
049:         *  <ul>
050:         *    <li> init(..)</li>
051:         *    <li> getStartURL()</li>
052:         *    <li> getMessageURL(..)</li>
053:         *  </ul>
054:         *
055:         *
056:         *@author     Bill York
057:         *@created    June 9, 2004
058:         *@version    1.0
059:         *@see        com.sun.ssoadapter.SSOAdapter
060:         */
061:
062:        public class UWCMailHelper extends ApplicationHelper implements 
063:                MailApplicationHelper {
064:
065:            protected String appName = "";
066:            public MailProvider provider = null;
067:            public SSOAdapter ssoAdapter = null;
068:            public Properties adapterProperties = null;
069:            public String charset = null;
070:            private long lastCheckTime = 0;
071:            private long checkInterval;
072:            protected String containerName = "";
073:            protected String clientAppURL = null;
074:
075:            // Create a logger for this class
076:            private static Logger debugLogger = PortalLogger
077:                    .getLogger(UWCMailHelper.class);
078:
079:            /**
080:             *  Initialize UWCMailHelper.
081:             *
082:             *@param  provider       MailProvider
083:             *@param  ssoAdapter     Used to identify the SSOAdapter
084:             *@exception  Exception
085:             */
086:            public void init(MailProvider provider, SSOAdapter ssoAdapter)
087:                    throws Exception {
088:                super .init((ProfileProviderAdapter) provider, ssoAdapter);
089:                this .provider = provider;
090:                this .ssoAdapter = ssoAdapter;
091:
092:                if (ssoAdapter != null) {
093:                    this .adapterProperties = ssoAdapter.getProperties();
094:                }
095:
096:                this .checkInterval = Integer.parseInt(adapterProperties
097:                        .getProperty("checkInterval", "5000"));
098:                // get the charset
099:                SSOToken token = ssoAdapter.getSSOToken();
100:                charset = token.getProperty("CharSet");
101:                debugLogger.log(Level.FINER, "PSMC_CSPPM0041", charset);
102:            }
103:
104:            /**
105:             *  Returns the Application Start URL.
106:             *
107:             *@param  provider  MailProvider
108:             *@param  request   HttpServletRequest
109:             *@return           url to access application
110:             */
111:            public String getStartURL(MailProvider provider,
112:                    HttpServletRequest request) {
113:                StringBuffer clientURL = new StringBuffer();
114:                String mailURL = "?argv=laurel=on&cal=1";
115:                String host = adapterProperties.getProperty("host");
116:                String port = adapterProperties.getProperty("clientPort", "80");
117:                String protocol = adapterProperties.getProperty(
118:                        "clientProtocol", "http");
119:
120:                clientURL.append(protocol + "://" + host + ":" + port);
121:                clientURL.append(mailURL);
122:                clientAppURL = clientURL.toString();
123:                debugLogger.log(Level.FINER, "PSMC_CSPPM0058", clientURL);
124:                return clientURL.toString();
125:            }
126:
127:            /**
128:             *  Returns the contents of the MailProviders edit page
129:             *
130:             *@param  mprov  MailProvider instance
131:             *@param  req    servlet request
132:             *@param  res    servlet response
133:             *@return        The appPrefsEdit value
134:             */
135:            public StringBuffer getAppPrefsEdit(MailProvider mprov,
136:                    HttpServletRequest req, HttpServletResponse res) {
137:                setEditContainer(mprov.editContainer);
138:                setContainerName(mprov.containerName);
139:                setTargetProvider(mprov.targetProvider);
140:                return super .getAppPrefsEdit((Provider) mprov, req, res);
141:            }
142:
143:            /**
144:             *  Processes values returned from the MailPprovider edit page
145:             *
146:             *@param  mprov                  MailProvider instance
147:             *@param  req                    servlet request
148:             *@param  res                    servlet response
149:             *@return                        URL for MailProvider.processEdit() to use
150:             *@exception  ProviderException
151:             */
152:            public URL processAppPrefsEdit(MailProvider mprov,
153:                    HttpServletRequest request, HttpServletResponse response)
154:                    throws ProviderException {
155:                setEditContainer(mprov.editContainer);
156:                setContainerName(mprov.containerName);
157:                setTargetProvider(mprov.targetProvider);
158:                return super .processAppPrefsEdit((Provider) mprov, request,
159:                        response);
160:            }
161:
162:            /**
163:             *  Returns client aware URL for message access to service associated with a
164:             *  particular instance of a MailSSOHelper.
165:             *
166:             *@param  provider       MailProvider
167:             *@param  request        HttpServletRequest
168:             *@param  message        Mail Message
169:             *@return                url to a specific message in the application
170:             *@exception  Exception
171:             */
172:            public String getMessageURL(MailProvider provider,
173:                    HttpServletRequest request, Message message)
174:                    throws Exception {
175:                StringBuffer clientURL = new StringBuffer();
176:                Folder folder = message.getFolder();
177:
178:                if (clientAppURL != null)
179:                    clientURL.append(clientAppURL);
180:                else {
181:                    clientAppURL = getStartURL(provider, request);
182:                    clientURL.append(clientAppURL);
183:                }
184:                clientURL.append("&argv=mbox=");
185:                clientURL.append(ProviderEditUtility.encode(message.getFolder()
186:                        .getFullName(), charset));
187:                clientURL.append("&argv=msg=");
188:                clientURL.append(((UIDFolder) folder).getUID(message));
189:                return clientURL.toString();
190:            }
191:
192:            /**
193:             *  Gets the appHelperEditLink attribute of the UWCMailHelper object
194:             *
195:             *@param  req  servlet request
196:             *@param  pc   current ProviderContext
197:             *@return      The appHelperEditLink value
198:             */
199:            public String getAppHelperEditLink(HttpServletRequest req,
200:                    ProviderContext pc) {
201:
202:                Hashtable tagTable = new Hashtable();
203:                StringBuffer link = new StringBuffer();
204:                try {
205:                    link.append(pc.getDesktopURL(req));
206:                } catch (Exception e) {
207:                    return "";
208:                }
209:                link.append("?action=edit&provider=");
210:                link.append(ProviderEditUtility.getRequestParameter("provider",
211:                        req));
212:                link.append("&targetprovider=" + provider.getName());
213:                link.append("&containerName=");
214:                link.append(ProviderEditUtility.getRequestParameter(
215:                        "containerName", req));
216:                link.append("&appPref=" + this .getName());
217:
218:                tagTable.put("editLink", link.toString());
219:                String content = null;
220:
221:                try {
222:                    String fontTag = pc.getStringProperty(provider.getName(),
223:                            "fontFace1", "Sans-serif");
224:                    tagTable.put("iwtDesktop-fontFace1", fontTag);
225:                    ProviderEditUtility
226:                            .setDefaultPresentation(provider.getName(),
227:                                    provider.getProviderContext(), tagTable);
228:                    content = pc.getTemplate(provider.getName(),
229:                            "edit-link.template", tagTable).toString();
230:                    debugLogger.log(Level.FINER, "PSMC_CSPPM0002", content
231:                            .toString());
232:                } catch (Exception e) {
233:                    debugLogger.log(Level.INFO, "PSMC_CSPPM0003", e);
234:                    content = "";
235:                }
236:
237:                debugLogger.log(Level.FINER, "PSMC_CSPPM0004", content
238:                        .toString());
239:
240:                return content;
241:            }
242:
243:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.