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


001:        package com.sun.portal.app.sharedevents.util;
002:
003:        import com.sun.comclient.calendar.CalendarSession;
004:        import com.sun.comclient.calendar.CalendarStore;
005:        import com.sun.comclient.calendar.CalendarStoreException;
006:        import com.sun.comclient.calendar.DateTime;
007:        import com.sun.comclient.calendar.StoreNotFoundException;
008:        import com.sun.portal.app.calendarcommon.calendar.SharedCalendarUtils;
009:        import com.sun.portal.app.calendarcommon.calendar.SharedCalendarUtilsFactory;
010:        import com.sun.portal.app.calendarcommon.common.SharedServicesUtils;
011:        import com.sun.portal.app.calendarcommon.common.SharedServicesUtilsFactory;
012:        import com.sun.portal.app.calendarcommon.common.SharedServicesException;
013:        import com.sun.portal.log.common.PortalLogger;
014:        import java.text.DateFormat;
015:        import java.text.SimpleDateFormat;
016:        import java.util.Locale;
017:        import java.util.Map;
018:        import java.util.Properties;
019:        import java.util.TimeZone;
020:        import java.util.logging.Level;
021:        import java.util.logging.Logger;
022:        import javax.faces.context.ExternalContext;
023:        import javax.faces.context.FacesContext;
024:        import javax.portlet.PortletContext;
025:        import javax.portlet.PortletRequest;
026:
027:        public class CalUserHelper {
028:            private String CLASS_NAME = "CalUserHelper";
029:
030:            private static Logger userHelperLogger = PortalLogger
031:                    .getLogger(CalUserHelper.class);
032:
033:            /** Creates a new instance of CalUserHelper class
034:             *  Can be called only within the class.
035:             *  Only one instance is created per application
036:             */
037:            private CalUserHelper() {
038:                super ();
039:            }
040:
041:            public static CalendarStore getCalStore(boolean checkvalidity)
042:                    throws SharedServicesException {
043:                return getCalStore(checkvalidity, true);
044:            }
045:
046:            /**
047:             * Returns a CalStore Object instance associated with the Portlet context.
048:             *
049:             * @param    checkvalidity  if the value is true then this method would
050:             *                          recreate the calendar session if session is invalid.
051:             *                          if set to false then no check is performed for the
052:             *                          validity of the calendar session.
053:             * @param    createStrore   flag to indicate if the creation of calendar store be enforced.
054:             *                          if true, calendar store should be created if not present
055:             *
056:             * @see com.sun.comclient.calendar.CalendarStore
057:             */
058:            public static CalendarStore getCalStore(boolean checkvalidity,
059:                    boolean createStore) throws SharedServicesException {
060:                CalendarStore calstore = null;
061:                FacesContext context = null;
062:
063:                context = FacesContext.getCurrentInstance();
064:                ExternalContext extContext = context.getExternalContext();
065:
066:                // Note: This code works only in portlet environment. You are testing this as
067:                // web-app then don't use this code.
068:
069:                // Get the CalendarStore object for the proxy community user. It contains
070:                // the authenticated calendar session info. We use this to perform calendar operations
071:                // on the community-calendar.
072:                // The store object returned should contain a valid connection
073:
074:                SharedCalendarUtils sharedCalUtils = SharedCalendarUtilsFactory
075:                        .getSharedCalendarUtils(context);
076:                return sharedCalUtils.getProxyCalendarStore(context);
077:
078:            }
079:
080:            public static DateTime getToday() {
081:
082:                String tzStr = CalUserHelper.getUserTimeZone();
083:                TimeZone tz = TimeZone.getTimeZone(tzStr);
084:
085:                DateTime dt = new DateTime(tz);
086:                return dt;
087:            }
088:
089:            public static String getUserDateFormat() {
090:                //Get the Date format computed. 
091:                // instead of computing it every time
092:                SimpleDateFormat df = (SimpleDateFormat) getDateFormat();
093:                return df.toPattern();
094:            }
095:
096:            /** <p>Return the DateFormat object for this Calendar.</p> */
097:            private static DateFormat getDateFormat() {
098:                return AppUtils.getDateFormat(getLocale());
099:
100:            }
101:
102:            /**
103:             * <p>Convenience function to return the locale of the current context.</p>
104:             */
105:            private static Locale getLocale() {
106:                FacesContext context = FacesContext.getCurrentInstance();
107:                return context.getViewRoot().getLocale();
108:            }
109:
110:            public static String getUserTimeZone() {
111:                String userTZ = null;
112:                FacesContext context = FacesContext.getCurrentInstance();
113:                ExternalContext extContext = context.getExternalContext();
114:
115:                Object req = extContext.getRequest();
116:                PortletRequest pReq = null;
117:                if (req instanceof  PortletRequest) {
118:                    pReq = (PortletRequest) req;
119:                    Map userInfo = (Map) pReq
120:                            .getAttribute(PortletRequest.USER_INFO);
121:                    if (userInfo != null) {
122:                        userTZ = (String) userInfo
123:                                .get(SharedConstants.USER_INFO_TIMEZONE);
124:                        if (userTZ == null) {
125:                            userTZ = TimeZone.getDefault().getID();
126:                        }
127:                    } else {
128:                        userTZ = TimeZone.getDefault().getID();
129:                    }
130:
131:                } else {
132:                    userTZ = TimeZone.getDefault().getID();
133:
134:                }
135:
136:                return userTZ;
137:            }
138:
139:            public static DateTime getDateTimeFromISOString(String isoString) {
140:
141:                DateTime dateTime = null;
142:                if (isoString != null && isoString.length() > 0) {
143:                    try {
144:                        String tzStr = getUserTimeZone();
145:                        TimeZone tz = TimeZone.getTimeZone(tzStr);
146:                        dateTime = new DateTime(isoString, tz);
147:                    } catch (Exception e1) {
148:                        dateTime = CalUserHelper.getToday();
149:                    }
150:                }
151:
152:                return dateTime;
153:
154:            }
155:
156:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.