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


001:        package com.sun.portal.app.sharedtasks.faces.beans;
002:
003:        import com.sun.comclient.calendar.CalendarStore;
004:        import com.sun.comclient.calendar.CalendarStoreException;
005:        import com.sun.comclient.calendar.DateTime;
006:        import com.sun.comclient.calendar.ICalendar;
007:        import com.sun.comclient.calendar.RecurrencePattern;
008:        import com.sun.portal.app.sharedtasks.faces.models.TaskModel;
009:        import com.sun.portal.app.sharedtasks.util.CalTask;
010:        import com.sun.portal.app.sharedtasks.util.SharedConstants;
011:        import com.sun.portal.app.sharedtasks.util.SharedTaskException;
012:        import com.sun.portal.app.sharedtasks.util.TaskBeanFactory;
013:
014:        import com.sun.portal.app.calendarcommon.common.SharedServicesUtils;
015:        import com.sun.portal.app.calendarcommon.common.SharedServicesUtilsFactory;
016:        import com.sun.portal.app.calendarcommon.common.SharedServicesException;
017:        import com.sun.portal.app.calendarcommon.calendar.SharedCalendarUtils;
018:        import com.sun.portal.app.calendarcommon.calendar.SharedCalendarUtilsFactory;
019:
020:        import com.sun.portal.log.common.PortalLogger;
021:
022:        import java.text.DateFormat;
023:        import java.util.logging.Logger;
024:        import java.util.logging.Level;
025:
026:        import java.util.Locale;
027:        import java.util.ResourceBundle;
028:        import java.util.TimeZone;
029:        import java.util.Map;
030:
031:        import javax.faces.context.FacesContext;
032:        import javax.faces.context.ExternalContext;
033:        import javax.portlet.PortletRequest;
034:        import javax.portlet.PortletURL;
035:
036:        /**
037:         * User session bean for calendar tasks module.
038:         *
039:         * @author ashwin.mathew@sun.com
040:         */
041:        public class TaskUserSessionBackingBean {
042:
043:            public static final String BEAN_NAME = "TaskUserSessionBean";
044:
045:            private static Logger logger = PortalLogger
046:                    .getLogger(TaskUserSessionBackingBean.class);
047:
048:            // Note that the current implementation of this method talks
049:            // to the calendarcommon API, and hence to the community API.
050:            // A future non-community version could have a class that
051:            // overrides this method to retrieve an individual user's calendar.
052:            // The subclass could then be registered under the same bean name
053:            // and everything should work ok.
054:            public ICalendar getCalendar() throws SharedTaskException {
055:                ICalendar communityCalendar = null;
056:
057:                FacesContext context = FacesContext.getCurrentInstance();
058:                ExternalContext extContext = context.getExternalContext();
059:
060:                //if (extContext instanceof PortletContext) // Only for testing
061:                {
062:                    // Note: This code works only in portlet environment.
063:
064:                    // Get the CalendarStore object for the proxy community user. It contains
065:                    // the authenticated calendar session info. We use this to perform calendar operations
066:                    // on the community-calendar.
067:                    // The store object returned should contain a valid connection
068:
069:                    try {
070:                        SharedCalendarUtils sharedCalUtils = SharedCalendarUtilsFactory
071:                                .getSharedCalendarUtils(context);
072:                        CalendarStore calstore = sharedCalUtils
073:                                .getProxyCalendarStore(context);
074:
075:                        String commCalId = sharedCalUtils
076:                                .getCommunityCalendarID(context);
077:
078:                        communityCalendar = calstore.openCalendar(commCalId);
079:                    } catch (SharedServicesException e1) {
080:                        throw new SharedTaskException(
081:                                SharedTaskException.CALENDAR_ERROR, e1);
082:                    } catch (CalendarStoreException e1) {
083:                        throw new SharedTaskException(
084:                                SharedTaskException.CALENDAR_ERROR, e1);
085:                    }
086:                }
087:                /*else // Uncomment for testing
088:                {
089:                    String host = "mobile.india.sun.com";
090:                    int port = 3080;
091:
092:                    Properties props = new Properties();
093:
094:                    props.setProperty( "cal.user", "communitytasks" );
095:                    props.setProperty( "cal.password", "communitytasks");
096:                    props.setProperty( "cal.protocol", "http");
097:                    props.setProperty( "cal.serviceAdapterClass", "com.sun.comclient.calendar.socs.SOCSCalendarStore");
098:                    props.setProperty( "cal.domain" , "india.sun.com");
099:
100:                    CalendarSession calsession = CalendarSession.getInstance(props);
101:
102:                    ICalendar cal = null;
103:
104:                    try 
105:                    {
106:                        calstore = calsession.getStore();
107:                        calstore.connect(host, port);
108:                    }
109:                    catch (Exception ex) 
110:                    {
111:                        throw new SharedTaskException(
112:                            SharedTaskException.CALENDAR_ERROR, ex);
113:                    }
114:                }*/
115:
116:                return communityCalendar;
117:            }
118:
119:            public TimeZone getTimeZone() {
120:                TimeZone timeZone = null;
121:
122:                FacesContext context = FacesContext.getCurrentInstance();
123:                ExternalContext extContext = context.getExternalContext();
124:
125:                Object req = extContext.getRequest();
126:                PortletRequest pReq = null;
127:                if (req instanceof  PortletRequest) {
128:                    pReq = (PortletRequest) req;
129:                    Map userInfo = (Map) pReq
130:                            .getAttribute(PortletRequest.USER_INFO);
131:                    if (userInfo != null) {
132:                        String timeZoneId = (String) userInfo
133:                                .get(SharedConstants.USER_INFO_TIMEZONE);
134:
135:                        if (timeZoneId != null) {
136:                            timeZone = TimeZone.getTimeZone(timeZoneId);
137:                        }
138:                    }
139:                }
140:
141:                timeZone = (timeZone == null) ? TimeZone.getDefault()
142:                        : timeZone;
143:
144:                logger.fine("Retrieved user timezone [" + timeZone.getID()
145:                        + "]");
146:
147:                return timeZone;
148:            }
149:
150:            public Locale getLocale() {
151:                FacesContext context = FacesContext.getCurrentInstance();
152:                ExternalContext extContext = context.getExternalContext();
153:
154:                Locale locale = extContext.getRequestLocale();
155:                if (locale == null) {
156:                    locale = Locale.getDefault();
157:                }
158:
159:                return locale;
160:            }
161:
162:            public ResourceBundle getResourceBundle() {
163:                return ResourceBundle.getBundle(
164:                        SharedConstants.TASKS_RESOURCE_BUNDLE, getLocale());
165:            }
166:
167:            private FacesContext getCurrentContext() {
168:                return FacesContext.getCurrentInstance();
169:            }
170:
171:            private SharedCalendarUtils getCalendarUtils()
172:                    throws SharedServicesException {
173:                return SharedCalendarUtilsFactory
174:                        .getSharedCalendarUtils(getCurrentContext());
175:            }
176:
177:            public void addTaskToSearchDatabase(TaskModel tModel) {
178:
179:                logger.fine("Enter addTask: task=" + tModel);
180:
181:                try {
182:
183:                    if (tModel == null)
184:                        return;
185:
186:                    FacesContext context = getCurrentContext();
187:
188:                    CalTask task = tModel.getTask();
189:
190:                    String taskID = "NULL";
191:
192:                    try {
193:
194:                        DateTime stDt = task.getStartTime();
195:                        DateTime endDt = task.getDueTime();
196:
197:                        String df = this .getDateFormat().toString();
198:
199:                        TimeZone tz = task.getTimeZone();
200:                        String dueTime = SharedConstants
201:                                .getDisplayableDateTime(stDt, endDt, df, "/",
202:                                        "24", tz, getResourceBundle());
203:
204:                        logger.fine("startTime = " + stDt);
205:
206:                        String description = task.getDescription();
207:                        String title = task.getTitle();
208:
209:                        taskID = task.getId();
210:                        logger.fine("task= " + taskID);
211:                        TaskListSessionBackingBean taskListSession = (TaskListSessionBackingBean) TaskBeanFactory
212:                                .getBean(TaskListSessionBackingBean.BEAN_NAME);
213:                        PortletURL portletUrl = taskListSession
214:                                .getPortletActionUrl();
215:                        if (taskID != null) {
216:                            portletUrl.setParameter(
217:                                    SharedConstants.REQ_PARAM_TASKID, taskID);
218:                        }
219:                        //Add the rid even if it is zero, so it it replaces the rid in actionURL
220:                        String rid = "0";
221:                        if ((task.getIsRecurring())
222:                                && (task.getRecurrencePattern() != null)) {
223:                            if (task.getStartTime() != null) {
224:                                rid = String.valueOf(task.getStartTime()
225:                                        .toISO8601());
226:                            } else if (task.getDueTime() != null) {
227:                                rid = String.valueOf(task.getDueTime()
228:                                        .toISO8601());
229:                            } else {
230:                                //Not taking care of recurrence task ( which has no start and no due time )
231:                            }
232:                        }
233:                        logger.fine("rid=" + rid);
234:                        portletUrl.setParameter(
235:                                SharedConstants.REQ_PARAM_TASKRID, rid);
236:                        portletUrl.setParameter(
237:                                SharedConstants.URL_COMM_SEARCH_TASKS, String
238:                                        .valueOf(true));
239:                        //portletUrl.setParameter(SharedConstants.REQ_PARAM_TASKRID, );
240:                        String displayURL = portletUrl.toString();
241:
242:                        SharedServicesUtils sharedServices = SharedServicesUtilsFactory
243:                                .getSharedServicesUtils(context);
244:                        String memberID = sharedServices
245:                                .getCurrentMemberID(context);
246:
247:                        logger.fine("mbr id = " + memberID);
248:
249:                        SharedCalendarUtils sharedCalUtils = SharedCalendarUtilsFactory
250:                                .getSharedCalendarUtils(context);
251:
252:                        logger.fine("sharedCalUtils = " + sharedCalUtils);
253:                        sharedCalUtils.insertItemIntoSearchDatabase(context,
254:                                SharedCalendarUtils.APP_TYPE_SHAREDTASKS,
255:                                memberID, taskID, title, dueTime + " -- "
256:                                        + description, displayURL);
257:
258:                    } catch (SharedServicesException e) {
259:                        logger.log(Level.WARNING, "Unable to add task "
260:                                + taskID + " to search database", e);
261:                    }
262:
263:                } catch (Exception e) {
264:                    logger.log(Level.SEVERE,
265:                            "Exception in addTaskToSearchDatabase: "
266:                                    + e.getMessage(), e);
267:                }
268:
269:            }
270:
271:            public void deleteTaskFromSearchDatabase(TaskModel tModel) {
272:
273:                if (tModel == null)
274:                    return;
275:
276:                FacesContext context = getCurrentContext();
277:
278:                String taskID = "NULL";
279:                try {
280:                    CalTask task = tModel.getTask();
281:
282:                    taskID = task.getId();
283:                    SharedCalendarUtils sharedCalUtils = SharedCalendarUtilsFactory
284:                            .getSharedCalendarUtils(context);
285:                    sharedCalUtils.deleteItemFromSearchDatabase(context,
286:                            SharedCalendarUtils.APP_TYPE_SHAREDTASKS, taskID);
287:
288:                } catch (SharedServicesException e) {
289:                    logger.log(Level.WARNING, "Unable to delete task " + taskID
290:                            + " from search database", e);
291:                }
292:
293:            }
294:
295:            public DateFormat getDateFormat() {
296:                Locale locale = getLocale();
297:                return DateFormat.getDateInstance(DateFormat.SHORT, locale);
298:            }
299:
300:        }
ww__w.j_av___a2___s.___com___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.