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


001:        /**
002:         * $Id: UWCCalendarHelper.java,v 1.9 2005/09/21 10:41:15 dg154973 Exp $
003:         * Copyright 2004 Sun Microsystems, Inc. All
004:         * rights reserved. Use of this product is subject
005:         * to license terms. Federal Acquisitions:
006:         * Commercial Software -- Government Users
007:         * Subject to Standard License Terms and
008:         * Conditions.
009:         *
010:         * Sun, Sun Microsystems, the Sun logo, and iPlanet
011:         * are trademarks or registered trademarks of Sun Microsystems,
012:         * Inc. in the United States and other countries.
013:         */package com.sun.portal.providers.calendar;
014:
015:        import java.io.UnsupportedEncodingException;
016:        import java.net.URL;
017:        import java.net.URLEncoder;
018:
019:        import java.util.Hashtable;
020:        import java.util.List;
021:        import java.util.StringTokenizer;
022:        import java.util.Map;
023:        import java.util.Iterator;
024:        import java.util.Set;
025:        import java.util.Properties;
026:        import java.util.logging.Logger;
027:        import java.util.logging.Level;
028:
029:        import javax.servlet.http.HttpServletRequest;
030:        import javax.servlet.http.HttpServletResponse;
031:
032:        import com.iplanet.am.sdk.AMException;
033:        import com.iplanet.am.sdk.AMStoreConnection;
034:        import com.iplanet.am.sdk.AMUser;
035:
036:        import com.iplanet.sso.SSOToken;
037:        import com.iplanet.sso.SSOTokenEvent;
038:        import com.iplanet.sso.SSOException;
039:
040:        import com.sun.comclient.calendar.*;
041:        import com.sun.comclient.calendar.socs.*;
042:
043:        import com.sun.ssoadapter.SSOAdapter;
044:        import com.sun.ssoadapter.SSOAdapterException;
045:        import com.sun.ssoadapter.SSOAdapterFactory;
046:
047:        import com.sun.portal.providers.context.ProviderContext;
048:        import com.sun.portal.providers.context.ProviderContextException;
049:        import com.sun.portal.providers.Provider;
050:        import com.sun.portal.providers.ProfileProviderAdapter;
051:        import com.sun.portal.providers.ApplicationHelper;
052:        import com.sun.portal.providers.ProviderException;
053:        import com.sun.portal.providers.ProviderEditUtility;
054:        import com.sun.portal.log.common.PortalLogger;
055:
056:        /**
057:         * <p A UWCCalendarHelper implementation must provide the following method(s):
058:         * <ul>
059:         * <li>init(...)</li>
060:         * <li>getStartURL(...)</li>
061:         * <li>getEventURL(...)</li>
062:         * <li>getTaskURL(...)</li>
063:         * </ul>
064:         *
065:         * @author Bill York
066:         * @version 1.0
067:         * @see com.sun.ssoadapter.SSOAdapter
068:         *
069:         */
070:
071:        public class UWCCalendarHelper extends ApplicationHelper implements 
072:                CalendarApplicationHelper {
073:
074:            public CalendarProvider provider = null;
075:            public SSOAdapter ssoAdapter = null;
076:            public Properties adapterProperties = null;
077:            public ProviderContext pc = null;
078:
079:            protected String appName = "";
080:            protected String containerName = "";
081:            protected String clientAppURL = "";
082:            public String charset = null;
083:
084:            // Create a logger for this class
085:            private static Logger debugLogger = PortalLogger
086:                    .getLogger(UWCCalendarHelper.class);
087:
088:            /**
089:             * Initialize UWCCalendarHelper.
090:             *
091:             * @param provider    CalendarProvider
092:             * @param ssoAdapter  Used to identify the SSOAdapter
093:             */
094:            public void init(CalendarProvider provider, SSOAdapter ssoAdapter)
095:                    throws Exception {
096:                super .init((ProfileProviderAdapter) provider, ssoAdapter);
097:                this .provider = provider;
098:                this .ssoAdapter = ssoAdapter;
099:                pc = provider.getProviderContext();
100:
101:                if (ssoAdapter != null) {
102:                    this .adapterProperties = ssoAdapter.getProperties();
103:                }
104:
105:                // get the charset
106:                SSOToken token = ssoAdapter.getSSOToken();
107:                charset = token.getProperty("CharSet");
108:                debugLogger.log(Level.FINER, "PSCC_CSPPC0001", charset);
109:            }
110:
111:            /**
112:             * Returns the contents of the AddressBookProviders edit page
113:             */
114:            public StringBuffer getAppPrefsEdit(CalendarProvider cprov,
115:                    HttpServletRequest req, HttpServletResponse res) {
116:                setEditContainer(cprov.editContainer);
117:                setContainerName(cprov.containerName);
118:                setTargetProvider(cprov.targetProvider);
119:                return super .getAppPrefsEdit((Provider) cprov, req, res);
120:            }
121:
122:            /**
123:             * Processes values returned from the AddressBookProvider edit page
124:             */
125:            public URL processAppPrefsEdit(CalendarProvider cprov,
126:                    HttpServletRequest request, HttpServletResponse response)
127:                    throws ProviderException {
128:                setEditContainer(cprov.editContainer);
129:                setContainerName(cprov.containerName);
130:                setTargetProvider(cprov.targetProvider);
131:                return super .processAppPrefsEdit((Provider) cprov, request,
132:                        response);
133:            }
134:
135:            /**
136:             * Responsible for generating the Application Launch Link/URL for the Communications
137:             * Express client.  The Comms Express URL format:
138:             *
139:             *     http://<hostname>:<port>/<contexturi>/?gotoUri=/calclient/<viewname>
140:             *       ?calid=<calid>
141:             *       &caltype=<caltype>
142:             *       &date=<context date>
143:             *       &category=<category>
144:             *
145:             * viewname : Name of View. [ Mandatory]
146:             *     - values: DayView, WeekView, MonthView
147:             *
148:             * calid : calid of the calendar for which the view is displayed [if this parameter is
149:             *         not present, default calendar is considered]
150:             *         - if there are multiple calendars, they are seperated by comma(,)
151:             *         - if one wants to view a calendar group, assign the groupname
152:             *
153:             * caltype :  will be 'calid' if the calid has single calid value [ default value, i.e
154:             *            if this parameter is no t present, value 'calid' is considered ]
155:             *            - will be 'group' if group-name is the value of calid parameter
156:             *            - will be 'Temporarycalendars" if calid has multiple calids
157:             *
158:             * date : context Date in ISO format (For example : 20040521T065954Z). Context date is
159:             *        date the user has selected to view.
160:             *        -default value : current date
161:             *
162:             * category: specifies the category filter for Events/Tasks to be dsiplayed. Should be
163:             *           'All' if events/tasks from all categories have to be displayed.
164:             *           - default value = 'All'
165:             *
166:             *
167:             * @param provider  CalendarProvider
168:             * @param request   HttpServletRequest
169:             * @return url to access application
170:             */
171:            public String getStartURL(CalendarProvider prov,
172:                    HttpServletRequest request) {
173:
174:                StringBuffer baseURL = getCommsExpressBaseURI();
175:                return baseURL.toString();
176:            }
177:
178:            /**
179:             * Returns client aware URL for event access
180:             * to service associated with a particular instance
181:             * of a CalendarSSOHelper.
182:             *
183:             * http://<hostname>:<port>/<contexturi>/?gotoUri=/calclient/ViewEvent?eventid=<eventid>&calid=<calid>
184:             *
185:             * If the event/todo is recurrring one, you need to pass the recurrence id of event
186:             * (parameter name is rid)
187:             *
188:             * @param provider  CalendarProvider
189:             * @param request   HttpServletRequest
190:             * @param event     VEvent
191:             */
192:            public String getEventURL(CalendarProvider provider,
193:                    HttpServletRequest request, VEvent event) throws Exception {
194:
195:                StringBuffer baseURL = getCommsExpressBaseURI();
196:                StringBuffer eventURL = new StringBuffer();
197:                String calid = getCalendarToView(provider);
198:                String eventid = event.getID();
199:                DateTime recurrenceDateTime = event.getRecurrenceID();
200:
201:                baseURL.append("/?gotoUri=/calclient/ViewEvent?");
202:                eventURL.append("eventid=" + eventid);
203:                eventURL.append("&calid=" + calid);
204:
205:                if ((event.isRecurring()) && (recurrenceDateTime != null)) {
206:                    eventURL.append("&rid=" + recurrenceDateTime.toISO8601());
207:                }
208:
209:                baseURL.append(ProviderEditUtility.encode(eventURL.toString(),
210:                        charset));
211:
212:                return baseURL.toString();
213:            }
214:
215:            /**
216:             * Returns client aware URL for task access
217:             * to service associated with a particular instance
218:             * of a CalendarSSOHelper.
219:             *
220:             * http://<hostname>:<port>/<contexturi>/?gotoUri=/calclient/ViewTask?todoUid=<taskid>&calid=<calid>
221:             *
222:             * If the event/todo is recurrring one, you need to pass the recurrence id of event
223:             * (parameter name is rid)
224:             *
225:             * @param provider  CalendarProvider
226:             * @param request   HttpServletRequest
227:             * @param task      VTodo
228:             */
229:            public String getTaskURL(CalendarProvider provider,
230:                    HttpServletRequest request, VTodo task) throws Exception {
231:
232:                StringBuffer baseURL = getCommsExpressBaseURI();
233:                StringBuffer taskURL = new StringBuffer();
234:                String calid = getCalendarToView(provider);
235:                String taskid = task.getID();
236:                DateTime recurrenceDateTime = task.getRecurrenceID();
237:
238:                baseURL.append("/?gotoUri=/calclient/ViewTask?");
239:                taskURL.append("todoUid=" + taskid);
240:                taskURL.append("&calid=" + calid);
241:
242:                if ((task.isRecurring()) && (recurrenceDateTime != null)) {
243:                    taskURL.append("&rid=" + recurrenceDateTime.toISO8601());
244:                }
245:
246:                baseURL.append(ProviderEditUtility.encode(taskURL.toString(),
247:                        charset));
248:
249:                return baseURL.toString();
250:            }
251:
252:            public String getAppHelperEditLink(HttpServletRequest req,
253:                    ProviderContext pc) {
254:
255:                Hashtable tagTable = new Hashtable();
256:                StringBuffer link = new StringBuffer();
257:                try {
258:                    link.append(pc.getDesktopURL(req));
259:                } catch (Exception e) {
260:                    return "";
261:                }
262:                link.append("?action=edit&provider=");
263:                link.append(ProviderEditUtility.getRequestParameter("provider",
264:                        req));
265:                link.append("&targetprovider=" + provider.getName());
266:                link.append("&containerName=");
267:                link.append(ProviderEditUtility.getRequestParameter(
268:                        "containerName", req));
269:                link.append("&appPref=" + this .getName());
270:
271:                tagTable.put("editLink", link.toString());
272:                String content = null;
273:
274:                try {
275:                    String fontTag = pc.getStringProperty(provider.getName(),
276:                            "fontFace1", "Sans-serif");
277:                    tagTable.put("iwtDesktop-fontFace1", fontTag);
278:                    content = pc.getTemplate(provider.getName(),
279:                            "edit-link.template", tagTable).toString();
280:                    debugLogger.log(Level.FINER, "PSCC_CSPPC0004", content
281:                            .toString());
282:                } catch (Exception e) {
283:                    debugLogger.log(Level.INFO, "PSCC_CSPPC0005", e);
284:                    content = "";
285:                }
286:
287:                debugLogger.log(Level.FINER, "PSCC_CSPPC0006", content
288:                        .toString());
289:
290:                return content;
291:            }
292:
293:            /*
294:             * Constructs the base URI for the Comms Express client.  The URI format is:
295:             *
296:             * <clientProtocol>://<clientHost>:<clientPort>/<uwcContext>
297:             *
298:             * If "clientHost" is not found in the SSO adapter properties, then "host" is
299:             * used.
300:             *
301:             */
302:            public StringBuffer getCommsExpressBaseURI() {
303:
304:                StringBuffer baseURL = new StringBuffer();
305:
306:                String host = adapterProperties.getProperty("host");
307:                String clientHost = adapterProperties.getProperty("clientHost",
308:                        host);
309:                String port = adapterProperties.getProperty("clientPort", "80");
310:                String uwcContext = adapterProperties.getProperty("uwcContext");
311:                String protocol = adapterProperties
312:                        .getProperty("clientProtocol");
313:
314:                baseURL.append(protocol + "://" + clientHost + ":" + port);
315:
316:                if (uwcContext != null) {
317:                    if (uwcContext.substring(0).equals("/")) {
318:                        baseURL.append(uwcContext);
319:                    } else {
320:                        baseURL.append("/" + uwcContext);
321:                    }
322:                }
323:
324:                return baseURL;
325:            }
326:
327:            /*
328:             * Retrieve the Calendar to Display.  This corresponds to the "calid"
329:             * URL parameter of the Comms Express client URI.
330:             *
331:             * First check to see if the channel's "calendar" property is set and use this
332:             * value if it is.  Otherwise, attempt to retrieve the SSO adapter "uid" value.
333:             * If this property is not found, then use the SSO adapter user naming attribute
334:             * "userAttribute".  Finally, check to see if hosted/virtual domain support is
335:             * present (by retrieving the "domain" property from the SSO adapter) and append
336:             * if found.
337:             *
338:             */
339:            public String getCalendarToView(CalendarProvider provider) {
340:
341:                String calendarToDisplay = "";
342:                String calid = "";
343:                String domain = "";
344:
345:                try {
346:                    calendarToDisplay = pc.getStringProperty(
347:                            provider.getName(), "calendar", pc
348:                                    .getClientAndLocalePropertiesFilters());
349:                } catch (ProviderContextException pce) {
350:                    calendarToDisplay = null;
351:                }
352:
353:                if ((calendarToDisplay != null)
354:                        && (calendarToDisplay.length() > 0)) {
355:                    calid = calendarToDisplay;
356:
357:                } else {
358:                    calid = adapterProperties.getProperty("uid");
359:                    domain = adapterProperties.getProperty("domain");
360:
361:                    if (calid == null || (calid.length() < 1)) {
362:                        String usrAttr = adapterProperties.getProperty(
363:                                "userAttribute", "uid");
364:                        try {
365:                            SSOToken tok = ssoAdapter.getSSOToken();
366:                            AMStoreConnection amsc = new AMStoreConnection(tok);
367:                            AMUser auser = amsc.getUser(tok.getPrincipal()
368:                                    .getName());
369:                            calid = auser.getStringAttribute(usrAttr);
370:                        } catch (SSOAdapterException ssae) {
371:                            debugLogger.log(Level.INFO, "PSCC_CSPPC0003", ssae);
372:                        } catch (SSOException ssoe) {
373:                            debugLogger.log(Level.INFO, "PSCC_CSPPC0003", ssoe);
374:                        } catch (AMException ame) {
375:                            debugLogger.log(Level.INFO, "PSCC_CSPPC0003", ame);
376:                        }
377:                    }
378:
379:                    // check for hosted domain support
380:                    if ((domain != null) && (domain.length() > 0)) {
381:                        calid = calid + "@" + domain;
382:                    }
383:
384:                }
385:
386:                return calid;
387:            }
388:
389:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.