1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package de.bea.domingo.samples.groupware;
23
24 import java.util.Calendar;
25 import java.util.Iterator;
26
27 import de.bea.domingo.groupware.CalendarEntry;
28 import de.bea.domingo.groupware.CalendarInterface;
29 import de.bea.domingo.groupware.Email;
30 import de.bea.domingo.groupware.EmailDigest;
31 import de.bea.domingo.groupware.Groupware;
32 import de.bea.domingo.groupware.GroupwareException;
33 import de.bea.domingo.groupware.Mailbox;
34 import de.bea.domingo.monitor.ConsoleMonitor;
35
36
37 /***
38 * A simple example about how to use the groupware package of domingo.
39 *
40 * @author <a href=mailto:kriede@users.sourceforge.net>Kurt Riede</a>
41 */
42 public class GroupwareSample {
43
44 private static final int MAX_MAILS = 10;
45
46 /***
47 * The main method.
48 *
49 * @param args arguments
50 */
51 public static void main(final String[] args) {
52 GroupwareSample sample = new GroupwareSample();
53 try {
54 sample.run();
55 } catch (GroupwareException e) {
56 e.printStackTrace();
57 }
58 }
59
60 private void run() throws GroupwareException {
61
62
63 ConsoleMonitor monitor = new ConsoleMonitor();
64 monitor.setLevel(ConsoleMonitor.DEBUG);
65 Groupware groupware = new Groupware("notes:///local!!mail/kriede2.nsf", monitor);
66 Mailbox mailbox = groupware.getMailbox();
67 CalendarInterface calendar = groupware.getCalendar();
68
69
70 Iterator inbox = mailbox.getInbox();
71 int i = 0;
72 while (inbox.hasNext() && i++ < MAX_MAILS) {
73 EmailDigest emailDigest = (EmailDigest) inbox.next();
74 System.out.println(emailDigest.toString());
75 }
76
77
78 Email email = new Email();
79 email.setSubject("Test");
80 email.setRecipient("kurt.riede@bea.de");
81 email.setBody("Hello world!");
82 mailbox.send(email);
83 System.out.println("Email sent");
84
85
86 CalendarEntry entry = new CalendarEntry();
87 entry.setTitle("New Years Party");
88 entry.setStartDate(2006, Calendar.DECEMBER, 31);
89 entry.setStartTime(20, 0, 0);
90 entry.setEndDate(2007, Calendar.JANUARY, 1);
91 entry.setEndTime(5, 0, 0);
92 calendar.save(entry);
93 System.out.println("Appointment created");
94 }
95 }