001: // Copyright %G% Sun Microsystems, Inc. All Rights Reserved.
002: // "%W% %E% Sun Microsystems"
003:
004: package com.sun.portal.wireless.taglibs.cal.socs;
005:
006: import javax.servlet.http.*;
007: import javax.servlet.jsp.*;
008: import javax.servlet.jsp.tagext.*;
009:
010: import com.sun.ssoadapter.*;
011:
012: import com.sun.portal.wireless.taglibs.cal.*;
013: import com.sun.portal.wireless.util.AppConfigConstants;
014:
015: import com.sun.comclient.calendar.CalendarStore;
016: import com.sun.comclient.calendar.ICalendar;
017:
018: import java.util.*;
019: import com.iplanet.sso.*;
020:
021: /**
022: * CalContextHolder - This class extends CalContext just to support the Extension mechanism
023: * but delegates all the method to another instance of CalContext available as parentContext.
024: * It should override all the methods of CalContext, Context except getParentContext()
025: * @see com.sun.portal.wireless.taglibs.base.Context
026: */
027:
028: public class CalContextHolder extends CalContext {
029:
030: /**
031: * the default constructor
032: */
033: public CalContextHolder() {
034: super ();
035: }
036:
037: /**
038: * Initialize a context with the specified session.
039: *
040: * @param session Context belongs to this session.
041: * @exception Exception
042: */
043: public void init(HttpServletRequest request, SSOToken session,
044: SSOAdapter ssoAdapter) throws Exception {
045: super .init(request, session,
046: AppConfigConstants.CALENDAR_APP_SERVICE_NAME,
047: ssoAdapter);
048: }
049:
050: /**
051: * Set the calendarID as the current Calendar
052: */
053:
054: public void setCalendar(String calendarID) throws JspException {
055: ((CalContext) getParentContext()).setCalendar(calendarID);
056: }
057:
058: /**
059: * Get the Current Calendar
060: *
061: * @return the Current Calendar; null if not available
062: */
063: public ICalendar getCalendar() {
064: return ((CalContext) getParentContext()).getCalendar();
065: }
066:
067: /**
068: * Get the CalStore
069: *
070: * @return the Current Calendar; null if not available
071: */
072: public CalendarStore getCalStore() {
073: return ((CalContext) getParentContext()).getCalStore();
074: }
075:
076: /**
077: * Get the Current CalendarID
078: *
079: * @return the Current CalendarD; null if not available
080: */
081: public String getCalendarID() {
082: return ((CalContext) getParentContext()).getCalendarID();
083: }
084:
085: /**
086: * Get the current event list
087: *
088: * @return the current event list; null is not available
089: */
090: public EventBean[] getEvents() {
091: return ((CalContext) getParentContext()).getEvents();
092: }
093:
094: /**
095: * Get the current task list
096: * @return the current task list. null is not available
097: */
098: public TaskBean[] getTasks() {
099: return ((CalContext) getParentContext()).getTasks();
100: }
101:
102: /**
103: * Set the current event list
104: *
105: * @return the current event list; null is not available
106: */
107: public void setEvents(EventBean[] evnts) {
108: ((CalContext) getParentContext()).setEvents(evnts);
109: }
110:
111: /**
112: * Set the current task list
113: *
114: * @return the current task list; null is not available
115: */
116: public void setTasks(TaskBean[] tsks) {
117: ((CalContext) getParentContext()).setTasks(tsks);
118: }
119:
120: /**
121: * Get the specified event from the event list
122: *
123: * @param index the index into the current event list
124: * @return the selected event or null if not found
125: */
126: public EventBean getEvent(int index) {
127: return ((CalContext) getParentContext()).getEvent(index);
128: }
129:
130: /**
131: * Get the specified task from the task list
132: *
133: * @param index the index into the current task list
134: * @return the selected task or null if not found
135: */
136: public TaskBean getTask(int index) {
137: return ((CalContext) getParentContext()).getTask(index);
138: }
139:
140: /**
141: * Get the count of the current event list
142: *
143: * @return the event list count
144: */
145: public int getEventCount() {
146: return ((CalContext) getParentContext()).getEventCount();
147: }
148:
149: /**
150: * Get the count of the current task list
151: *
152: * @return the task list count
153: */
154: public int getTaskCount() {
155: return ((CalContext) getParentContext()).getTaskCount();
156: }
157:
158: /**
159: * Get the size of the current event list
160: *
161: * @return the event list size
162: */
163: public int getEventSize() {
164: return getEventCount();
165: }
166:
167: /**
168: * Returns whether the events list is empty or not
169: *
170: * @return true if the event list is empty
171: * false otherwise
172: */
173: public boolean isEventsEmpty() {
174: return getEventCount() == 0;
175: }
176:
177: /**
178: * Returns whether the tasks list is empty or not
179: *
180: * @return true if the tasks list is empty
181: * false otherwise
182: */
183: public boolean isTasksEmpty() {
184: return getTaskCount() == 0;
185: }
186:
187: /**
188: * Get the iCal ServiceURL
189: *
190: * @return the service url
191: */
192: public String getServiceURL() {
193: return ((CalContext) getParentContext()).getServiceURL();
194: }
195:
196: /**
197: * Gets a property from the CalSession. Ex: preferredtimezone - The
198: * CalStore after the connect, retrieves user values stored in the
199: * backend service and populates them in the Properties.
200: *
201: * @param name name of the property to look for in CalSession
202: * @return value of the property
203: */
204: public String getSessionProperty(String name) {
205: return ((CalContext) getParentContext())
206: .getSessionProperty(name);
207: }
208:
209: /**
210: * Checks if user is the Owner of this calendar
211: * @return true if the user can modify it, false otherwise
212: * TBD: once this is provided by JCAPI bug#4816278
213: */
214:
215: public boolean isUserTheOwner() {
216: return ((CalContext) getParentContext()).isUserTheOwner();
217: }
218:
219: /**
220: * Get an attribute string from the user's profile.
221: *
222: * @return attr string.
223: */
224: public String getAttributeString(String name) {
225: return ((CalContext) getParentContext())
226: .getAttributeString(name);
227: }
228:
229: public String getAttributeString(String name, String value) {
230: return ((CalContext) getParentContext()).getAttributeString(
231: name, value);
232: }
233:
234: public Set getAttributeSet(String name) {
235: return ((CalContext) getParentContext()).getAttributeSet(name);
236: }
237:
238: /**
239: * Return the session.
240: *
241: * @return session object.
242: */
243: public SSOToken getSession() {
244: return ((CalContext) getParentContext()).getSession();
245: }
246:
247: /**
248: * Return the session id.
249: *
250: * @return session id.
251: */
252: public SSOTokenID getSessionID() {
253: return ((CalContext) getParentContext()).getSessionID();
254: }
255:
256: /**
257: * Return the user's locale.
258: *
259: * @return locale
260: */
261: public Locale getLocale() {
262: return ((CalContext) getParentContext()).getLocale();
263: }
264:
265: /**
266: * Return the user's timezone.
267: *
268: * @return timezone
269: */
270: public TimeZone getTimeZone() {
271: return ((CalContext) getParentContext()).getTimeZone();
272: }
273:
274: /**
275: * Return the errorCode.
276: *
277: * @return errorCode String.
278: */
279: public String getErrorCode() {
280: return ((CalContext) getParentContext()).getErrorCode();
281: }
282:
283: /**
284: * Set the errorCode
285: *
286: * @param errorCode - String.
287: */
288: public void setErrorCode(String errorCode) {
289: ((CalContext) getParentContext()).setErrorCode(errorCode);
290: }
291:
292: /**
293: * Handle SessionChanged events from the Portal Session.
294: * Cleanup the context when the session goes invalid.
295: *
296: * @param se session change event
297: */
298: public void ssoTokenChanged(SSOTokenEvent evt) {
299: ((CalContext) getParentContext()).ssoTokenChanged(evt);
300: }
301:
302: public SSOAdapter getSSOAdapter() {
303: return ((CalContext) getParentContext()).getSSOAdapter();
304: }
305:
306: public String getClientType() {
307: return ((CalContext) getParentContext()).getClientType();
308: }
309:
310: public String getUserLocaleString() {
311: return ((CalContext) getParentContext()).getUserLocaleString();
312: }
313:
314: public Locale getUserLocale() {
315: return ((CalContext) getParentContext()).getUserLocale();
316: }
317:
318: public String getCharset() {
319: return ((CalContext) getParentContext()).getCharset();
320: }
321:
322: public String getContentType() {
323: return ((CalContext) getParentContext()).getContentType();
324: }
325:
326: public String getConfigName() {
327: return ((CalContext) getParentContext()).getConfigName();
328: }
329:
330: public void loadTimeZone() {
331: ((CalContext) getParentContext()).loadTimeZone();
332: }
333:
334: public void reloadUserPreferences() {
335: ((CalContext) getParentContext()).reloadUserPreferences();
336: }
337:
338: }
|