Source Code Cross Referenced for CalendarProvider.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) 


0001:        /**
0002:         * $Id: CalendarProvider.java,v 1.126 2005/09/21 10:41:04 dg154973 Exp $
0003:         * Copyright 2002 Sun Microsystems, Inc. All
0004:         * rights reserved. Use of this product is subject
0005:         * to license terms. Federal Acquisitions:
0006:         * Commercial Software -- Government Users
0007:         * Subject to Standard License Terms and
0008:         * Conditions.
0009:         *
0010:         * Sun, Sun Microsystems, the Sun logo, and iPlanet
0011:         * are trademarks or registered trademarks of Sun Microsystems,
0012:         * Inc. in the United States and other countries.
0013:         *
0014:         */package com.sun.portal.providers.calendar;
0015:
0016:        /**
0017:         * The CalendarProvider displays a Calendar configured by a Portal user
0018:         * on his/her desktop.
0019:         *
0020:         * Calendar Server Connection
0021:         * ==========================
0022:         * The CalendarProvider uses the SSOAdapter APIs to establish a connection to the
0023:         * backend Calendar server.  The CalendarProvider references an SSOAdapter Coinfiguration
0024:         * via the display profile property 'ssoAdapter'.
0025:         *
0026:         * Calendar Views
0027:         * ==============
0028:         * Five views are supported by the CalendarProvider.  The display profile property
0029:         * 'view' is used to determine which calendar view is displayed.
0030:         *  - dayView
0031:         *  - dayWeekView (default)
0032:         *  - weekView
0033:         *  - monthView
0034:         *  - none
0035:         *
0036:         *
0037:         * History
0038:         * =======
0039:         * Note: This class is based on CalendarProvider originally shipped with iPS:MAP 3.0
0040:         * release. Changes has been made to make it work with SunONE Portal Server and
0041:         * SunONE Identity Server.
0042:         */
0043:
0044:        import java.lang.reflect.Constructor;
0045:        import java.lang.reflect.InvocationTargetException;
0046:        import java.net.URL;
0047:        import java.net.MalformedURLException;
0048:        import java.text.DateFormatSymbols;
0049:        import java.util.logging.Logger;
0050:        import java.util.logging.Level;
0051:        import java.util.logging.LogRecord;
0052:        import java.util.*;
0053:
0054:        import com.sun.portal.providers.Provider;
0055:        import com.sun.portal.providers.ProviderException;
0056:        import com.sun.portal.providers.ProviderAdapter;
0057:        import com.sun.portal.providers.ProfileProviderAdapter;
0058:        import com.sun.portal.providers.ProviderEditUtility;
0059:        import com.sun.portal.providers.calendar.CalendarApplicationHelper;
0060:        import com.sun.portal.providers.context.ProviderContext;
0061:        import com.sun.portal.providers.context.ProviderContextException;
0062:        import com.sun.portal.providers.context.ContainerProviderContext;
0063:        import com.sun.portal.providers.util.ProviderProperties;
0064:        import com.sun.portal.log.common.PortalLogger;
0065:
0066:        import com.sun.ssoadapter.SSOAdapter;
0067:        import com.sun.ssoadapter.SSOAdapterSession;
0068:        import com.sun.ssoadapter.SSOAdapterFactory;
0069:        import com.sun.ssoadapter.SSOAdapterException;
0070:
0071:        import com.sun.comclient.calendar.*;
0072:        import com.sun.comclient.calendar.socs.*;
0073:
0074:        import javax.servlet.http.HttpServletRequest;
0075:        import javax.servlet.http.HttpServletResponse;
0076:
0077:        public class CalendarProvider extends ProfileProviderAdapter {
0078:
0079:            private static final int DAYS_OF_PREFETCHED_EVENTS = 7;
0080:
0081:            private TimeZone userTimeZone = null;
0082:            private java.util.Locale userLocale = null;
0083:            private ResourceBundle bundle = null;
0084:
0085:            private ProviderContext providerContext = null;
0086:            protected SSOAdapterFactory adapterFactory = null;
0087:            protected HashMap appHandlers = null;
0088:
0089:            // display profile default values
0090:            private String fontFace = null;
0091:
0092:            // bundle default values
0093:            private String bundleAllDayEvent = null;
0094:            private String bundleAtLocation = null;
0095:            private String bundleAtNoLocation = null;
0096:            private String bundleConflict = null;
0097:            private String bundleDescriptionSeperator = null;
0098:            private String bundleDueEvents = null;
0099:            private String bundleDueTasks = null;
0100:            private String bundleFetchError = null;
0101:            private String bundleNoSummary = null;
0102:            private String bundleOpenError = null;
0103:            private String bundleOtherTasks = null;
0104:            private String bundleOverdueTasks = null;
0105:            private String bundleProcessingError = null;
0106:            private String bundleTaskCompleteStart = null;
0107:            private String bundleTaskCompleteEnd = null;
0108:
0109:            // flag to determine sso adapter configuration existence in init()
0110:            protected boolean isSSOConfigFound = true;
0111:
0112:            // flag to determine presentability in init()
0113:            protected Boolean isPresentable = null;
0114:
0115:            protected String editContainer = "";
0116:            protected String targetProvider = "";
0117:            protected String containerName = "";
0118:            protected List pflist = null;
0119:
0120:            // Create a logger for this class
0121:            private static Logger debugLogger = PortalLogger
0122:                    .getLogger(CalendarProvider.class);
0123:
0124:            /*
0125:             * Default Constructor
0126:             */
0127:            public CalendarProvider() {
0128:                super ();
0129:            }
0130:
0131:            /**
0132:             * Check to see if <code>ssoAdapter</code> exists.  If not then set
0133:             * <code>isSSOConfigFound</code> to false disabling editability for the
0134:             * user's Session.
0135:             *
0136:             */
0137:            public void init(String name, HttpServletRequest request)
0138:                    throws ProviderException {
0139:
0140:                super .init(name, request);
0141:                try {
0142:                    pflist = getProviderContext()
0143:                            .getClientAndLocalePropertiesFilters();
0144:                } catch (ProviderContextException pce) {
0145:                    debugLogger.fine("PSCC_CSPPC0011");
0146:                }
0147:
0148:                bundle = getResourceBundle();
0149:                providerContext = getProviderContext();
0150:                fontFace = getBestStringProperty("fontFace1", "Sans-serif",
0151:                        pflist);
0152:                appHandlers = new HashMap();
0153:                adapterFactory = SSOAdapterFactory.getInstance();
0154:
0155:                try {
0156:                    // get bundle defaults
0157:                    bundleAllDayEvent = bundle
0158:                            .getString("CalendarProvider-allDayEvent");
0159:                    bundleAtLocation = bundle.getString("atLocation");
0160:                    bundleAtNoLocation = bundle.getString("atNoLocation");
0161:                    bundleConflict = bundle.getString("conflict");
0162:                    bundleDescriptionSeperator = bundle
0163:                            .getString("seperatorDescription");
0164:                    bundleDueEvents = bundle.getString("dueEvents");
0165:                    bundleDueTasks = bundle.getString("dueTasks");
0166:                    bundleFetchError = bundle.getString("componentFetchError")
0167:                            + " ";
0168:                    bundleNoSummary = bundle
0169:                            .getString("CalendarProvider-noSummary");
0170:                    bundleOpenError = bundle.getString("calendarOpenError")
0171:                            + " ";
0172:                    bundleOtherTasks = bundle.getString("otherTasks");
0173:                    bundleOverdueTasks = bundle.getString("overdueTasks");
0174:                    bundleProcessingError = bundle
0175:                            .getString("componentProcessingError");
0176:                    bundleTaskCompleteStart = bundle
0177:                            .getString("taskCompleteStart");
0178:                    bundleTaskCompleteEnd = bundle.getString("taskCompleteEnd");
0179:
0180:                    // check for ssoadapter configuration existence
0181:                    SSOAdapter ssoAdapter = (SSOAdapter) adapterFactory
0182:                            .getSSOAdapter(getBestStringProperty("ssoAdapter",
0183:                                    pflist),
0184:                                    new SSOAdapterSession(request,
0185:                                            getProviderContext().getLocale(),
0186:                                            getProviderContext().getUserID(),
0187:                                            getName()));
0188:                } catch (MissingResourceException mre) {
0189:                    debugLogger.log(Level.INFO, "PSCC_CSPPC0012", mre);
0190:                    isPresentable = Boolean.FALSE;
0191:                } catch (NullPointerException npe) {
0192:                    debugLogger.log(Level.INFO, "PSCC_CSPPC0013", npe);
0193:                    isSSOConfigFound = false;
0194:                } catch (SSOAdapterException ssoe) {
0195:                    isSSOConfigFound = false;
0196:                    debugLogger.log(Level.INFO, "PSCC_CSPPC0014", ssoe
0197:                            .getMessage());
0198:                }
0199:
0200:                // pre-calculate presentability
0201:                // in the non-authless case in order to
0202:                // prevent re-calc'ing it each request
0203:                //
0204:                if (!getProviderContext().isAuthless(request)) {
0205:                    if (isPresentable(request)) {
0206:                        isPresentable = Boolean.TRUE;
0207:                    } else {
0208:                        isPresentable = Boolean.FALSE;
0209:                    }
0210:                }
0211:
0212:            } // end init
0213:
0214:            /**
0215:             * Channel is presentable if
0216:             * 1) parent.isPresentable()
0217:             * 2) existence of <code>display.template</code>
0218:             * 3) existence of sso adapter template
0219:             *
0220:             * @return true or false
0221:             */
0222:            public boolean isPresentable(HttpServletRequest request) {
0223:                boolean ip = false;
0224:                try {
0225:                    getTemplate("display.template");
0226:                } catch (ProviderException pe) {
0227:                    debugLogger.info("PSCC_CSPPC0015");
0228:                    return false;
0229:                }
0230:                if (isPresentable != null) {
0231:                    ip = isPresentable.booleanValue();
0232:                    return (ip && isSSOConfigFound);
0233:                } else {
0234:                    return isSSOConfigFound;
0235:                }
0236:            }
0237:
0238:            /**
0239:             * returns HTML content to the <code>ProfileProviderAdapter </code>
0240:             * to be displayed on the desktop
0241:             *
0242:             * @param request <code>HttpServletRequest</code>
0243:             * @param response <code>HttpServletResponse</code>
0244:             * @return <code>StringBuffer</code> containing the provider content
0245:             * @exception ProviderException indicates error in getting content
0246:             */
0247:
0248:            public StringBuffer getContent(HttpServletRequest request,
0249:                    HttpServletResponse response) throws ProviderException {
0250:
0251:                StringBuffer content = new StringBuffer();
0252:                StringBuffer escapedContent = new StringBuffer();
0253:                Hashtable contentTags = new Hashtable();
0254:                DateTime startToday = null;
0255:
0256:                CalendarStore calStore = null;
0257:                String tmpConf = null;
0258:
0259:                int index = 0;
0260:
0261:                SSOAdapter ssoAdapter = null;
0262:                Properties configProps = null;
0263:
0264:                try {
0265:
0266:                    ssoAdapter = (SSOAdapter) adapterFactory.getSSOAdapter(
0267:                            getBestStringProperty("ssoAdapter", pflist),
0268:                            new SSOAdapterSession(request, getProviderContext()
0269:                                    .getLocale(), getProviderContext()
0270:                                    .getUserID(), getName()));
0271:                    calStore = (CalendarStore) ssoAdapter.getConnection();
0272:                    ProviderEditUtility.setDefaultPresentation(getName(),
0273:                            getProviderContext(), contentTags);
0274:
0275:                } catch (SSOAdapterException ssoe) {
0276:                    debugLogger.log(Level.FINER, "PSCC_CSPPC0016", ssoe);
0277:                    String ssoError = bundle.getString("ssoadapterError");
0278:                    contentTags.put("ErrorMessage", ssoError);
0279:                    String strContent = getTemplate("display.template",
0280:                            contentTags).toString();
0281:                    content.append(strContent);
0282:                    return content;
0283:                } catch (Exception genexcp) {
0284:                    String errorMessage = bundle.getString("loginError");
0285:                    contentTags.put("ErrorMessage", errorMessage);
0286:                    String strContent = getTemplate("display.template",
0287:                            contentTags).toString();
0288:                    content.append(strContent);
0289:                    contentTags.clear();
0290:                    return content;
0291:                }
0292:
0293:                if ((ssoAdapter != null) && (calStore != null)) {
0294:
0295:                    // get timezone from user service
0296:                    String tz = getStringAttribute("preferredtimezone");
0297:
0298:                    if (tz == null || tz.length() == 0) {
0299:                        tz = TimeZone.getDefault().getID();
0300:                    }
0301:
0302:                    userTimeZone = TimeZone.getTimeZone(tz);
0303:                    calStore.getSession().setTimeZone(userTimeZone);
0304:
0305:                    configProps = ssoAdapter.getProperties();
0306:                    tmpConf = ssoAdapter.getName();
0307:
0308:                    contentTags.put("iwtDesktop-fontFace1", fontFace);
0309:
0310:                    //Get user locale
0311:                    userLocale = providerContext.getLocale();
0312:                    String applicationStartURL = "";
0313:                    CalendarApplicationHelper appHelper = null;
0314:                    String appHelperClass = getBestStringProperty(
0315:                            "applicationHelperURL", pflist);
0316:
0317:                    if (appHelperClass != null) {
0318:                        appHelper = getCalAppHelper(ssoAdapter, appHelperClass,
0319:                                true);
0320:                        if (appHelper != null) {
0321:                            applicationStartURL = getApplicationStartURL(
0322:                                    appHelper, request);
0323:                        } else {
0324:                            applicationStartURL = null;
0325:                        }
0326:                        if (applicationStartURL != null) {
0327:                            contentTags.put("calendar-display-client-uri",
0328:                                    applicationStartURL);
0329:                        }
0330:                    }
0331:
0332:                    if (appHelper == null) {
0333:                        debugLogger.info("PSCC_CSPPC0017");
0334:                    }
0335:
0336:                    contentTags.put("config-index", String.valueOf(index));
0337:
0338:                    //get start time
0339:                    try {
0340:                        startToday = new DateTime(userTimeZone);
0341:                    } catch (NullPointerException ne) {
0342:                        debugLogger.log(Level.FINER, "PSCC_CSPPC0018", ne);
0343:                        startToday = new DateTime();
0344:                    }
0345:
0346:                    //Set startTime for today
0347:                    startToday.setTime(0, 0, 0);
0348:
0349:                    // Count events and add summary tags
0350:                    CalendarComponent[] components = null;
0351:                    CalendarComponent[] wkComponents = null;
0352:                    VEvent[] events = null;
0353:                    VEvent[] wkEvents = null;
0354:                    VTodo[] tasks = null;
0355:                    VTodo[] wkTasks = null;
0356:                    VEvent currentEvent = null;
0357:                    VTodo currentTask = null;
0358:                    Vector evtToday = new Vector();
0359:                    Vector taskToday = new Vector();
0360:                    Vector evtWk = new Vector();
0361:                    Vector taskWk = new Vector();
0362:                    StringBuffer dayView = null;
0363:                    StringBuffer weekView = null;
0364:                    int todaysEvts = 0;
0365:                    int todaysTsks = 0;
0366:
0367:                    // Get calendar display preferences from DisplayProfile
0368:                    String view = getBestStringProperty("view", "dayWeekView",
0369:                            pflist);
0370:
0371:                    /** NOTE: There are five scenarios of event and task fetch
0372:                     * a) dayView : Day View
0373:                     * b) weekView : Week View
0374:                     * c) dayWeekView : Day and Week View
0375:                     * d) monthView : Month View
0376:                     * e) none
0377:                     */
0378:
0379:                    //Make a new DateTime Object for comparing the todo timestamps to
0380:                    //figure out if they are overdue.
0381:                    DateTime currentDT = (DateTime) (startToday.clone());
0382:
0383:                    // open the user's calendar.  refer to the 'calendar' display profile
0384:                    // property to determine which calendar to load.  some calendar
0385:                    // store's (notes/exchange) only allow the user to view their own
0386:                    // calendar, therefore it is acceptable for the value to be "".
0387:                    //
0388:                    ICalendar calendar = null;
0389:                    String calendarToLoad = null;
0390:
0391:                    try {
0392:                        calendarToLoad = getBestStringProperty("calendar", "",
0393:                                pflist);
0394:
0395:                        if (calendarToLoad.length() > 0) {
0396:                            calendar = calStore.openCalendar(calendarToLoad);
0397:                        } else {
0398:                            calendar = calStore.openCalendar();
0399:                        }
0400:                    } catch (CalendarStoreException cesx) {
0401:                        debugLogger.log(Level.INFO, "PSCC_CSPPC0016", cesx);
0402:                        return getErrorContent(bundleOpenError
0403:                                + cesx.getMessage());
0404:                    }
0405:
0406:                    // Day and Week View : case (c)
0407:                    //
0408:                    if (view.equals("dayWeekView")) {
0409:                        DateTime endDate = (DateTime) (startToday.clone());
0410:                        endDate.add(java.util.Calendar.DATE,
0411:                                DAYS_OF_PREFETCHED_EVENTS);
0412:
0413:                        try {
0414:                            wkComponents = calendar
0415:                                    .fetchComponents(startToday, endDate,
0416:                                            ICalendar.VEVENT | ICalendar.VTODO);
0417:                        } catch (CalendarException cx) {
0418:                            debugLogger.log(Level.INFO, "PSCC_CSPPC0016", cx);
0419:                            return getErrorContent(bundleFetchError
0420:                                    + cx.getMessage());
0421:                        }
0422:
0423:                        try {
0424:
0425:                            for (int i = 0; i < wkComponents.length; i++) {
0426:
0427:                                //EVENT
0428:                                if (wkComponents[i] instanceof  VEvent) {
0429:                                    currentEvent = (VEvent) wkComponents[i];
0430:                                    evtWk.add(currentEvent);
0431:
0432:                                    // check for todays events
0433:                                    if (matchDayMonthYear(currentEvent
0434:                                            .getStartTime(), startToday)) {
0435:                                        evtToday.add(currentEvent);
0436:                                        todaysEvts++;
0437:                                    }
0438:                                    continue;
0439:                                }
0440:
0441:                                //TASK
0442:                                if (wkComponents[i] instanceof  VTodo) {
0443:
0444:                                    currentTask = (VTodo) wkComponents[i];
0445:
0446:                                    // check to see if task is scheduled for today
0447:                                    if (isTodayTask(currentTask, currentDT)) {
0448:                                        taskToday.add(currentTask);
0449:                                        taskWk.add(currentTask);
0450:                                        todaysTsks++;
0451:
0452:                                        // check to see if task is overdue
0453:                                    } else if (isTaskOverDue(currentDT,
0454:                                            currentTask)) {
0455:                                        taskToday.add(currentTask);
0456:
0457:                                    } else {
0458:                                        taskWk.add(currentTask);
0459:                                    }
0460:                                }
0461:
0462:                            }//end for
0463:
0464:                            events = (VEvent[]) evtToday.toArray(new VEvent[0]);
0465:                            tasks = (VTodo[]) taskToday.toArray(new VTodo[0]);
0466:
0467:                            //Get the content for day view
0468:                            dayView = getDayViewContent(startToday, tmpConf,
0469:                                    request, events, tasks, calStore,
0470:                                    appHelper, applicationStartURL);
0471:
0472:                            contentTags
0473:                                    .put("calendar-display-dayView", dayView);
0474:
0475:                            //Now do the weekview
0476:                            wkEvents = (VEvent[]) evtWk.toArray(new VEvent[0]);
0477:                            wkTasks = (VTodo[]) taskWk.toArray(new VTodo[0]);
0478:
0479:                            weekView = getWeekViewContent(startToday,
0480:                                    currentDT, tmpConf, request, wkEvents,
0481:                                    wkTasks, calStore, appHelper,
0482:                                    applicationStartURL,
0483:                                    "calendar-display-weekView",
0484:                                    "display-weekView", null, false);
0485:
0486:                            contentTags.put("calendar-display-weekView",
0487:                                    weekView);
0488:
0489:                        } catch (Exception csx) {
0490:                            debugLogger.log(Level.INFO, "PSCC_CSPPC0016", csx);
0491:                            return getErrorContent(bundleProcessingError);
0492:                        }
0493:
0494:                        // Day View : case (a)
0495:                    } else if (view.equals("dayView")) {
0496:
0497:                        // Dayview is selected but not weekview.
0498:                        // So just do the fetch for the day
0499:                        //
0500:                        try {
0501:                            components = calendar
0502:                                    .fetchComponents(ICalendar.VEVENT
0503:                                            | ICalendar.VTODO);
0504:                        } catch (CalendarException cx1) {
0505:                            debugLogger.log(Level.INFO, "PSCC_CSPPC0016", cx1);
0506:                            return getErrorContent(bundleFetchError
0507:                                    + cx1.getMessage());
0508:                        }
0509:
0510:                        try {
0511:                            for (int j = 0; j < components.length; j++) {
0512:                                //Check if event
0513:                                if (components[j] instanceof  VEvent) {
0514:                                    currentEvent = (VEvent) components[j];
0515:                                    if (matchDayMonthYear(currentEvent
0516:                                            .getStartTime(), startToday)) {
0517:                                        evtToday.add(currentEvent);
0518:                                        todaysEvts++;
0519:                                    }
0520:                                    continue;
0521:                                }
0522:
0523:                                //Check if task and if so is it overdue
0524:                                if (components[j] instanceof  VTodo) {
0525:
0526:                                    currentTask = (VTodo) components[j];
0527:
0528:                                    // check to see if task is scheduled for today
0529:                                    if (isTodayTask(currentTask, currentDT)) {
0530:                                        taskToday.add(currentTask);
0531:                                        todaysTsks++;
0532:
0533:                                        // check to see if task is overdue
0534:                                    } else if (isTaskOverDue(currentDT,
0535:                                            currentTask)) {
0536:                                        taskToday.add(currentTask);
0537:                                    }
0538:                                }
0539:                            }//end for
0540:
0541:                            events = (VEvent[]) evtToday.toArray(new VEvent[0]);
0542:                            tasks = (VTodo[]) taskToday.toArray(new VTodo[0]);
0543:
0544:                            //Get the content for day view
0545:                            dayView = getDayViewContent(startToday, tmpConf,
0546:                                    request, events, tasks, calStore,
0547:                                    appHelper, applicationStartURL);
0548:
0549:                            contentTags
0550:                                    .put("calendar-display-dayView", dayView);
0551:
0552:                        } catch (Exception csx) {
0553:                            debugLogger.log(Level.INFO, "PSCC_CSPPC0016", csx);
0554:                            return getErrorContent(bundleProcessingError);
0555:                        }
0556:
0557:                        // Week View : case (b)
0558:                    } else if (view.equals("weekView")) {
0559:
0560:                        DateTime endDate = (DateTime) (startToday.clone());
0561:                        endDate.add(java.util.Calendar.DATE,
0562:                                DAYS_OF_PREFETCHED_EVENTS);
0563:
0564:                        try {
0565:                            wkComponents = calendar
0566:                                    .fetchComponents(startToday, endDate,
0567:                                            ICalendar.VEVENT | ICalendar.VTODO);
0568:                        } catch (CalendarException cx) {
0569:                            debugLogger.log(Level.INFO, "PSCC_CSPPC0016", cx);
0570:                            return getErrorContent(bundleFetchError
0571:                                    + cx.getMessage());
0572:                        }
0573:
0574:                        try {
0575:                            for (int i = 0; i < wkComponents.length; i++) {
0576:                                //get the summary info and fill the week vectors
0577:                                if (wkComponents[i] instanceof  VEvent) {
0578:                                    currentEvent = (VEvent) wkComponents[i];
0579:
0580:                                    if (matchDayMonthYear(currentEvent
0581:                                            .getStartTime(), startToday)) {
0582:                                        todaysEvts++;
0583:                                    }
0584:                                    evtWk.add(currentEvent);
0585:                                    continue;
0586:                                }
0587:                                //Check if task and if so is it overdue
0588:                                if (wkComponents[i] instanceof  VTodo) {
0589:
0590:                                    currentTask = (VTodo) wkComponents[i];
0591:
0592:                                    // check to see if task is scheduled for today
0593:                                    if (isTodayTask(currentTask, currentDT)) {
0594:                                        todaysTsks++;
0595:                                        taskWk.add(currentTask);
0596:                                    } else if (isTaskOverDue(currentDT,
0597:                                            currentTask)) {
0598:                                    } else {
0599:                                        taskWk.add(currentTask);
0600:                                    }
0601:                                }
0602:                            }//end for
0603:
0604:                            wkEvents = (VEvent[]) evtWk.toArray(new VEvent[0]);
0605:                            wkTasks = (VTodo[]) taskWk.toArray(new VTodo[0]);
0606:
0607:                            weekView = getWeekViewContent(startToday,
0608:                                    currentDT, tmpConf, request, wkEvents,
0609:                                    wkTasks, calStore, appHelper,
0610:                                    applicationStartURL,
0611:                                    "calendar-display-weekView",
0612:                                    "display-weekView", null, true);
0613:
0614:                            contentTags.put("calendar-display-dayView", " ");
0615:                            contentTags.put("calendar-display-weekView",
0616:                                    weekView);
0617:
0618:                        } catch (Exception csx) {
0619:                            debugLogger.log(Level.INFO, "PSCC_CSPPC0016", csx);
0620:                            return getErrorContent(bundleProcessingError);
0621:                        }
0622:
0623:                        // Month View : case (d)
0624:                    } else if (view.equals("monthView")) {
0625:                        StringBuffer monthView = new StringBuffer();
0626:                        DateTime monthStart = getMonthStart(startToday);
0627:                        DateTime monthEnd = getMonthEnd(startToday);
0628:                        CalendarComponent[] monthComponents = null;
0629:                        VEvent[] monthEvents = null;
0630:                        VTodo[] monthTasks = null;
0631:                        currentEvent = null;
0632:                        Vector eventMonth = new Vector();
0633:                        Vector taskMonth = new Vector();
0634:                        Hashtable monthTags = new Hashtable();
0635:                        String tagPrefix = "calendar-display-monthView";
0636:
0637:                        // fetch month components based on month start and end
0638:                        try {
0639:                            monthComponents = calendar.fetchComponents(
0640:                                    monthStart, monthEnd, ICalendar.VEVENT
0641:                                            | ICalendar.VTODO);
0642:                        } catch (CalendarException cx) {
0643:                            debugLogger.log(Level.INFO, "PSCC_CSPPC0016", cx);
0644:                            return getErrorContent(bundleFetchError
0645:                                    + cx.getMessage());
0646:                        }
0647:
0648:                        DateTime iteratorDate = (DateTime) (monthStart.clone());
0649:                        DateTime iteratorDate2 = (DateTime) (monthStart.clone());
0650:                        iteratorDate2.add(java.util.Calendar.DATE, -1);
0651:
0652:                        populateHeaderTags(monthTags, tagPrefix, startToday);
0653:                        populateDayOfWeekTags(monthTags, tagPrefix,
0654:                                iteratorDate2);
0655:                        monthTags.put("iwtDesktop-fontFace1", fontFace);
0656:
0657:                        try {
0658:                            for (int i = 0; i < monthComponents.length; i++) {
0659:
0660:                                // perform summary calculations for events
0661:                                if (monthComponents[i] instanceof  VEvent) {
0662:                                    currentEvent = (VEvent) monthComponents[i];
0663:
0664:                                    if (matchDayMonthYear(currentEvent
0665:                                            .getStartTime(), startToday)) {
0666:                                        todaysEvts++;
0667:                                    }
0668:                                    eventMonth.add(currentEvent);
0669:                                    continue;
0670:                                }
0671:
0672:                                // perform summary calculations for tasks
0673:                                if (monthComponents[i] instanceof  VTodo) {
0674:                                    currentTask = (VTodo) monthComponents[i];
0675:
0676:                                    // check to see if task is scheduled for today
0677:                                    if (isTodayTask(currentTask, currentDT)) {
0678:                                        todaysTsks++;
0679:                                        taskMonth.add(currentTask);
0680:                                    } else if (isTaskOverDue(currentDT,
0681:                                            currentTask)) {
0682:                                    } else {
0683:                                        taskMonth.add(currentTask);
0684:                                    }
0685:                                }
0686:                            }//end for
0687:
0688:                            monthEvents = (VEvent[]) eventMonth
0689:                                    .toArray(new VEvent[0]);
0690:                            monthTasks = (VTodo[]) taskMonth
0691:                                    .toArray(new VTodo[0]);
0692:
0693:                            monthView = getTemplate(
0694:                                    "display-monthView-dayOfWeek.template",
0695:                                    monthTags);
0696:                            monthTags.put(tagPrefix + "-dayOfWeek", monthView);
0697:
0698:                            // construct weeks
0699:                            for (int k = 0; k < 5; k++) {
0700:                                monthView = getWeekViewContent(iteratorDate,
0701:                                        currentDT, tmpConf, request,
0702:                                        monthEvents, monthTasks, calStore,
0703:                                        appHelper, applicationStartURL,
0704:                                        "calendar-display-monthView",
0705:                                        "display-monthView",
0706:                                        "display-monthView-weekView.template",
0707:                                        false);
0708:
0709:                                monthTags.put(
0710:                                        "calendar-display-monthView-weekView"
0711:                                                + k, monthView);
0712:                                iteratorDate.add(Calendar.DAY_OF_MONTH, 7);
0713:                            }
0714:
0715:                            monthView = getTemplate(
0716:                                    "display-monthView.template", monthTags);
0717:                            contentTags.put("calendar-display-monthView",
0718:                                    monthView);
0719:
0720:                        } catch (Exception csx) {
0721:                            debugLogger.log(Level.INFO, "PSCC_CSPPC0016", csx);
0722:                            return getErrorContent(bundleProcessingError);
0723:                        }
0724:
0725:                        // None View : case (e)
0726:                        //But we still have to count todays evt/todos and overdue tasks
0727:                    } else {
0728:
0729:                        try {
0730:                            components = calendar
0731:                                    .fetchComponents(ICalendar.VEVENT
0732:                                            | ICalendar.VTODO);
0733:                        } catch (CalendarException cxn) {
0734:                            debugLogger.log(Level.INFO, "PSCC_CSPPC0016", cxn);
0735:                            return getErrorContent(bundleFetchError
0736:                                    + cxn.getMessage());
0737:                        }
0738:
0739:                        try {
0740:
0741:                            for (int k = 0; k < components.length; k++) {
0742:                                //Check if event
0743:                                if (components[k] instanceof  VEvent) {
0744:                                    if (matchDayMonthYear(
0745:                                            ((VEvent) components[k])
0746:                                                    .getStartTime(), startToday)) {
0747:                                        todaysEvts++;
0748:                                    }
0749:                                    continue;
0750:                                }
0751:
0752:                                //Check if task and if so is it overdue
0753:                                if (components[k] instanceof  VTodo) {
0754:
0755:                                    currentTask = (VTodo) components[k];
0756:
0757:                                    // check to see if task is scheduled for today
0758:                                    if (isTodayTask(currentTask, currentDT)) {
0759:                                        todaysTsks++;
0760:
0761:                                    }
0762:                                }
0763:                            }//end for
0764:
0765:                            contentTags.put("calendar-display-dayView", " ");
0766:                            contentTags.put("calendar-display-weekView", " ");
0767:
0768:                        } catch (Exception csx) {
0769:                            debugLogger.log(Level.INFO, "PSCC_CSPPC0016", csx);
0770:                            throw new ProviderException(csx.getMessage());
0771:                        }
0772:                    }
0773:
0774:                    StringBuffer summ = getSummaryContent(todaysEvts,
0775:                            todaysTsks);
0776:                    contentTags.put("calendar-display-dayView-summary", summ);
0777:
0778:                    /** Now populate the contentTags Hashtable to do tagswapping
0779:                     * and get the final content to render
0780:                     */
0781:
0782:                    try {
0783:                        //user id
0784:                        contentTags.put("CalUserId", configProps.getProperty(
0785:                                "uid", ""));
0786:                        debugLogger.log(Level.FINER, "PSCC_CSPPC0019",
0787:                                configProps.getProperty("uid"));
0788:                        //password
0789:                        contentTags.put("CalPassword", configProps.getProperty(
0790:                                "password", ""));
0791:
0792:                        //Add CalendarStore to Hashtable..
0793:                        contentTags.put("calendar-display-client-calStore",
0794:                                calStore);
0795:
0796:                        // Add Client URL tags
0797:
0798:                        if ((applicationStartURL != null)
0799:                                && (!applicationStartURL.equals(""))) {
0800:                            contentTags.put("calendar-display-clientURL",
0801:                                    getTemplate("display-clientURL.template"));
0802:                        }
0803:
0804:                        // Finally get tagswapped content
0805:                        String strContent = getTemplate("display.template",
0806:                                contentTags).toString();
0807:                        content.append(strContent);
0808:                        contentTags.clear();
0809:
0810:                    } catch (Exception nex) {
0811:                        debugLogger.log(Level.INFO, "PSCC_CSPPC0016", nex);
0812:                    }
0813:                    index++;
0814:
0815:                    // connection management.  check ssoadapter for per request connection
0816:                    // management property.  if true, then close connection to store.
0817:                    //
0818:                    String eprc = configProps.getProperty(
0819:                            "enablePerRequestConnection", "false");
0820:
0821:                    if ((eprc != null) && (eprc.equals("true"))) {
0822:                        ssoAdapter.closeConnection();
0823:                    }
0824:
0825:                } else {
0826:
0827:                    // user level sso adapter exists, but store is null
0828:                    //
0829:                    if ((ssoAdapter != null)
0830:                            && (ssoAdapter.getName().endsWith("_" + getName()))) {
0831:                        return getErrorContent(bundle.getString("loginError"));
0832:
0833:                        // user level sso adapter does not exist
0834:                        //
0835:                    } else {
0836:                        return getErrorContent(bundle
0837:                                .getString("noConfigError"));
0838:                    }
0839:                }
0840:
0841:                return content;
0842:            } //end getContent
0843:
0844:            protected URL getURL(String url) {
0845:                try {
0846:                    return new URL(url);
0847:                } catch (MalformedURLException mu) {
0848:                    return null;
0849:                }
0850:            }
0851:
0852:            /**
0853:             *@param  request                HttpServletRequest
0854:             *@param  response               HttpServletResponse
0855:             *@return                        StringBuffer HTML content for the edit page
0856:             *@exception  ProviderException  indicates error in generating edit content
0857:             */
0858:
0859:            public StringBuffer getEdit(HttpServletRequest request,
0860:                    HttpServletResponse response) throws ProviderException {
0861:
0862:                StringBuffer content = new StringBuffer();
0863:                SSOAdapter ssoAdapter = null;
0864:                Hashtable tagTable = new Hashtable();
0865:                editContainer = request.getParameter("provider");
0866:                targetProvider = request.getParameter("targetprovider");
0867:                containerName = request.getParameter("containerName");
0868:
0869:                debugLogger.log(Level.FINER, "PSCC_CSPPC0020", new Object[] {
0870:                        editContainer, targetProvider, containerName });
0871:
0872:                try {
0873:                    ssoAdapter = (SSOAdapter) adapterFactory.getSSOAdapter(
0874:                            getBestStringProperty("ssoAdapter", pflist),
0875:                            new SSOAdapterSession(request, getProviderContext()
0876:                                    .getLocale(), getProviderContext()
0877:                                    .getUserID(), getName()));
0878:                    ProviderEditUtility.setDefaultPresentation(getName(),
0879:                            getProviderContext(), tagTable);
0880:                } catch (Exception e) {
0881:                    debugLogger.log(Level.FINER, "PSCC_CSPPC0021", e);
0882:                }
0883:
0884:                String appPref = ProviderEditUtility.getRequestParameter(
0885:                        "appPref", request);
0886:                if (!appPref.equals("")) {
0887:
0888:                    // if 'loadSubscribedCalendars' then retrieve the user's subscribed
0889:                    // calendars from the calendar store and set the 'calendarSelectOptions'
0890:                    // collection for use in the edit view.
0891:                    //
0892:                    if ((existsBooleanProperty("loadSubscribedCalendars"))
0893:                            && (getBestBooleanProperty(
0894:                                    "loadSubscribedCalendars", false, pflist))) {
0895:                        setCalendarSelectOptions(ssoAdapter);
0896:                    }
0897:
0898:                    CalendarApplicationHelper cah = getCalAppHelper(ssoAdapter,
0899:                            appPref, false);
0900:                    content = cah.getAppPrefsEdit(this , request, response);
0901:                } else {
0902:
0903:                    tagTable.put("iwtDesktop-fontFace1", fontFace);
0904:                    // Get the starting template
0905:                    content
0906:                            .append(getTemplate("edit-start.template", tagTable));
0907:
0908:                    // Get the SSOAdapter attributes
0909:                    try {
0910:                        content.append(ProviderEditUtility.getSSOAdapterPrefs(
0911:                                (ProviderAdapter) this , ssoAdapter));
0912:                    } catch (Exception e) {
0913:                        debugLogger.log(Level.FINE, "PSCC_CSPPC0022", e);
0914:                    }
0915:
0916:                    // Get ending template
0917:                    content.append(getTemplate("edit-end.template", tagTable));
0918:
0919:                    CalendarApplicationHelper cah = null;
0920:                    Map appHelperClasses = getAppHandlerMap();
0921:                    if (appHelperClasses == null) {
0922:                        debugLogger.info("PSCC_CSPPC0023");
0923:                    } else {
0924:                        // Don't generate link if null.
0925:
0926:                        Iterator iter = appHelperClasses.entrySet().iterator();
0927:                        while (iter.hasNext()) {
0928:                            Map.Entry appClass = (Map.Entry) iter.next();
0929:                            String appHelperClass = (String) appClass
0930:                                    .getValue();
0931:                            cah = getCalAppHelper(ssoAdapter, appHelperClass,
0932:                                    true);
0933:                            String link = "";
0934:                            if (cah == null) {
0935:                                debugLogger.info("PSCC_CSPPC0024");
0936:                            } else {
0937:                                link = cah.getAppHelperEditLink(request,
0938:                                        getProviderContext());
0939:                            }
0940:                            if ((link != null) || (!link.equals(""))) {
0941:                                content.append(link);
0942:                            } else {
0943:                                debugLogger.fine("PSCC_CSPPC0025");
0944:                            }
0945:                        }
0946:                    }
0947:
0948:                }
0949:
0950:                return content;
0951:
0952:            }
0953:
0954:            /**
0955:             *  Retrieves the CalendarApplicationHelper
0956:             *
0957:             * @param request      The HttpServletRequest object
0958:             * @param ssoAdapter   The SSOAdapter object
0959:             * @return CalendarApplicationHelper
0960:             */
0961:            protected Map getAppHandlerMap() {
0962:                Map appHelperClasses = null;
0963:                appHelperClasses = getBestCollectionProperty(
0964:                        "applicationHelperEdit", pflist);
0965:                return appHelperClasses;
0966:            }
0967:
0968:            /**
0969:             *  Gets the aBAppHelper attribute of the AddressBookProvider object
0970:             *
0971:             *@param  ssoAdapter  ssoAdapter for this channel
0972:             *@return             The aBAppHelper value
0973:             */
0974:            private CalendarApplicationHelper getCalAppHelper(
0975:                    SSOAdapter ssoAdapter, String applicationHelperName,
0976:                    boolean safe) {
0977:                CalendarApplicationHelper abApplicationHelper = null;
0978:
0979:                if (ssoAdapter == null) {
0980:                    debugLogger.info("PSCC_CSPPC0026");
0981:                    return null;
0982:                }
0983:
0984:                if (applicationHelperName == null) {
0985:                    debugLogger.info("PSCC_CSPPC0027");
0986:                    return null;
0987:                }
0988:
0989:                //Verify that the applicationHelperName is a valid App Helper and not any old class
0990:                //This is done to prevent malicious users from instantiate any class they wish
0991:                boolean validClass = safe;
0992:                if (!safe) {
0993:                    Map validAppHelpers = getAppHandlerMap();
0994:                    if (validAppHelpers != null) {
0995:                        validClass = validAppHelpers
0996:                                .containsKey(applicationHelperName);
0997:                        debugLogger.log(Level.FINER, "PSCC_CSPPC0028", Boolean
0998:                                .toString(validClass));
0999:                    } else {
1000:                        validClass = false;
1001:                    }
1002:                }
1003:                // try to get the stored AppHandler
1004:                if (ProviderEditUtility.isAppHandlerSet(appHandlers,
1005:                        applicationHelperName)) {
1006:                    debugLogger.log(Level.FINER, "PSCC_CSPPC0029",
1007:                            applicationHelperName);
1008:                    abApplicationHelper = (CalendarApplicationHelper) appHandlers
1009:                            .get(applicationHelperName);
1010:                    return abApplicationHelper;
1011:                } else if (validClass) {
1012:                    //Create the new AppHelper and store it
1013:
1014:                    try {
1015:                        Class applicationHelperClass = Class
1016:                                .forName(applicationHelperName);
1017:                        Class[] argConst = {};
1018:                        Constructor applicationHelperConst = applicationHelperClass
1019:                                .getConstructor(argConst);
1020:                        Object[] argConstObj = {};
1021:                        abApplicationHelper = (CalendarApplicationHelper) applicationHelperConst
1022:                                .newInstance(argConstObj);
1023:
1024:                    } catch (ClassNotFoundException cnfe) {
1025:                        debugLogger.log(Level.INFO, "PSCC_CSPPC0016", cnfe);
1026:                    } catch (NoSuchMethodException nsme) {
1027:                        debugLogger.log(Level.INFO, "PSCC_CSPPC0016", nsme);
1028:                    } catch (InstantiationException ine) {
1029:                        debugLogger.log(Level.INFO, "PSCC_CSPPC0016", ine);
1030:                    } catch (IllegalAccessException iae) {
1031:                        debugLogger.log(Level.INFO, "PSCC_CSPPC0016", iae);
1032:                    } catch (InvocationTargetException ite) {
1033:                        debugLogger.log(Level.INFO, "PSCC_CSPPC0016", ite);
1034:                    }
1035:
1036:                    try {
1037:                        abApplicationHelper.init(this , ssoAdapter);
1038:                    } catch (Exception e) {
1039:                        if (debugLogger.isLoggable(Level.FINE)) {
1040:                            LogRecord logRecord = new LogRecord(Level.FINE,
1041:                                    "PSCC_CSPPC0030");
1042:                            logRecord.setLoggerName(debugLogger.getName());
1043:                            logRecord
1044:                                    .setParameters(new Object[] { applicationHelperName });
1045:                            logRecord.setThrown(e);
1046:                            debugLogger.log(logRecord);
1047:                        }
1048:                        return null;
1049:
1050:                    }
1051:
1052:                    // save application helper into the hashmap
1053:                    if (abApplicationHelper != null) {
1054:                        debugLogger.log(Level.FINER, "PSCC_CSPPC0031",
1055:                                applicationHelperName);
1056:                        appHandlers.put(applicationHelperName,
1057:                                abApplicationHelper);
1058:                        abApplicationHelper.setName(applicationHelperName);
1059:                        return abApplicationHelper;
1060:                    } else {
1061:                        return null;
1062:                    }
1063:                } else {
1064:                    return null;
1065:                }
1066:            }
1067:
1068:            /**
1069:             *  processEdit handles the processing of the edit form once submitted by the
1070:             *  user
1071:             *
1072:             *@param  request                HttpServletRequest
1073:             *@param  response               HttpServletResponse
1074:             *@return                        java.net.URL sends back a redirect url
1075:             *@exception  ProviderException  indicates error in processing of submitted
1076:             *      data
1077:             */
1078:
1079:            public URL processEdit(HttpServletRequest req,
1080:                    HttpServletResponse res) throws ProviderException {
1081:                SSOAdapter ssoAdapter = null;
1082:                URL returnURL = null;
1083:                editContainer = req.getParameter("provider");
1084:                targetProvider = req.getParameter("targetprovider");
1085:                containerName = req.getParameter("containerName");
1086:
1087:                try {
1088:                    ssoAdapter = (SSOAdapter) adapterFactory.getSSOAdapter(
1089:                            getBestStringProperty("ssoAdapter", pflist),
1090:                            new SSOAdapterSession(req, getProviderContext()
1091:                                    .getLocale(), getProviderContext()
1092:                                    .getUserID(), getName()));
1093:
1094:                } catch (SSOAdapterException ssoe) {
1095:                    debugLogger.log(Level.FINER, "PSCC_CSPPC0021", ssoe);
1096:                }
1097:
1098:                String appPref = ProviderEditUtility.getRequestParameter(
1099:                        "appPref", req);
1100:
1101:                debugLogger
1102:                        .log(Level.FINER, "PSCC_CSPPC0032", new Object[] {
1103:                                editContainer, targetProvider, containerName,
1104:                                appPref });
1105:
1106:                CalendarApplicationHelper cah = null;
1107:                if (!appPref.equals("")) {
1108:                    cah = getCalAppHelper(ssoAdapter, appPref, false);
1109:                    if (cah == null) {
1110:                        debugLogger.fine("PSCC_CSPPC0033");
1111:                        returnURL = null;
1112:                    } else {
1113:                        returnURL = cah.processAppPrefsEdit(this , req, res);
1114:                        debugLogger.log(Level.FINER, "PSCC_CSPPC0034",
1115:                                returnURL);
1116:                    }
1117:                } else {
1118:
1119:                    //Set the SSOAdapter attributes
1120:                    ProviderEditUtility.editContainer = editContainer;
1121:                    ProviderEditUtility.container = containerName;
1122:                    SSOAdapter newAdapter = null;
1123:                    try {
1124:                        newAdapter = ProviderEditUtility.setSSOAdapterPrefs(
1125:                                (ProviderAdapter) this , ssoAdapter,
1126:                                adapterFactory, req);
1127:                        returnURL = ProviderEditUtility.getErrorURL();
1128:                        if (returnURL == null) {
1129:                            if (newAdapter != null) {
1130:                                debugLogger.finer("PSCC_CSPPC0035");
1131:                                appPref = getBestStringProperty(
1132:                                        "applicationHelperURL", pflist);
1133:                                cah = getCalAppHelper(ssoAdapter, appPref,
1134:                                        false);
1135:                                cah.init(this , newAdapter);
1136:                            }
1137:                        }
1138:                    } catch (Exception e) {
1139:                        debugLogger.finer("PSCC_CSPPC0036");
1140:                    }
1141:
1142:                }
1143:                return returnURL;
1144:            }
1145:
1146:            /**
1147:             * @param msg the message String to be displayed as error
1148:             * @return StringBuffer HTML content for the error display
1149:             *
1150:             */
1151:            protected StringBuffer getErrorContent(String msg)
1152:                    throws ProviderException {
1153:                Hashtable errorTags = new Hashtable();
1154:                errorTags.put("calendar-display-error", msg);
1155:                return getTemplate("display-error.template", errorTags);
1156:            }
1157:
1158:            /*
1159:             * Test is the todo is completed or not.
1160:             *
1161:             * @param  task VTodo
1162:             * @return true if the task is complete
1163:             */
1164:            private boolean isTaskComplete(VTodo task) {
1165:                try {
1166:                    return task.isCompleted();
1167:                } catch (OperationNotSupportedException onse) {
1168:                    debugLogger.log(Level.FINE, "PSCC_CSPPC0016", onse);
1169:                } catch (CalendarComponentException cce) {
1170:                    debugLogger.log(Level.FINE, "PSCC_CSPPC0016", cce);
1171:                }
1172:
1173:                return false;
1174:            }
1175:
1176:            /**
1177:             * Determines if Task is overdue
1178:             *
1179:             * @param  dt   DateTime object to be compared against
1180:             * @param  tsk  Task that needs to be compared
1181:             * @throws OperationNotSupportedException
1182:             * @return true if the task is overdue. default is false.
1183:             */
1184:            private boolean isTaskOverDue(DateTime dt, VTodo tsk)
1185:                    throws OperationNotSupportedException {
1186:
1187:                boolean taskOverdue = false;
1188:
1189:                try {
1190:                    DateTime taskDT = tsk.getDueTime();
1191:                    if (taskDT == null) {
1192:                        return taskOverdue;
1193:                    }
1194:
1195:                    // check to see if the task is an 'All Day' task.  If yes,
1196:                    // then verify the task does not correspond to today and is
1197:                    // not in the future if so then the task is overdue.
1198:                    // Else, check to see if the task due time is before the
1199:                    // current time.
1200:                    //
1201:                    if (tsk.isAllDay()) {
1202:                        if ((!matchDayMonthYear(dt, taskDT))
1203:                                && (!isTaskComplete(tsk))
1204:                                && (!taskDT.after(dt))) {
1205:                            taskOverdue = true;
1206:                        }
1207:                    } else {
1208:                        if ((taskDT.before(dt)) && (!isTaskComplete(tsk))) {
1209:                            taskOverdue = true;
1210:                        }
1211:                    }
1212:                } catch (Exception e) {
1213:                    debugLogger.log(Level.FINER, "PSCC_CSPPC0016", e);
1214:                }
1215:
1216:                return taskOverdue;
1217:            }
1218:
1219:            /**
1220:             * getDayViewContent gets the HTML dayview of a specific calendar
1221:             *
1222:             * @return StringBuffer day view content for calendar
1223:             * @param today DateTime object on which day view will be generated
1224:             * @param events array of Event objects scheduled for today
1225:             * @param tasks array of Task objects due today
1226:             * @exception ProviderException
1227:             * @see com.sun.portal.providers.ProviderException
1228:             *
1229:             */
1230:
1231:            protected StringBuffer getDayViewContent(DateTime today,
1232:                    String cnfgName, HttpServletRequest rqst, VEvent events[],
1233:                    VTodo tasks[], CalendarStore calStore,
1234:                    CalendarApplicationHelper appHelper, String clientURL)
1235:                    throws ProviderException, Exception {
1236:                boolean overdue = false;
1237:                int odTasks = 0;
1238:                Hashtable dayViewTags = new Hashtable();
1239:                StringBuffer dayViewEventList = new StringBuffer();
1240:                StringBuffer dayViewTaskList = new StringBuffer();
1241:                StringBuffer overdueTaskList = new StringBuffer();
1242:                StringBuffer otherTaskList = new StringBuffer();
1243:
1244:                populateDayTags(dayViewTags, "calendar-display-dayView", today);
1245:                dayViewTags.put("iwtDesktop-fontFace1", fontFace);
1246:
1247:                if (clientURL != null) {
1248:                    dayViewTags.put("calendar-display-client-url", clientURL);
1249:                }
1250:
1251:                //------------------------------------//
1252:                // 	      DAY VIEW TASKS          //
1253:                //------------------------------------//
1254:
1255:                //Empty TaskList
1256:
1257:                if (tasks.length == 0) {
1258:                    debugLogger.finer("PSCC_CSPPC0037");
1259:                    try {
1260:                        dayViewTaskList = getTemplate("display-dayView-emptyTaskList.template");
1261:                    } catch (NullPointerException np) {
1262:                        debugLogger.log(Level.FINE, "PSCC_CSPPC0038", np);
1263:                    }
1264:
1265:                } else {
1266:                    //When dayview tasks exist
1267:                    StringBuffer dayViewTask = null;
1268:                    StringBuffer dayViewOverdueTask = null;
1269:                    Hashtable dayViewTaskTags = new Hashtable();
1270:                    Hashtable dayViewODHash = new Hashtable();
1271:                    DateFormatSymbols dfSymbols = new DateFormatSymbols(
1272:                            userLocale);
1273:                    DateTime taskDT = null;
1274:                    DateTime currDT = null;
1275:
1276:                    if ((clientURL == null) || (clientURL.equals(""))) {
1277:                        debugLogger.fine("PSCC_CSPPC0039");
1278:                    } else {
1279:                        dayViewTaskTags.put("calendar-display-client-url",
1280:                                clientURL);
1281:                        dayViewODHash.put("calendar-display-client-url",
1282:                                clientURL);
1283:                    }
1284:
1285:                    dayViewTaskTags.put("iwtDesktop-fontFace1", fontFace);
1286:                    dayViewODHash.put("iwtDesktop-fontFace1", fontFace);
1287:
1288:                    //For each task process
1289:
1290:                    for (int cnt = 0; cnt < tasks.length; cnt++) {
1291:
1292:                        if (userTimeZone != null) {
1293:                            currDT = new DateTime(userTimeZone);
1294:                        } else {
1295:                            currDT = new DateTime();
1296:                        }
1297:
1298:                        //check for null because tasks may not have a duedate
1299:                        //commenting this for bug 4808636, tasks marked "not due'
1300:                        //are now shown in as "Other Tasks"
1301:                        /*
1302:                        try {
1303:                            taskDT = tasks[cnt].getDueTime();
1304:                            if (taskDT == null) {
1305:                                taskDT = currDT;
1306:                            }
1307:                        } catch (NullPointerException ne) {
1308:                        debugWarning("CalendarProvider.getDayViewContent(): No due date", ne);
1309:                        taskDT = currDT;
1310:                        }
1311:                         */
1312:
1313:                        taskDT = tasks[cnt].getDueTime();
1314:
1315:                        //Only show incomplete and overdue tasks
1316:
1317:                        //TODO: Following line throws exception for Lotus Notes
1318:                        //servers. Catching for Bug#4804918
1319:                        try {
1320:                            overdue = isTaskOverDue(currDT, tasks[cnt]);
1321:                        } catch (OperationNotSupportedException oex) {
1322:                            if (taskDT.before(currDT)) {
1323:                                overdue = true;
1324:                            }
1325:                        }
1326:
1327:                        //if(tasks[cnt].getStatus() != SOCSTodo.STATUS_COMPLETED) {}
1328:                        //if(!tasks[cnt].getStatus().equals("NEEDS_ACTION")) {}
1329:
1330:                        if (!(isTaskComplete(tasks[cnt]))) {
1331:
1332:                            if (tasks[cnt].getDueTime() != null) {
1333:                                debugLogger.log(Level.FINER, "PSCC_CSPPC0040",
1334:                                        String.valueOf(tasks[cnt].getDueTime()
1335:                                                .get(Calendar.HOUR)));
1336:                            } else {
1337:                                debugLogger.finer("PSCC_CSPPC0041");
1338:                            }
1339:
1340:                            debugLogger.log(Level.FINER, "PSCC_CSPPC0042",
1341:                                    tasks[cnt].getStatus());
1342:
1343:                            // These are all incomplete tasks but if overdue
1344:                            // then process separately
1345:                            if (overdue) {
1346:
1347:                                tagTime(tasks[cnt].getDueTime(), dayViewODHash,
1348:                                        "calendar-display-dayView-task-due",
1349:                                        cnfgName, calStore, rqst);
1350:
1351:                                dayViewODHash
1352:                                        .put(
1353:                                                "calendar-display-dayView-task-dueMonth",
1354:                                                dfSymbols.getMonths()[taskDT
1355:                                                        .getMonth()]);
1356:                                dayViewODHash.put(
1357:                                        "calendar-display-dayView-task-dueDay",
1358:                                        Integer.toString(taskDT.getDay()));
1359:                                dayViewODHash
1360:                                        .put(
1361:                                                "calendar-display-dayView-task-dueYear",
1362:                                                Integer.toString(taskDT
1363:                                                        .getYear()));
1364:                            } else {
1365:                                //This is a pending task
1366:                                tagTime(taskDT, dayViewTaskTags,
1367:                                        "calendar-display-dayView-task-pend",
1368:                                        cnfgName, calStore, rqst);
1369:                            }
1370:                        } else {
1371:                            // Now process Completed Tasks
1372:                            // and show them as strike through
1373:                            debugLogger.log(Level.FINER, "PSCC_CSPPC0043",
1374:                                    tasks[cnt].getDescription());
1375:
1376:                            tagTime(taskDT, dayViewTaskTags,
1377:                                    "calendar-display-dayView-task-pend",
1378:                                    cnfgName, calStore, rqst);
1379:
1380:                            dayViewTaskTags
1381:                                    .put(
1382:                                            "calendar-display-dayView-task-complete-start",
1383:                                            bundleTaskCompleteStart);
1384:                            dayViewTaskTags
1385:                                    .put(
1386:                                            "calendar-display-dayView-task-complete-end",
1387:                                            bundleTaskCompleteEnd);
1388:                        }
1389:
1390:                        if (overdue) {
1391:
1392:                            try {
1393:                                tasks[cnt].getStatus();
1394:                            } catch (OperationNotSupportedException oe) {
1395:                                debugLogger.log(Level.FINE, "PSCC_CSPPC0016",
1396:                                        oe);
1397:                                tasks[cnt]
1398:                                        .setStatus(SOCSTodo.STATUS_IN_PROCESS);
1399:                            }
1400:
1401:                            if (!isTaskComplete(tasks[cnt])) {
1402:                                tagTaskSummary(tasks[cnt], dayViewODHash,
1403:                                        "calendar-display-dayView-overdueTask",
1404:                                        rqst, appHelper);
1405:
1406:                                tagDescription(escapeContent(tasks[cnt]
1407:                                        .getDescription()), dayViewODHash,
1408:                                        "calendar-display-dayView-overdueTask");
1409:
1410:                                dayViewOverdueTask = getTemplate(
1411:                                        "display-dayView-overdueTasks.template",
1412:                                        dayViewODHash);
1413:
1414:                                overdueTaskList.append(dayViewOverdueTask);
1415:                                odTasks++;
1416:                            }
1417:
1418:                        } else {
1419:                            //These tasks are not overdue
1420:                            tagTaskSummary(tasks[cnt], dayViewTaskTags,
1421:                                    "calendar-display-dayView-task", rqst,
1422:                                    appHelper);
1423:
1424:                            tagDescription(escapeContent(tasks[cnt]
1425:                                    .getDescription()), dayViewTaskTags,
1426:                                    "calendar-display-dayView-task");
1427:
1428:                            //This is an "Other Task"
1429:                            if (tasks[cnt].getDueTime() == null) {
1430:                                dayViewTask = getTemplate(
1431:                                        "display-dayView-otherTasks.template",
1432:                                        dayViewTaskTags);
1433:                                otherTaskList.append(dayViewTask);
1434:                            } else {
1435:                                dayViewTask = getTemplate(
1436:                                        "display-dayView-task.template",
1437:                                        dayViewTaskTags);
1438:                                dayViewTaskList.append(dayViewTask);
1439:                            }
1440:
1441:                            dayViewTaskTags.clear();
1442:                            if ((clientURL == null) || (clientURL.equals(""))) {
1443:                                debugLogger.fine("PSCC_CSPPC0039");
1444:                            } else {
1445:                                dayViewTaskTags.put(
1446:                                        "calendar-display-client-url",
1447:                                        clientURL);
1448:                            }
1449:                            dayViewTaskTags.put("iwtDesktop-fontFace1",
1450:                                    fontFace);
1451:                        }
1452:                    }//end for
1453:                }//end else
1454:
1455:                //-------------------------//
1456:                //	DAY VIEW EVENTS	   //
1457:                //-------------------------//
1458:
1459:                if (events.length == 0) {
1460:                    try {
1461:                        dayViewEventList = getTemplate("display-dayView-emptyEventList.template");
1462:                    } catch (NullPointerException np) {
1463:                        debugLogger.log(Level.FINER, "PSCC_CSPPC0044", np);
1464:                    }
1465:                } else {
1466:
1467:                    events = getTransformedEventList(events);
1468:
1469:                    //Events exist so for each event ..
1470:                    for (int i = 0; i < events.length; i++) {
1471:                        Hashtable dayViewEventTags = new Hashtable();
1472:                        StringBuffer dayViewEvent = new StringBuffer();
1473:                        String dayViewtemplateName = null;
1474:                        if ((clientURL == null) || (clientURL.equals(""))) {
1475:                            debugLogger.fine("PSCC_CSPPC0039");
1476:                        } else {
1477:                            dayViewEventTags.put("calendar-display-client-url",
1478:                                    clientURL);
1479:                        }
1480:                        dayViewEventTags.put("iwtDesktop-fontFace1", fontFace);
1481:
1482:                        if (events[i].isAllDay()) {
1483:                            dayViewtemplateName = "display-dayView-eventAllDay.template";
1484:                            dayViewEventTags.put(
1485:                                    "calendar-display-dayView-event-allDay",
1486:                                    bundleAllDayEvent);
1487:                        } else {
1488:                            dayViewtemplateName = "display-dayView-event.template";
1489:
1490:                            tagTime(events[i].getStart(), dayViewEventTags,
1491:                                    "calendar-display-dayView-event-start",
1492:                                    cnfgName, calStore, rqst);
1493:
1494:                            tagTime(events[i].getEnd(), dayViewEventTags,
1495:                                    "calendar-display-dayView-event-end",
1496:                                    cnfgName, calStore, rqst);
1497:                        }
1498:
1499:                        boolean conflicted = new Boolean((String) events[i]
1500:                                .getProperty("isConflict")).booleanValue();
1501:                        if (conflicted) {
1502:                            dayViewEventTags.put(
1503:                                    "calendar-display-event-conflict",
1504:                                    bundleConflict);
1505:                        }
1506:
1507:                        if ((events[i].getLocation() == null)
1508:                                || (events[i].getLocation().equals(""))) {
1509:                            dayViewEventTags.put("calendar-display-dayView-at",
1510:                                    bundleAtNoLocation);
1511:                        } else {
1512:                            dayViewEventTags.put("calendar-display-dayView-at",
1513:                                    bundleAtLocation);
1514:                        }
1515:                        tagLocation(escapeContent(events[i].getLocation()),
1516:                                dayViewEventTags,
1517:                                "calendar-display-dayView-event");
1518:
1519:                        tagEventSummary(events[i], dayViewEventTags,
1520:                                "calendar-display-dayView-event", rqst,
1521:                                appHelper);
1522:
1523:                        tagDescription(
1524:                                escapeContent(events[i].getDescription()),
1525:                                dayViewEventTags,
1526:                                "calendar-display-dayView-event");
1527:
1528:                        dayViewEvent = getTemplate(dayViewtemplateName,
1529:                                dayViewEventTags);
1530:                        dayViewEventList.append(dayViewEvent);
1531:                        dayViewEventTags.clear();
1532:                    } //end for
1533:                } //end else
1534:
1535:                //Get the overdue tasks day view
1536:                if (odTasks > 0) {
1537:                    dayViewTags.put("display-dayView-overdueTask-Header",
1538:                            bundleOverdueTasks);
1539:                    dayViewTags.put("calendar-display-dayView-overdueTaskNum",
1540:                            Integer.toString(odTasks));
1541:                    dayViewTags.put("calendar-display-dayView-overdueTaskList",
1542:                            overdueTaskList);
1543:                }
1544:
1545:                if (tasks.length > 0) {
1546:                    for (int ts = 0; ts < tasks.length; ts++) {
1547:                        if (isTaskOverDue(new DateTime(), tasks[ts])) {
1548:                            continue;
1549:                        } else if (tasks[ts].getDueTime() != null) {
1550:                            dayViewTags.put("display-dayView-dueTask-Header",
1551:                                    bundleDueTasks);
1552:                            break;
1553:                        }
1554:                    }
1555:                }
1556:                dayViewTags.put("calendar-display-dayView-taskList",
1557:                        dayViewTaskList);
1558:
1559:                if (otherTaskList.length() > 0) {
1560:                    dayViewTags.put("display-dayView-otherTask-Header",
1561:                            bundleOtherTasks);
1562:                    dayViewTags.put("calendar-display-dayView-otherTaskList",
1563:                            otherTaskList);
1564:                }
1565:
1566:                if (events.length > 0) {
1567:                    dayViewTags.put("display-dayView-dueEvent-Header",
1568:                            bundleDueEvents);
1569:                }
1570:                dayViewTags.put("calendar-display-dayView-eventList",
1571:                        dayViewEventList);
1572:
1573:                return (getTemplate("display-dayView.template", dayViewTags));
1574:            } //end getDayViewContent
1575:
1576:            /** returns the weekview of an users calendar
1577:             * @param today DateTime object  for today
1578:             * @param cfgName configurtation name for which weekview is called
1579:             * @param request HttpServletRequest
1580:             * @param events array of events for the next 7 days
1581:             * @param tasks  array of tasks for the next 7 days
1582:             * @param calStore  CalendarStore
1583:             * @param appHelper  CalendarApplicationHelper
1584:             * @return StringBuffer weekview of tasks and events in HTML
1585:             * @exception ProviderException indicates error in getting weekview
1586:             */
1587:
1588:            protected StringBuffer getWeekViewContent(DateTime beginDate,
1589:                    DateTime todaysDate, String cfgName,
1590:                    HttpServletRequest request, VEvent[] events, VTodo[] tasks,
1591:                    CalendarStore calStore,
1592:                    CalendarApplicationHelper appHelper, String clientURL,
1593:                    String tagPrefix, String templatePrefix,
1594:                    String endTemplate, boolean addCurrentDayHeader)
1595:                    throws ProviderException, Exception {
1596:
1597:                String weekViewTemplateName = null;
1598:                StringBuffer weekView = new StringBuffer();
1599:                Hashtable weekViewTags = new Hashtable();
1600:                DateFormatSymbols symbols = new DateFormatSymbols(userLocale);
1601:                int todaysTasks = 0;
1602:                int todaysEvents = 0;
1603:
1604:                // rearrange 'All Day' events to the beginning of the array and tag
1605:                // events that are in conflict
1606:                //
1607:                events = getTransformedEventList(events);
1608:
1609:                // since the week view can be included in the day view, we need to check the
1610:                // boolean and determine whether or not to include the current day header
1611:                //
1612:                if (addCurrentDayHeader) {
1613:                    StringBuffer currentDayHeader = null;
1614:                    populateHeaderTags(weekViewTags, tagPrefix, todaysDate);
1615:
1616:                    try {
1617:                        currentDayHeader = getTemplate(templatePrefix
1618:                                + "-currentDayHeader.template", weekViewTags);
1619:                    } catch (ProviderException pe) {
1620:                        currentDayHeader = null;
1621:                    }
1622:
1623:                    if (currentDayHeader != null) {
1624:                        weekViewTags.put(tagPrefix + "-currentDayHeader",
1625:                                currentDayHeader);
1626:                    }
1627:                }
1628:
1629:                weekViewTags.put("iwtDesktop-fontFace1", fontFace);
1630:                if ((clientURL == null) || (clientURL.equals(""))) {
1631:                    debugLogger.fine("PSCC_CSPPC0039");
1632:                } else {
1633:                    weekViewTags.put("calendar-display-client-url", clientURL);
1634:                }
1635:
1636:                /* Now populate for each day */
1637:
1638:                for (int i = 0; i < DAYS_OF_PREFETCHED_EVENTS; i++) {
1639:                    DateTime date = (DateTime) (beginDate.clone());
1640:                    date.add(java.util.Calendar.DATE, i);
1641:
1642:                    //Put the headers etc.
1643:                    weekViewTags.put(tagPrefix + "-dayOfWeek" + i, symbols
1644:                            .getShortWeekdays()[date
1645:                            .get(java.util.Calendar.DAY_OF_WEEK)]);
1646:
1647:                    weekViewTags.put(tagPrefix + "-day" + i, Integer
1648:                            .toString(date.getDay()));
1649:
1650:                    //-------------------------------//
1651:                    //         WEEKVIEW TASKS        //
1652:                    //-------------------------------//
1653:
1654:                    StringBuffer weekViewTaskList = new StringBuffer();
1655:
1656:                    //see if there is any task today
1657:                    int nm = 0;
1658:                    for (nm = 0; nm < tasks.length; nm++) {
1659:                        if (tasks[nm].getDueTime() != null) {
1660:                            if (matchDayMonthYear(tasks[nm].getDueTime(), date)) {
1661:                                todaysTasks++;
1662:                                continue;
1663:                            }
1664:                        }
1665:                    }
1666:
1667:                    if (todaysTasks == 0) {
1668:                        try {
1669:                            weekViewTaskList = getTemplate(templatePrefix
1670:                                    + "-emptyTaskList.template");
1671:                        } catch (NullPointerException np) {
1672:                            debugLogger.log(Level.FINER, "PSCC_CSPPC0045", np);
1673:                        }
1674:                    } else {
1675:                        //i.e. weekview tasks exist
1676:                        for (int tsk = 0; tsk < tasks.length; tsk++) {
1677:                            StringBuffer weekViewTask = new StringBuffer();
1678:                            Hashtable weekViewTaskTags = new Hashtable();
1679:                            weekViewTemplateName = templatePrefix
1680:                                    + "-task.template";
1681:                            weekViewTaskTags.put("iwtDesktop-fontFace1",
1682:                                    fontFace);
1683:                            if ((clientURL == null) || (clientURL.equals(""))) {
1684:                                debugLogger.fine("PSCC_CSPPC0039");
1685:                            } else {
1686:                                weekViewTaskTags.put(
1687:                                        "calendar-display-client-url",
1688:                                        clientURL);
1689:                            }
1690:
1691:                            DateTime tskDT = tasks[tsk].getDueTime();
1692:
1693:                            if ((tskDT != null)) {
1694:
1695:                                if (matchDayMonthYear(tskDT, date)) {
1696:
1697:                                    tagTime(tskDT, weekViewTaskTags, tagPrefix
1698:                                            + "-task-pend", cfgName, calStore,
1699:                                            request);
1700:
1701:                                    if (isTaskComplete(tasks[tsk])) {
1702:                                        weekViewTaskTags.put(tagPrefix
1703:                                                + "-task-complete-start",
1704:                                                bundleTaskCompleteStart);
1705:                                        weekViewTaskTags.put(tagPrefix
1706:                                                + "-task-complete-end",
1707:                                                bundleTaskCompleteEnd);
1708:                                    }
1709:
1710:                                    tagTaskSummary(tasks[tsk],
1711:                                            weekViewTaskTags, tagPrefix
1712:                                                    + "-task", request,
1713:                                            appHelper);
1714:
1715:                                } else
1716:                                    continue;
1717:                            } else
1718:                                continue;
1719:
1720:                            weekViewTask = getTemplate(weekViewTemplateName,
1721:                                    weekViewTaskTags);
1722:                            weekViewTaskList.append(weekViewTask);
1723:                            weekViewTaskTags.clear();
1724:                        } // end for
1725:                    }
1726:
1727:                    //-------------------------------------//
1728:                    //         WEEKVIEW EVENTS	       //
1729:                    //-------------------------------------//
1730:
1731:                    StringBuffer weekViewEventList = new StringBuffer();
1732:                    //see if there is any event today
1733:                    int num;
1734:                    for (num = 0; num < events.length; num++) {
1735:                        if (events[num].getStart() != null) {
1736:                            if (matchDayMonthYear(events[num].getStart(), date)) {
1737:                                todaysEvents++;
1738:                                continue;
1739:                            }
1740:                        }
1741:                    }
1742:
1743:                    if (todaysEvents == 0) {
1744:                        weekViewEventList = getTemplate(templatePrefix
1745:                                + "-emptyEventList.template");
1746:                    } else {
1747:
1748:                        for (int j = 0; j < events.length; j++) {
1749:                            StringBuffer weekViewEvent = new StringBuffer();
1750:                            Hashtable weekViewEventTags = new Hashtable();
1751:                            if ((clientURL == null) || (clientURL.equals(""))) {
1752:                                debugLogger.fine("PSCC_CSPPC0039");
1753:                            } else {
1754:                                weekViewEventTags.put(
1755:                                        "calendar-display-client-url",
1756:                                        clientURL);
1757:                            }
1758:                            weekViewEventTags.put("iwtDesktop-fontFace1",
1759:                                    fontFace);
1760:
1761:                            //#4728197 fix - removed extra calls to fetch
1762:                            // events and tasks for each day. Now get them for a wk and
1763:                            // test if they are for the specified day or not.
1764:
1765:                            if ((events[j].isAllDay())
1766:                                    && (matchDayMonthYear(events[j].getStart(),
1767:                                            date))) {
1768:
1769:                                weekViewTemplateName = templatePrefix
1770:                                        + "-eventAllDay.template";
1771:                                weekViewEventTags.put(tagPrefix
1772:                                        + "-event-allDay", bundleAllDayEvent);
1773:
1774:                                tagEventSummary(events[j], weekViewEventTags,
1775:                                        tagPrefix + "-event", request,
1776:                                        appHelper);
1777:
1778:                                weekViewEvent = getTemplate(
1779:                                        weekViewTemplateName, weekViewEventTags);
1780:                                weekViewEventList.append(weekViewEvent);
1781:
1782:                            } else if ((!(events[j].isAllDay()))
1783:                                    && (matchDayMonthYear(events[j].getStart(),
1784:                                            date))) {
1785:
1786:                                boolean conflicted = new Boolean(
1787:                                        (String) events[j]
1788:                                                .getProperty("isConflict"))
1789:                                        .booleanValue();
1790:                                if (conflicted) {
1791:                                    weekViewEventTags.put(
1792:                                            "calendar-display-event-conflict",
1793:                                            bundleConflict);
1794:                                }
1795:
1796:                                weekViewTemplateName = templatePrefix
1797:                                        + "-event.template";
1798:                                tagTime(events[j].getStart(),
1799:                                        weekViewEventTags, tagPrefix
1800:                                                + "-event-start", cfgName,
1801:                                        calStore, request);
1802:
1803:                                tagTime(events[j].getEnd(), weekViewEventTags,
1804:                                        tagPrefix + "-event-end", cfgName,
1805:                                        calStore, request);
1806:
1807:                                tagEventSummary(events[j], weekViewEventTags,
1808:                                        tagPrefix + "-event", request,
1809:                                        appHelper);
1810:
1811:                                weekViewEvent = getTemplate(
1812:                                        weekViewTemplateName, weekViewEventTags);
1813:                                weekViewEventList.append(weekViewEvent);
1814:                            }
1815:                            weekViewEventTags.clear();
1816:                        }
1817:                    }
1818:                    weekViewTags.put(tagPrefix + "-eventList" + i,
1819:                            weekViewEventList);
1820:                    weekViewTags.put(tagPrefix + "-taskList" + i,
1821:                            weekViewTaskList);
1822:                }
1823:
1824:                if (endTemplate != null) {
1825:                    weekView = getTemplate(endTemplate, weekViewTags);
1826:                } else {
1827:                    weekView = getTemplate(templatePrefix + ".template",
1828:                            weekViewTags);
1829:                }
1830:                return (weekView);
1831:            } //end getWeekViewContent
1832:
1833:            /** @return  StringBuffer containing summary information
1834:             * @param int total number of events for today
1835:             * @param int total number of tasks for today
1836:             * @throws ProviderException
1837:             */
1838:
1839:            private StringBuffer getSummaryContent(int eventCount, int taskCount)
1840:                    throws ProviderException {
1841:
1842:                StringBuffer summary = null;
1843:                Hashtable summaryTags = new Hashtable();
1844:
1845:                summaryTags.put("iwtDesktop-fontFace1", fontFace);
1846:                summaryTags.put("calendar-display-summary-events", Integer
1847:                        .toString(eventCount));
1848:                summaryTags.put("calendar-display-summary-tasks", Integer
1849:                        .toString(taskCount));
1850:                summary = getTemplate("display-summary.template", summaryTags);
1851:
1852:                return (summary);
1853:            }
1854:
1855:            private void tagTime(DateTime time, Hashtable tags, String prefix,
1856:                    String config, CalendarStore calStore,
1857:                    HttpServletRequest request) {
1858:
1859:                DateFormatSymbols symbols = new DateFormatSymbols(userLocale);
1860:                int usrTimeFmt = 12;
1861:                String usrTimeFmtStr = null;
1862:                String usrTimeFmtStr1 = null;
1863:
1864:                CalendarSession session = null;
1865:
1866:                try {
1867:                    session = calStore.getSession();
1868:                } catch (Exception e) {
1869:                    debugLogger.log(Level.INFO, "PSCC_CSPPC0016", e);
1870:                }
1871:
1872:                if (time == null) {
1873:                    tags.put(prefix + "Hour", "");
1874:                    tags.put(prefix + "Minute", "");
1875:                    tags.put(prefix + "AmPm", "");
1876:                } else {
1877:                    int hour = time.get(java.util.Calendar.HOUR);
1878:                    int hourOfDay = time.get(java.util.Calendar.HOUR_OF_DAY);
1879:
1880:                    tags.put(prefix + "Hour0", Integer.toString(hour));
1881:                    tags
1882:                            .put(prefix + "HourOfDay0", Integer
1883:                                    .toString(hourOfDay));
1884:
1885:                    tags.put(prefix + "Hour1", Integer.toString(hour == 0 ? 12
1886:                            : hour));
1887:                    tags.put(prefix + "HourOfDay1", Integer
1888:                            .toString(hourOfDay == 0 ? 24 : hourOfDay));
1889:
1890:                    usrTimeFmtStr = session.getProperty("ceClock");
1891:
1892:                    if (usrTimeFmtStr == null) {
1893:                        // Newer Calendars use the the property "cal.clock" not "ceClock"
1894:                        usrTimeFmtStr = session.getProperty("cal.clock");
1895:                    }
1896:
1897:                    if (usrTimeFmtStr != null) {
1898:                        usrTimeFmtStr = usrTimeFmtStr.trim();
1899:                    }
1900:
1901:                    //Set the default to 12 hr clock
1902:                    if (usrTimeFmtStr == null) {
1903:                        usrTimeFmtStr = "12";
1904:                    }
1905:
1906:                    //convert to int
1907:                    usrTimeFmt = Integer.parseInt(usrTimeFmtStr);
1908:                    debugLogger.log(Level.FINER, "PSCC_CSPPC0046", Integer
1909:                            .toString(usrTimeFmt));
1910:
1911:                    // Now add a new tag Hour2 based on user pref of
1912:                    // 12 or 24 hrs format
1913:
1914:                    try {
1915:                        if (usrTimeFmt == 12) {
1916:                            debugLogger.log(Level.FINER, "PSCC_CSPPC0047",
1917:                                    Integer.toString(hour));
1918:                            tags.put(prefix + "Hour2", Integer
1919:                                    .toString(hour == 0 ? 12 : hour));
1920:                            tags.put(prefix + "AmPm",
1921:                                    symbols.getAmPmStrings()[time
1922:                                            .get(java.util.Calendar.AM_PM)]
1923:                                            .toLowerCase());
1924:                        } else if (usrTimeFmt == 24) {
1925:                            debugLogger.log(Level.FINER, "PSCC_CSPPC0048",
1926:                                    Integer.toString(hourOfDay));
1927:                            tags.put(prefix + "Hour2", Integer
1928:                                    .toString(hourOfDay));
1929:                            tags.put(prefix + "AmPm", " Hrs");
1930:                        }
1931:                    } catch (Exception xn) {
1932:                        debugLogger.log(Level.INFO, "PSCC_CSPPC0016", xn);
1933:                    }
1934:
1935:                    int timeMinutes = time.getMinutes();
1936:                    StringBuffer minute = new StringBuffer();
1937:
1938:                    if (timeMinutes < 10) {
1939:                        minute.append("0");
1940:                    }
1941:
1942:                    minute.append(Integer.toString(timeMinutes));
1943:                    tags.put(prefix + "Minute", minute.toString());
1944:                } //end else
1945:            } //end tagTime
1946:
1947:            private void tagLocation(String location, Hashtable tags,
1948:                    String prefix) {
1949:                if (location == null) {
1950:                    location = "";
1951:                }
1952:                tags.put(prefix + "-location", location);
1953:            }
1954:
1955:            private void tagHref(String href, Hashtable tags, String prefix) {
1956:                if (href == null) {
1957:                    href = "";
1958:                }
1959:                tags.put(prefix + "-href", href);
1960:            }
1961:
1962:            /*
1963:             * Responsible for constructing the Summary tag for a VEvent. If the
1964:             * CalendarApplicationHelper.getEventURL() returns a non-null value then the
1965:             * Event is displayed as a link per the markup in the url.template
1966:             *
1967:             * @param event     Event
1968:             * @param tags      Tagtable
1969:             * @param prefix    tag prefix (i.e. day, week, ....)
1970:             * @param request   HttpServletRequest
1971:             * @param appHelper CalendarApplicationHelper
1972:             */
1973:            private void tagEventSummary(VEvent event, Hashtable tags,
1974:                    String prefix, HttpServletRequest request,
1975:                    CalendarApplicationHelper appHelper) {
1976:
1977:                String url = null;
1978:                String summary = null;
1979:
1980:                try {
1981:                    if (appHelper != null) {
1982:                        url = appHelper.getEventURL(this , request, event);
1983:                    }
1984:                    summary = event.getSummary();
1985:                } catch (Exception e) {
1986:                    debugLogger.log(Level.INFO, "PSCC_CSPPC0016", e);
1987:                }
1988:
1989:                tagSummary(summary, tags, prefix, url);
1990:            }
1991:
1992:            /*
1993:             * Responsible for constructing the Summary tag for a VTodo. If the
1994:             * CalendarApplicationHelper.getTaskURL() returns a non-null value then the
1995:             * Event is displayed as a link per the markup in the url.template
1996:             *
1997:             * @param event     Task
1998:             * @param tags      Tagtable
1999:             * @param prefix    tag prefix (i.e. day, week, ....)
2000:             * @param request   HttpServletRequest
2001:             * @param appHelper CalendarApplicationHelper
2002:             */
2003:            private void tagTaskSummary(VTodo task, Hashtable tags,
2004:                    String prefix, HttpServletRequest request,
2005:                    CalendarApplicationHelper appHelper) {
2006:
2007:                String url = null;
2008:                String summary = null;
2009:
2010:                try {
2011:                    if (appHelper != null) {
2012:                        url = appHelper.getTaskURL(this , request, task);
2013:                    }
2014:                    summary = task.getSummary();
2015:                } catch (Exception e) {
2016:                    debugLogger.log(Level.INFO, "PSCC_CSPPC0016", e);
2017:                }
2018:
2019:                tagSummary(summary, tags, prefix, url);
2020:            }
2021:
2022:            /*
2023:             * Responsible for constructing the Summary tag for an Event/Task. If the
2024:             * <code>link</code> is not null and the display profile property 'disableTaskEventURL'
2025:             * is false, then a uri is constructed with the help of the markup in the url.template
2026:             *
2027:             * There will always be some text so the user can "click" on it.  Using the bundle
2028:             * 'noSummary' property
2029:             *
2030:             * @param summary name value
2031:             * @param tags    Tagtable
2032:             * @param prefix  tag prefix (i.e. day, week, ....)
2033:             * @param link    link value
2034:             */
2035:            private void tagSummary(String summary, Hashtable tags,
2036:                    String prefix, String link) {
2037:
2038:                if (summary == null) {
2039:                    summary = bundleNoSummary;
2040:                }
2041:
2042:                summary = escapeContent(summary);
2043:
2044:                // build uri (if applicable)
2045:                try {
2046:                    if ((link != null)
2047:                            && (!getBestBooleanProperty("disableTaskEventURLs",
2048:                                    false, pflist))) {
2049:                        Hashtable etags = new Hashtable();
2050:                        etags.put("link", link);
2051:                        etags.put("name", summary);
2052:                        summary = getTemplate("url.template", etags).toString();
2053:                    }
2054:                } catch (ProviderException pe) {
2055:                    debugLogger.log(Level.FINER, "PSCC_CSPPC0049", pe);
2056:                }
2057:
2058:                tags.put(prefix + "-summary", summary);
2059:            }
2060:
2061:            private void tagDescription(String description, Hashtable tags,
2062:                    String prefix) {
2063:                if (description == null) {
2064:                    description = "";
2065:                } else {
2066:                    tags.put("calendar-display-dayView-description-seperator",
2067:                            bundleDescriptionSeperator);
2068:                }
2069:                tags.put(prefix + "-description", description);
2070:            }
2071:
2072:            /**
2073:             *  This method is reponsible for moving all the 'All Day' events to
2074:             *  the beginning of the VEvent array and for identifying events that are
2075:             *  in conflict.  All events get the property 'isConflict' set.
2076:             *
2077:             * @param events[]     An array of VEvent objects
2078:             * @return a new VEvent array that has been updated and/or reordered
2079:             * @throws Exception
2080:             */
2081:            protected VEvent[] getTransformedEventList(VEvent events[])
2082:                    throws Exception {
2083:
2084:                if (events == null) {
2085:                    return null;
2086:                }
2087:
2088:                ArrayList eventList = new ArrayList();
2089:                int allDayIdx = 0;
2090:
2091:                for (int i = 0; i < events.length; i++) {
2092:                    DateTime eventStart = events[i].getStart();
2093:                    DateTime eventEnd = events[i].getEnd();
2094:                    String eventID = events[i].getID();
2095:
2096:                    // seed the event "isConflict" property with false if it does not exist
2097:                    if (!events[i].hasProperty("isConflict")) {
2098:                        events[i].setProperty("isConflict", "false");
2099:                    }
2100:
2101:                    // check for conflicting events
2102:                    for (int k = 0; k < events.length; k++) {
2103:                        DateTime conflictEventStart = events[k].getStart();
2104:                        String conflictEventID = events[k].getID();
2105:
2106:                        if ((!conflictEventID.equals(eventID))
2107:                                && (eventEnd != null)
2108:                                && (conflictEventStart != null)) {
2109:
2110:                            // if the event has already been marked in conflict, then skip
2111:                            if ((events[k].hasProperty("isConflict"))
2112:                                    && (events[k].getProperty("isConflict")
2113:                                            .equals("true"))) {
2114:                                continue;
2115:                            }
2116:
2117:                            // check for any events that start at the same time as the current event or
2118:                            // check for any events that start after the same time as the current event
2119:                            // and also start before the end time of the current event
2120:                            //
2121:                            if ((conflictEventStart.equals(eventStart))
2122:                                    || ((conflictEventStart.after(eventStart)) && (conflictEventStart
2123:                                            .before(eventEnd)))) {
2124:                                events[k].setProperty("isConflict", "true");
2125:                                events[i].setProperty("isConflict", "true");
2126:                            } else if (conflictEventStart.after(eventEnd)) {
2127:                                break;
2128:                            }
2129:                        }
2130:                    }
2131:
2132:                    // identify all day events and place accordingly
2133:                    if (events[i].isAllDay()) {
2134:                        eventList.add(allDayIdx, (VEvent) events[i]);
2135:                        allDayIdx++;
2136:                    } else {
2137:                        eventList.add((VEvent) events[i]);
2138:                    }
2139:
2140:                }
2141:
2142:                return (VEvent[]) eventList.toArray(new VEvent[0]);
2143:            }
2144:
2145:            /**
2146:             *  Retrieves the CalendarApplicationHelper start URL
2147:             *
2148:             * @param calApplicationHelper  The CalendarApplicationHelper object
2149:             * @param request               The HttpServletRequest object
2150:             * @return string representing the Application start URL
2151:             */
2152:            protected String getApplicationStartURL(
2153:                    CalendarApplicationHelper calApplicationHelper,
2154:                    HttpServletRequest request) {
2155:                String applicationURLString = null;
2156:
2157:                if (calApplicationHelper != null) {
2158:                    applicationURLString = calApplicationHelper.getStartURL(
2159:                            this , request);
2160:                }
2161:
2162:                if (applicationURLString == null) {
2163:                    debugLogger.fine("PSCC_CSPPC0050");
2164:                }
2165:
2166:                return applicationURLString;
2167:            }
2168:
2169:            /**
2170:             * Helper method to determine if the task is scheduled for today.  Tasks are
2171:             * scheduled for today if:
2172:             *
2173:             * - Task is Due Today OR Task does not have a Due Time
2174:             *
2175:             * @param task   Task to evaluate
2176:             * @param today  DateTime representing Today
2177:             * @return boolean true if the Task is scheduled for Today and is not Overdue
2178:             * @throws OperationNotSupportedException, CalendarComponentException
2179:             */
2180:            protected boolean isTodayTask(VTodo task, DateTime today)
2181:                    throws OperationNotSupportedException,
2182:                    CalendarComponentException {
2183:
2184:                boolean isToday = false;
2185:
2186:                // check to see if task is due today or does not have a due time
2187:                if ((task.getDueTime() == null)
2188:                        || (matchDayMonthYear(task.getDueTime(), today))) {
2189:                    isToday = true;
2190:                }
2191:
2192:                return isToday;
2193:            }
2194:
2195:            /**
2196:             * Helper method to determine if the Day, Month, and Year match for
2197:             * two DateTime objects.
2198:             *
2199:             * @param date1  First DateTime
2200:             * @param date2  Second DateTime to match
2201:             * @return boolean true if the two DateTime Day, Month, and Year values match
2202:             */
2203:            protected boolean matchDayMonthYear(DateTime date1, DateTime date2) {
2204:
2205:                boolean match = false;
2206:
2207:                if ((date1.getDay() == date2.getDay())
2208:                        && (date1.getMonth() == date2.getMonth())
2209:                        && (date1.getYear() == date2.getYear())) {
2210:                    match = true;
2211:                }
2212:
2213:                return match;
2214:            }
2215:
2216:            /*
2217:             * Set the Calendars available to the User in the Edit View.
2218:             *
2219:             * Retrieve all the Calendars available to the User, if there is an exception
2220:             * during retreival, then we assume the messaging server does not support multiple
2221:             * calendars and do not populate the display profile 'calendarSelectOptions'
2222:             * collection.
2223:             *
2224:             * Otherwise, retrieve the calendars and populate the display profile
2225:             * 'calendarSelectOptions' collection, such that it will be picked up by the
2226:             * prefs editing logic.
2227:             *
2228:             * It is up to the Channel to define the 'calendar' as a select in the
2229:             * 'dpEditAttributes'.
2230:             *
2231:             * @param ssoAdapter SSOAdapter for the Channel
2232:             * @throws ProviderException
2233:             */
2234:            protected void setCalendarSelectOptions(SSOAdapter ssoAdapter)
2235:                    throws ProviderException {
2236:                CalendarStore calStore = (CalendarStore) ssoAdapter
2237:                        .getConnection();
2238:
2239:                if (calStore == null) {
2240:                    return;
2241:                }
2242:
2243:                String[] subscribedCalendars = null;
2244:                HashMap calsCollection = new HashMap();
2245:
2246:                try {
2247:                    subscribedCalendars = calStore.getSubscribedCalenders();
2248:                } catch (CalendarStoreException cse) {
2249:                    if (debugLogger.isLoggable(Level.FINER)) {
2250:                        LogRecord logRecord = new LogRecord(Level.FINER,
2251:                                "PSCC_CSPPC0051");
2252:                        logRecord.setLoggerName(debugLogger.getName());
2253:                        logRecord.setParameters(new Object[] { getName() });
2254:                        logRecord.setThrown(cse);
2255:                        debugLogger.log(logRecord);
2256:                    }
2257:                } catch (OperationNotSupportedException onse) {
2258:                    if (debugLogger.isLoggable(Level.FINER)) {
2259:                        LogRecord logRecord = new LogRecord(Level.FINER,
2260:                                "PSCC_CSPPC0051");
2261:                        logRecord.setLoggerName(debugLogger.getName());
2262:                        logRecord.setParameters(new Object[] { getName() });
2263:                        logRecord.setThrown(onse);
2264:                        debugLogger.log(logRecord);
2265:                    }
2266:                }
2267:
2268:                if (subscribedCalendars != null) {
2269:                    for (int k = 0; k < subscribedCalendars.length; k++) {
2270:                        String calid = subscribedCalendars[k];
2271:                        calsCollection.put(calid, calid);
2272:                    }
2273:                }
2274:
2275:                // populate display profile collection, if applicable
2276:                if (!calsCollection.isEmpty()) {
2277:                    setMapProperty("calendarSelectOptions", calsCollection);
2278:                }
2279:
2280:                // connection management.  check ssoadapter for per request connection
2281:                // management property.  if true, then close connection to store.
2282:                //
2283:                Properties props = ssoAdapter.getProperties();
2284:
2285:                if (props != null) {
2286:                    String eprc = props.getProperty(
2287:                            "enablePerRequestConnection", "false");
2288:
2289:                    if ((eprc != null) && (eprc.equals("true"))) {
2290:                        ssoAdapter.closeConnection();
2291:                    }
2292:                }
2293:
2294:            }
2295:
2296:            /*
2297:             * Retreive the Month Start Date
2298:             *
2299:             * The Month start date is calculated by setting <code>today</code>
2300:             * to day 1 of the month, i.e. setDay(1), and the assumption that the week
2301:             * start day is Calendar.SUNDAY
2302:             *
2303:             * @param today DateTime object representing today's date
2304:             * @return a cloned DateTime object that represents the Month start date
2305:             */
2306:            public DateTime getMonthStart(DateTime today) {
2307:                DateTime start = (DateTime) (today.clone());
2308:                start.setDay(1);
2309:
2310:                int subtract = ((start.get(Calendar.DAY_OF_WEEK) - Calendar.SUNDAY) * -1);
2311:                start.add(Calendar.DAY_OF_MONTH, subtract);
2312:
2313:                return start;
2314:            }
2315:
2316:            /*
2317:             * Retreive the Month End Date
2318:             *
2319:             * The Month end date is calculated by setting <code>today</code>
2320:             * to the maximum number of days in the month, i.e. getMaximum(Calendar.DAY_OF_MONTH),
2321:             * and the assumption that the week end day is Calendar.SATURDAY
2322:             *
2323:             * @param today DateTime object representing today's date
2324:             * @return a cloned DateTime object that represents the Month end date
2325:             */
2326:            public DateTime getMonthEnd(DateTime today) {
2327:                DateTime end = (DateTime) (today.clone());
2328:                end.setDay(end.getMaximum(Calendar.DAY_OF_MONTH));
2329:
2330:                int add = Calendar.SATURDAY - end.get(Calendar.DAY_OF_WEEK);
2331:                end.add(Calendar.DAY_OF_MONTH, add);
2332:
2333:                return end;
2334:            }
2335:
2336:            /*
2337:             * Populate header tags
2338:             *
2339:             * This method is responsible for populating the Hashtable, tags, with the following
2340:             * tags:
2341:             *
2342:             * tagPrefix + "-currentDayOfWeek"
2343:             * tagPrefix + "-currentMonth"
2344:             * tagPrefix + "-currentDay"
2345:             * tagPrefix + "-currentYear"
2346:             *
2347:             * @param tags       Hashtable that the tags will be put in
2348:             * @param tagPrefix  The tag prefix, i.e. calendar-display-monthView
2349:             * @param date       The date to retrieve information from
2350:             */
2351:            public void populateHeaderTags(Hashtable tags, String tagPrefix,
2352:                    DateTime date) {
2353:
2354:                if ((tags == null) || (date == null)) {
2355:                    return;
2356:                }
2357:
2358:                try {
2359:                    DateFormatSymbols symbols = new DateFormatSymbols(
2360:                            userLocale);
2361:
2362:                    tags.put(tagPrefix + "-currentDayOfWeek", symbols
2363:                            .getWeekdays()[date
2364:                            .get(java.util.Calendar.DAY_OF_WEEK)]);
2365:                    tags.put(tagPrefix + "-currentMonth",
2366:                            symbols.getMonths()[date.getMonth()]);
2367:                    tags.put(tagPrefix + "-currentDay", Integer.toString(date
2368:                            .getDay()));
2369:                    tags.put(tagPrefix + "-currentYear", Integer.toString(date
2370:                            .getYear()));
2371:                } catch (Exception e) {
2372:                    if (debugLogger.isLoggable(Level.INFO)) {
2373:                        LogRecord logRecord = new LogRecord(Level.INFO,
2374:                                "PSCC_CSPPC0052");
2375:                        logRecord.setLoggerName(debugLogger.getName());
2376:                        logRecord.setParameters(new Object[] { getName() });
2377:                        logRecord.setThrown(e);
2378:                        debugLogger.log(logRecord);
2379:                    }
2380:                }
2381:
2382:            }
2383:
2384:            /*
2385:             * Populate day tags
2386:             *
2387:             * This method is responsible for populating the Hashtable, tags, with the following
2388:             * tags:
2389:             *
2390:             * tagPrefix + "-dayOfWeek"
2391:             * tagPrefix + "-month"
2392:             * tagPrefix + "-day"
2393:             * tagPrefix + "-year"
2394:             *
2395:             * @param tags       Hashtable that the tags will be put in
2396:             * @param tagPrefix  The tag prefix, i.e. calendar-display-monthView
2397:             * @param date       The date to retrieve information from
2398:             */
2399:            public void populateDayTags(Hashtable tags, String tagPrefix,
2400:                    DateTime date) {
2401:
2402:                if ((tags == null) || (date == null)) {
2403:                    return;
2404:                }
2405:
2406:                try {
2407:                    DateFormatSymbols symbols = new DateFormatSymbols(
2408:                            userLocale);
2409:
2410:                    tags.put(tagPrefix + "-dayOfWeek",
2411:                            symbols.getWeekdays()[date
2412:                                    .get(java.util.Calendar.DAY_OF_WEEK)]);
2413:
2414:                    tags.put(tagPrefix + "-month", symbols.getMonths()[date
2415:                            .getMonth()]);
2416:                    tags.put(tagPrefix + "-day", Integer
2417:                            .toString(date.getDay()));
2418:                    tags.put(tagPrefix + "-year", Integer.toString(date
2419:                            .getYear()));
2420:                } catch (Exception e) {
2421:                    if (debugLogger.isLoggable(Level.INFO)) {
2422:                        LogRecord logRecord = new LogRecord(Level.INFO,
2423:                                "PSCC_CSPPC0052");
2424:                        logRecord.setLoggerName(debugLogger.getName());
2425:                        logRecord.setParameters(new Object[] { getName() });
2426:                        logRecord.setThrown(e);
2427:                        debugLogger.log(logRecord);
2428:                    }
2429:                }
2430:
2431:            }
2432:
2433:            /*
2434:             * Populate day of week tags
2435:             *
2436:             * This method is responsible for populating the Hashtable, tags, with the following
2437:             * tags:
2438:             *
2439:             * tagPrefix + "-dayOfWeek" + [0..6]
2440:             *
2441:             * @param tags       Hashtable that the tags will be put in
2442:             * @param tagPrefix  The tag prefix, i.e. calendar-display-monthView
2443:             * @param date       The date to retrieve information from
2444:             */
2445:            public void populateDayOfWeekTags(Hashtable tags, String tagPrefix,
2446:                    DateTime date) {
2447:
2448:                if ((tags == null) || (date == null)) {
2449:                    return;
2450:                }
2451:
2452:                try {
2453:                    DateFormatSymbols symbols = new DateFormatSymbols(
2454:                            userLocale);
2455:
2456:                    for (int i = 0; i < 7; i++) {
2457:                        date.add(java.util.Calendar.DATE, 1);
2458:
2459:                        tags.put(tagPrefix + "-dayOfWeek" + i, symbols
2460:                                .getWeekdays()[date
2461:                                .get(java.util.Calendar.DAY_OF_WEEK)]);
2462:                    }
2463:                } catch (Exception e) {
2464:                    if (debugLogger.isLoggable(Level.INFO)) {
2465:                        LogRecord logRecord = new LogRecord(Level.INFO,
2466:                                "PSCC_CSPPC0052");
2467:                        logRecord.setLoggerName(debugLogger.getName());
2468:                        logRecord.setParameters(new Object[] { getName() });
2469:                        logRecord.setThrown(e);
2470:                        debugLogger.log(logRecord);
2471:                    }
2472:                }
2473:
2474:            }
2475:
2476:            /**
2477:             * Does escaping of markup in a client aware fashion, example of markups
2478:             * include HTML, XML, WML, cHTML, .....
2479:             *
2480:             *@param  inContent  is the string input
2481:             *@return            String containing the escaped String
2482:             */
2483:            private String escapeContent(String inContent) {
2484:
2485:                if (inContent == null) {
2486:                    return null;
2487:                }
2488:
2489:                try {
2490:                    return getProviderContext().escape(inContent);
2491:                } catch (ProviderContextException e) {
2492:                    if (debugLogger.isLoggable(Level.INFO)) {
2493:                        LogRecord logRecord = new LogRecord(Level.INFO,
2494:                                "PSCC_CSPPC0052");
2495:                        logRecord.setLoggerName(debugLogger.getName());
2496:                        logRecord.setParameters(new Object[] { getName() });
2497:                        logRecord.setThrown(e);
2498:                        debugLogger.log(logRecord);
2499:                    }
2500:                    return inContent;
2501:                }
2502:
2503:            }
2504:
2505:            /**
2506:             * Returns the DP property by attempting to retrieve client and localized properties first
2507:             * then it searches for non conditional definitions
2508:             *
2509:             * @param pflist                 List containg the client and locale filters
2510:             * @param key                    Display Preofile key
2511:             * @return                       Returns the best value for the DP key
2512:             */
2513:            public String getBestStringProperty(String key, String def,
2514:                    List pflist) {
2515:                ProviderContext pc = getProviderContext();
2516:                try {
2517:                    if (key != null) {
2518:                        if (pc
2519:                                .existsStringProperty(this .getName(), key,
2520:                                        pflist)) {
2521:                            return pc.getStringProperty(this .getName(), key,
2522:                                    pflist);
2523:                        } else if (pc.existsStringProperty(this .getName(), key)) {
2524:                            return pc.getStringProperty(this .getName(), key);
2525:                        }
2526:                    }
2527:                    return def;
2528:                } catch (ProviderContextException pce) {
2529:                    debugLogger.log(Level.FINE, "PSCC_CSPPC0053", key);
2530:                    return def;
2531:                }
2532:            }
2533:
2534:            public String getBestStringProperty(String key, List pflist) {
2535:                return getBestStringProperty(key, "", pflist);
2536:            }
2537:
2538:            /**
2539:             * Returns the DP property by attempting to retrieve client and localized properties first
2540:             * then it searches for non conditional definitions
2541:             *
2542:             * @param pflist                 List containg the client and locale filters
2543:             * @param key                    Display Preofile key
2544:             * @return                       Returns the best value for the DP key
2545:             */
2546:            public int getBestIntegerProperty(String key, int def, List pflist) {
2547:                ProviderContext pc = getProviderContext();
2548:                try {
2549:                    if (key != null) {
2550:                        if (pc.existsIntegerProperty(this .getName(), key,
2551:                                pflist)) {
2552:                            return pc.getIntegerProperty(this .getName(), key,
2553:                                    pflist);
2554:                        } else if (pc
2555:                                .existsIntegerProperty(this .getName(), key)) {
2556:                            return pc.getIntegerProperty(this .getName(), key);
2557:                        }
2558:                    }
2559:                    return def;
2560:                } catch (ProviderContextException pce) {
2561:                    debugLogger.log(Level.FINE, "PSCC_CSPPC0053", key);
2562:                    return def;
2563:                }
2564:            }
2565:
2566:            public int getBestIntegerProperty(String key, List pflist) {
2567:                return getBestIntegerProperty(key, -1, pflist);
2568:            }
2569:
2570:            /**
2571:             * Returns the DP property by attempting to retrieve client and localized properties first
2572:             * then it searches for non conditional definitions
2573:             *
2574:             * @param pflist                 List containg the client and locale filters
2575:             * @param key                    Display Preofile key
2576:             * @return                       Returns the best value for the DP key
2577:             */
2578:            public Map getBestCollectionProperty(String key, Map def,
2579:                    List pflist) {
2580:                ProviderContext pc = getProviderContext();
2581:                try {
2582:                    if (key != null) {
2583:                        if (pc.existsCollectionProperty(this .getName(), key,
2584:                                pflist)) {
2585:                            return pc.getCollectionProperty(this .getName(),
2586:                                    key, pflist);
2587:                        } else if (pc.existsCollectionProperty(this .getName(),
2588:                                key)) {
2589:                            return pc
2590:                                    .getCollectionProperty(this .getName(), key);
2591:                        }
2592:                    }
2593:                    return def;
2594:                } catch (ProviderContextException pce) {
2595:                    debugLogger.log(Level.FINE, "PSCC_CSPPC0053", key);
2596:                    return def;
2597:                }
2598:            }
2599:
2600:            public Map getBestCollectionProperty(String key, List pflist) {
2601:                return getBestCollectionProperty(key, null, pflist);
2602:            }
2603:
2604:            /**
2605:             * Returns the DP property by attempting to retrieve client and localized properties first
2606:             * then it searches for non conditional definitions
2607:             *
2608:             * @param pflist                 List containg the client and locale filters
2609:             * @param key                    Display Preofile key
2610:             * @return                       Returns the best value for the DP key
2611:             */
2612:            public boolean getBestBooleanProperty(String key, boolean def,
2613:                    List pflist) {
2614:                ProviderContext pc = getProviderContext();
2615:                try {
2616:                    if (key != null) {
2617:                        if (pc.existsBooleanProperty(this .getName(), key,
2618:                                pflist)) {
2619:                            return pc.getBooleanProperty(this .getName(), key,
2620:                                    pflist);
2621:                        } else if (pc
2622:                                .existsBooleanProperty(this .getName(), key)) {
2623:                            return pc.getBooleanProperty(this .getName(), key);
2624:                        }
2625:                    }
2626:                    return def;
2627:                } catch (ProviderContextException pce) {
2628:                    debugLogger.log(Level.FINE, "PSCC_CSPPC0053", key);
2629:                    return def;
2630:                }
2631:            }
2632:
2633:            public boolean getBestBooleanProperty(String key, List pflist) {
2634:                return getBestBooleanProperty(key, false, pflist);
2635:            }
2636:
2637:        } //end class
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.