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


001:        package com.sun.portal.config;
002:
003:        import com.sun.comclient.calendar.*;
004:        import com.sun.comclient.calendar.socs.SOCSTodo;
005:        import java.util.*;
006:
007:        /*
008:         * This class is responsible for populating the JES Calendar Server
009:         * with sample data for the JES Portal Server adventuresportscafe.com
010:         * sample.
011:         *
012:         * It will populate data for the users:  chris, ed, and mary
013:         * 
014:         * It uses <code>URLName</code> for server and user information. 
015:         * 
016:         */
017:        public class PopulateCalendar {
018:
019:            protected String serviceClass = "com.sun.comclient.calendar.socs.SOCSCalendarStore";
020:            protected String host = null;
021:            protected int port = 80;
022:            protected String user = null;
023:            protected String password = null;
024:            protected String protocol = null;
025:            protected String domain = null;
026:            protected boolean debug = false;
027:            protected final static String PASSWORD = "ascsample";
028:
029:            // known users
030:            protected final static String CHRIS = "chris";
031:            protected final static String ED = "ed";
032:            protected final static String MARY = "mary";
033:
034:            /*
035:             * Constructor
036:             * 
037:             * @param protocol Calendar server protocol 
038:             * @param host     Calendar server host 
039:             * @param port     Calendar server port 
040:             * @param domain   Calendar server hosted domain
041:             */
042:            public PopulateCalendar(String protocol, String host, String port,
043:                    String domain, boolean debug) {
044:
045:                this .protocol = protocol;
046:                this .host = host;
047:                this .domain = domain;
048:                this .debug = debug;
049:
050:                try {
051:                    this .port = Integer.parseInt(port);
052:                } catch (Exception e) {
053:                    e.printStackTrace();
054:                }
055:
056:            }
057:
058:            /*
059:             * Retreive CalendarStore
060:             *
061:             * @param user     Calendar server user
062:             * @param password Calendar server password
063:             */
064:            public CalendarStore getStore(String user, String password)
065:                    throws Exception {
066:
067:                CalendarSession calSession = null;
068:                CalendarStore calStore = null;
069:                Properties props = new Properties();
070:                String uid = user;
071:
072:                if (domain != null) {
073:                    uid = user + "@" + domain;
074:                }
075:
076:                props.put("cal.host", host);
077:                props.put("cal.port", Integer.toString(port));
078:                props.put("cal.user", uid);
079:                props.put("cal.password", password);
080:                props.put("cal.protocol", protocol);
081:
082:                if (debug) {
083:                    System.out.println("Session Properties=" + props.toString()
084:                            + "\n");
085:                }
086:
087:                calSession = calSession.getInstance(props);
088:                calSession.setTimeZone(TimeZone.getDefault());
089:                calStore = calSession.getStore(serviceClass);
090:                calStore.connect(host, port);
091:
092:                if (debug) {
093:                    System.out.println("Connected to Calendar Server");
094:                }
095:
096:                return calStore;
097:            }
098:
099:            /*
100:             * Populate data.
101:             * 
102:             * @param user     Calendar server user
103:             * @param password Calendar server password
104:             */
105:            public void generate(String user, String password) {
106:                CalendarStore store;
107:                ICalendar calendar;
108:
109:                if (debug) {
110:                    System.out.println("Generating Calendar for : " + user);
111:                }
112:
113:                try {
114:                    store = getStore(user, password);
115:                    calendar = store.openCalendar();
116:
117:                    if (user.equals(CHRIS)) {
118:                        setTasksForChris(calendar);
119:                        setEventsForChris(calendar);
120:
121:                    } else if (user.equals(ED)) {
122:                        setTasksForEd(calendar);
123:                        setEventsForEd(calendar);
124:
125:                    } else if (user.equals(MARY)) {
126:                        setTasksForMary(calendar);
127:                        setEventsForMary(calendar);
128:                    }
129:
130:                    store.disconnect();
131:                } catch (Exception e) {
132:                    e.printStackTrace();
133:                    return;
134:                }
135:
136:                if (debug) {
137:                    System.out.println("Finished generating Calendar for: "
138:                            + user);
139:                }
140:
141:            }
142:
143:            /*
144:             * Chris' Tasks
145:             *
146:             */
147:            public void setTasksForChris(ICalendar calendar) throws Exception {
148:
149:                // E-mail agenda for "New Tours" meeting
150:                //
151:                VTodo task = calendar.createTodo();
152:                task.setSummary("E-mail agenda for \"New Tours\" meeting");
153:                calendar.addTodo(task, false);
154:
155:                // Review documents for "New Tours" project
156:                //
157:                task = calendar.createTodo();
158:                task.setSummary("Review documents for \"New Tours\" project");
159:                calendar.addTodo(task, false);
160:
161:                // Schedule meeting with Mary
162:                //
163:                task = calendar.createTodo();
164:                task.setSummary("Schedule meeting with Mary");
165:                calendar.addTodo(task, false);
166:
167:            }
168:
169:            /*
170:             * Ed's Tasks
171:             *
172:             */
173:            public void setTasksForEd(ICalendar calendar) throws Exception {
174:
175:                // Update contact information
176:                //
177:                VTodo task = calendar.createTodo();
178:                task.setSummary("Update contact information");
179:                calendar.addTodo(task, false);
180:
181:                // 
182:                //
183:                task = calendar.createTodo();
184:                task
185:                        .setSummary("Browse ASC job opportunities and call old colleagues");
186:                calendar.addTodo(task, false);
187:
188:                // 
189:                //
190:                task = calendar.createTodo();
191:                task.setSummary("Schedule meeting with Mary");
192:                calendar.addTodo(task, false);
193:
194:            }
195:
196:            /*
197:             * Mary's Tasks
198:             *
199:             */
200:            public void setTasksForMary(ICalendar calendar) throws Exception {
201:
202:                // Confirm Chris' availability for "New Tours" meeting
203:                // 
204:                VTodo task = calendar.createTodo();
205:                task
206:                        .setSummary("Confirm Chris' availability for \"New Tours\" meeting");
207:                calendar.addTodo(task, false);
208:
209:                // Review hiring policies
210:                // 
211:                task = calendar.createTodo();
212:                task.setSummary("Review hiring policies");
213:                calendar.addTodo(task, false);
214:
215:                // Finish performance reviews (overdue)
216:                //
217:                task = calendar.createTodo();
218:
219:                DateTime taskStartTime = new DateTime();
220:                DateTime taskEndTime = new DateTime();
221:
222:                taskStartTime.setDay(taskStartTime.getDay() - 1);
223:                task.setStartTime(taskStartTime);
224:                task.setDueTime(taskEndTime);
225:                task.setSummary("Finish performance reviews");
226:                calendar.addTodo(task, false);
227:            }
228:
229:            /*
230:             * Chris' Events
231:             *
232:             */
233:            public void setEventsForChris(ICalendar calendar) throws Exception {
234:                RecurrencePattern rp = new RecurrencePattern(
235:                        RecurrencePattern.DAILY, 1, 60);
236:                VEvent event = calendar.createEvent();
237:                DateTime eventStartTime = new DateTime();
238:                DateTime eventEndTime = new DateTime();
239:                String summary = "Appointment with Mary";
240:                String location = "Mary's office";
241:
242:                eventStartTime.setHours(9);
243:                eventStartTime.setMinutes(0);
244:                eventEndTime.setHours(10);
245:                eventEndTime.setMinutes(0);
246:                event.addRecurrenceRule(rp);
247:                event.setDescription(summary);
248:                event.setLocation(location);
249:                event.setSummary(summary);
250:                event.setStartTime(eventStartTime);
251:                event.setEndTime(eventEndTime);
252:                calendar.addEvent(event, false);
253:
254:                event = calendar.createEvent();
255:                eventStartTime = new DateTime();
256:                eventEndTime = new DateTime();
257:                summary = "Public Outreach Planning Meeting";
258:                location = "Pikes Peak Room";
259:
260:                eventStartTime.setHours(13);
261:                eventStartTime.setMinutes(0);
262:                eventEndTime.setHours(14);
263:                eventEndTime.setMinutes(0);
264:                event.addRecurrenceRule(rp);
265:                event.setDescription(summary);
266:                event.setLocation(location);
267:                event.setSummary(summary);
268:                event.setStartTime(eventStartTime);
269:                event.setEndTime(eventEndTime);
270:                calendar.addEvent(event, false);
271:
272:                event = calendar.createEvent();
273:                eventStartTime = new DateTime();
274:                eventEndTime = new DateTime();
275:                summary = "New Customer Tours Meeting";
276:                location = "Longs Peak Room";
277:
278:                eventStartTime.setHours(14);
279:                eventStartTime.setMinutes(0);
280:                eventEndTime.setHours(15);
281:                eventEndTime.setMinutes(0);
282:                event.addRecurrenceRule(rp);
283:                event.setDescription(summary);
284:                event.setLocation(location);
285:                event.setSummary(summary);
286:                event.setStartTime(eventStartTime);
287:                event.setEndTime(eventEndTime);
288:                calendar.addEvent(event, false);
289:
290:            }
291:
292:            /*
293:             * Ed's Events
294:             *
295:             */
296:            public void setEventsForEd(ICalendar calendar) throws Exception {
297:                RecurrencePattern rp = new RecurrencePattern(
298:                        RecurrencePattern.DAILY, 1, 60);
299:                VEvent event = calendar.createEvent();
300:                DateTime eventStartTime = new DateTime();
301:                DateTime eventEndTime = new DateTime();
302:                String summary = "Appointment with Mary";
303:                String location = "Mary's office";
304:
305:                eventStartTime.setHours(10);
306:                eventStartTime.setMinutes(0);
307:                eventEndTime.setHours(11);
308:                eventEndTime.setMinutes(0);
309:                event.addRecurrenceRule(rp);
310:                event.setDescription(summary);
311:                event.setLocation(location);
312:                event.setSummary(summary);
313:                event.setStartTime(eventStartTime);
314:                event.setEndTime(eventEndTime);
315:                calendar.addEvent(event, false);
316:
317:                event = calendar.createEvent();
318:                eventStartTime = new DateTime();
319:                eventEndTime = new DateTime();
320:                summary = "Public Outreach Planning Meeting";
321:                location = "Pikes Peak Room";
322:
323:                eventStartTime.setHours(13);
324:                eventStartTime.setMinutes(0);
325:                eventEndTime.setHours(14);
326:                eventEndTime.setMinutes(0);
327:                event.addRecurrenceRule(rp);
328:                event.setDescription(summary);
329:                event.setLocation(location);
330:                event.setSummary(summary);
331:                event.setStartTime(eventStartTime);
332:                event.setEndTime(eventEndTime);
333:                calendar.addEvent(event, false);
334:
335:                event = calendar.createEvent();
336:                eventStartTime = new DateTime();
337:                eventEndTime = new DateTime();
338:                summary = "Australia Expansion Meeting";
339:                location = "Mount Hood Room";
340:
341:                eventStartTime.setHours(15);
342:                eventStartTime.setMinutes(0);
343:                eventEndTime.setHours(16);
344:                eventEndTime.setMinutes(0);
345:                event.addRecurrenceRule(rp);
346:                event.setDescription(summary);
347:                event.setLocation(location);
348:                event.setSummary(summary);
349:                event.setStartTime(eventStartTime);
350:                event.setEndTime(eventEndTime);
351:                calendar.addEvent(event, false);
352:
353:            }
354:
355:            /*
356:             * Mary's Events
357:             *
358:             */
359:            public void setEventsForMary(ICalendar calendar) throws Exception {
360:                RecurrencePattern rp = new RecurrencePattern(
361:                        RecurrencePattern.DAILY, 1, 60);
362:                VEvent event = calendar.createEvent();
363:                DateTime eventStartTime = new DateTime();
364:                DateTime eventEndTime = new DateTime();
365:                String summary = "Appointment with Chris";
366:                String location = "My office";
367:
368:                eventStartTime.setHours(9);
369:                eventStartTime.setMinutes(0);
370:                eventEndTime.setHours(10);
371:                eventEndTime.setMinutes(0);
372:                event.addRecurrenceRule(rp);
373:                event.setDescription(summary);
374:                event.setLocation(location);
375:                event.setSummary(summary);
376:                event.setStartTime(eventStartTime);
377:                event.setEndTime(eventEndTime);
378:                calendar.addEvent(event, false);
379:
380:                event = calendar.createEvent();
381:                eventStartTime = new DateTime();
382:                eventEndTime = new DateTime();
383:                summary = "Appointment with Ed";
384:                location = "My office";
385:
386:                eventStartTime.setHours(10);
387:                eventStartTime.setMinutes(0);
388:                eventEndTime.setHours(11);
389:                eventEndTime.setMinutes(0);
390:                event.addRecurrenceRule(rp);
391:                event.setDescription(summary);
392:                event.setLocation(location);
393:                event.setSummary(summary);
394:                event.setStartTime(eventStartTime);
395:                event.setEndTime(eventEndTime);
396:                calendar.addEvent(event, false);
397:
398:                event = calendar.createEvent();
399:                eventStartTime = new DateTime();
400:                eventEndTime = new DateTime();
401:                summary = "Public Outreach Planning Meeting";
402:                location = "Pikes Peak Room";
403:
404:                eventStartTime.setHours(13);
405:                eventStartTime.setMinutes(0);
406:                eventEndTime.setHours(14);
407:                eventEndTime.setMinutes(0);
408:                event.addRecurrenceRule(rp);
409:                event.setDescription(summary);
410:                event.setLocation(location);
411:                event.setSummary(summary);
412:                event.setStartTime(eventStartTime);
413:                event.setEndTime(eventEndTime);
414:                calendar.addEvent(event, false);
415:
416:                event = calendar.createEvent();
417:                eventStartTime = new DateTime();
418:                eventEndTime = new DateTime();
419:                summary = "New Customer Tours Meeting";
420:                location = "Longs Peak Room";
421:
422:                eventStartTime.setHours(14);
423:                eventStartTime.setMinutes(0);
424:                eventEndTime.setHours(15);
425:                eventEndTime.setMinutes(0);
426:                event.addRecurrenceRule(rp);
427:                event.setDescription(summary);
428:                event.setLocation(location);
429:                event.setSummary(summary);
430:                event.setStartTime(eventStartTime);
431:                event.setEndTime(eventEndTime);
432:                calendar.addEvent(event, false);
433:
434:                event = calendar.createEvent();
435:                eventStartTime = new DateTime();
436:                eventEndTime = new DateTime();
437:                summary = "Australia Expansion Meeting";
438:                location = "Mount Hood Room";
439:
440:                eventStartTime.setHours(15);
441:                eventStartTime.setMinutes(0);
442:                eventEndTime.setHours(16);
443:                eventEndTime.setMinutes(0);
444:                event.addRecurrenceRule(rp);
445:                event.setDescription(summary);
446:                event.setLocation(location);
447:                event.setSummary(summary);
448:                event.setStartTime(eventStartTime);
449:                event.setEndTime(eventEndTime);
450:                calendar.addEvent(event, false);
451:
452:            }
453:
454:            /*
455:             * Usage
456:             *
457:             */
458:            private static void usage() {
459:                System.out
460:                        .println("usage: java PopulateCalendar <URLName> true|false");
461:            }
462:
463:            /*
464:             * Main
465:             *
466:             */
467:            public static void main(String[] args) {
468:
469:                if (args.length == 0) {
470:                    usage();
471:                    return;
472:                }
473:
474:                String protocol = args[0];
475:                String host = args[1];
476:                String port = args[2];
477:                String domain = args[3];
478:                boolean debug = true;
479:
480:                if (args[4] != null) {
481:                    debug = Boolean.valueOf(args[4]).booleanValue();
482:                }
483:
484:                PopulateCalendar seed = new PopulateCalendar(protocol, host,
485:                        port, domain, debug);
486:                /**
487:                 * CR 6268652 : Password is same as User ID 
488:                 */
489:                seed.generate(seed.ED, seed.ED);
490:                seed.generate(seed.CHRIS, seed.CHRIS);
491:                seed.generate(seed.MARY, seed.MARY);
492:            }
493:
494:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.