Source Code Cross Referenced for PopulateMail.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 java.util.*;
004:        import java.io.*;
005:        import javax.mail.*;
006:        import javax.mail.internet.*;
007:
008:        /**
009:         *
010:         * This class is responsible for populating the JES Messaging Server
011:         * with sample data for the JES Portal Server adventuresportscafe.com
012:         * sample.
013:         *
014:         * It will populate data for the users:  chris, ed, and mary
015:         *
016:         * It uses <code>URLName</code> for server information.
017:         *
018:         */
019:        public class PopulateMail {
020:
021:            protected String host = null;
022:            protected String user = null;
023:            protected String domain = null;
024:            protected int port = 143;
025:            protected boolean debug = false;
026:            protected final static String PASSWORD = "ascsample";
027:
028:            // known users
029:            protected final static String CHRIS = "chris";
030:            protected final static String ED = "ed";
031:            protected final static String MARY = "mary";
032:
033:            /*
034:             * Constructor
035:             *
036:             * @param protocol Mail server protocol
037:             * @param host     Mail server host
038:             * @param port     Mail server port
039:             * @param domain   Mail server hosted domain
040:             */
041:            public PopulateMail(String host, String port, String domain,
042:                    boolean debug) {
043:
044:                this .host = host;
045:                this .domain = "@" + domain;
046:                this .debug = debug;
047:
048:                try {
049:                    this .port = Integer.parseInt(port);
050:                } catch (Exception e) {
051:                    e.printStackTrace();
052:                }
053:
054:            }
055:
056:            /*
057:             * Populate data.
058:             *
059:             */
060:            public void generate() {
061:
062:                Properties props = new Properties();
063:                props.put("mail.smtp.host", host);
064:                props.put("mail.smtp.port", Integer.toString(port));
065:                props.put("mail.debug", Boolean.toString(debug));
066:
067:                Session session = Session.getDefaultInstance(props, null);
068:
069:                try {
070:                    sendMessagesForChris(session);
071:                    sendMessagesForEd(session);
072:                    sendMessagesForMary(session);
073:                } catch (MessagingException mex) {
074:                    mex.printStackTrace();
075:                    return;
076:                }
077:
078:            }
079:
080:            /*
081:             * Chris' Messages
082:             *
083:             */
084:            public void sendMessagesForChris(Session session)
085:                    throws MessagingException {
086:
087:                // Message 1
088:                //
089:                String to = CHRIS + domain;
090:                String from = MARY + domain;
091:                String subject = "Please review new document about top 5 possible tours";
092:                StringBuffer text = new StringBuffer();
093:                text.append("Hi, Chris,\n\n");
094:                text
095:                        .append("I've just posted a document entitled, \"Top 5 Possible New Tours\".  We need to start focusing on one or two of these for future expansion. With that goal in mind, please review the document prior to our weekly meeting for further discussion.  I'm looking forward to hearing your ideas.\n\n");
096:                text.append("Thanks,\n\n");
097:                text.append("Mary");
098:
099:                Message msg = new MimeMessage(session);
100:                InternetAddress[] address = { new InternetAddress(to) };
101:                Calendar date = Calendar.getInstance();
102:                date.set(Calendar.HOUR_OF_DAY, 10);
103:                date.set(Calendar.MINUTE, 30);
104:
105:                msg.setFrom(new InternetAddress(from));
106:                msg.setRecipients(Message.RecipientType.TO, address);
107:                msg.setSubject(subject);
108:                msg.setSentDate(date.getTime());
109:                msg.setText(text.toString());
110:                Transport.send(msg);
111:
112:                // Message 2
113:                // 
114:                from = MARY + domain;
115:                subject = "Latest update from Customer Poll";
116:                text = new StringBuffer();
117:                text.append("Hello, Chris,\n\n");
118:                text
119:                        .append("Could you please send me the latest update from the customer poll.  Also, please let me know if you'll be available for our New Customer Tours meeting this week.");
120:                text.append("Thanks,\n\n");
121:                text.append("Mary");
122:
123:                msg = new MimeMessage(session);
124:                InternetAddress[] address2 = { new InternetAddress(to) };
125:
126:                date = Calendar.getInstance();
127:                date.set(Calendar.HOUR_OF_DAY, 16);
128:                date.set(Calendar.MINUTE, 30);
129:
130:                msg.setFrom(new InternetAddress(from));
131:                msg.setRecipients(Message.RecipientType.TO, address2);
132:                msg.setSubject(subject);
133:                msg.setSentDate(date.getTime());
134:                msg.setText(text.toString());
135:                Transport.send(msg);
136:
137:            }
138:
139:            public void sendMessagesForEd(Session session)
140:                    throws MessagingException {
141:
142:                // Message 1
143:                //
144:                String to = ED + domain;
145:                String from = CHRIS + domain;
146:                String subject = "Top vote-getter from employee poll";
147:                StringBuffer text = new StringBuffer();
148:                text.append("Hey, Ed,\n\n");
149:                text
150:                        .append("Have you seen the results of the latest employee poll?  It sure seems like all your hard work on the Australia Expansion project has really paid off!\n\n");
151:                text.append("Thought you'd like to know,\n\n");
152:                text.append("Chris");
153:
154:                Message msg = new MimeMessage(session);
155:                InternetAddress[] address = { new InternetAddress(to) };
156:                Calendar date = Calendar.getInstance();
157:                date.set(Calendar.HOUR_OF_DAY, 17);
158:                date.set(Calendar.MINUTE, 30);
159:
160:                msg.setFrom(new InternetAddress(from));
161:                msg.setRecipients(Message.RecipientType.TO, address);
162:                msg.setSubject(subject);
163:                msg.setSentDate(date.getTime());
164:                msg.setText(text.toString());
165:                Transport.send(msg);
166:
167:                // Message 2
168:                //
169:                from = MARY + domain;
170:                subject = "New tour developer position";
171:                text = new StringBuffer();
172:                text.append("Hello, Ed,\n\n");
173:                text
174:                        .append("I thought you might be interested in a new tour developer position that is opening up in Maui.  Based on your excellent work on the Australia Expansion project, I think you would be a perfect fit.  Let me know if you'd like to meet to talk about this.\n\n");
175:                text.append("Regards,\n\n");
176:                text.append("Mary");
177:
178:                msg = new MimeMessage(session);
179:                InternetAddress[] address2 = { new InternetAddress(to) };
180:                date = Calendar.getInstance();
181:
182:                msg.setFrom(new InternetAddress(from));
183:                msg.setRecipients(Message.RecipientType.TO, address2);
184:                msg.setSubject(subject);
185:                msg.setSentDate(date.getTime());
186:                msg.setText(text.toString());
187:                Transport.send(msg);
188:
189:                // Message 3
190:                //
191:                from = MARY + domain;
192:                subject = "Status of Final School Selection?";
193:                text = new StringBuffer();
194:                text.append("Hi, Ed,\n\n");
195:                text
196:                        .append("This is just a reminder that I need your decision on a final school selection for the Public Outreach Program.  If something or someone is impeding your progress, please let me know so that I can help.\n\n");
197:                text.append("Thanks,\n\n");
198:                text.append("Mary");
199:
200:                msg = new MimeMessage(session);
201:                InternetAddress[] address3 = { new InternetAddress(to) };
202:                date = Calendar.getInstance();
203:
204:                msg.setFrom(new InternetAddress(from));
205:                msg.setRecipients(Message.RecipientType.TO, address3);
206:                msg.setSubject(subject);
207:                msg.setSentDate(date.getTime());
208:                msg.setText(text.toString());
209:                Transport.send(msg);
210:            }
211:
212:            public void sendMessagesForMary(Session session)
213:                    throws MessagingException {
214:
215:                // Message 1
216:                //
217:                String to = MARY + domain;
218:                String from = "ed" + domain;
219:                String subject = "Review Updated Public Outreach Budget";
220:
221:                StringBuffer text = new StringBuffer();
222:                text.append("Hi Mary, \n\n");
223:                text
224:                        .append("I'd appreciate it if you would review the updated Public Outreach Budget for FY2005, which has been posted to the forum.  Let's discuss this at our regular meeting this week.\n\n");
225:                text.append("Thanks,\n\n");
226:                text.append("Ed");
227:
228:                Message msg = new MimeMessage(session);
229:                InternetAddress[] address = { new InternetAddress(to) };
230:                Calendar date = Calendar.getInstance();
231:                date.set(Calendar.HOUR_OF_DAY, 9);
232:                date.set(Calendar.MINUTE, 0);
233:
234:                msg.setFrom(new InternetAddress(from));
235:                msg.setRecipients(Message.RecipientType.TO, address);
236:                msg.setSubject(subject);
237:                msg.setSentDate(date.getTime());
238:                msg.setText(text.toString());
239:                Transport.send(msg);
240:
241:                // Message 2
242:                //
243:                from = CHRIS + domain;
244:                subject = "Re: Latest update from Customer Poll";
245:                text = new StringBuffer();
246:
247:                text.append("Mary, \n\n");
248:                text
249:                        .append("As you requested, the latest update from the customer poll shows surfing in Australia as the top choice.  Ed should be really pleased to hear about this!\n\n");
250:                text.append("Thanks,\n\n");
251:                text.append("Chris");
252:
253:                msg = new MimeMessage(session);
254:                InternetAddress[] address2 = { new InternetAddress(to) };
255:
256:                date = Calendar.getInstance();
257:                date.set(Calendar.HOUR_OF_DAY, 17);
258:                date.set(Calendar.MINUTE, 0);
259:
260:                msg.setFrom(new InternetAddress(from));
261:                msg.setRecipients(Message.RecipientType.TO, address2);
262:                msg.setSubject(subject);
263:                msg.setSentDate(date.getTime());
264:                msg.setText(text.toString());
265:                Transport.send(msg);
266:
267:            }
268:
269:            private static void usage() {
270:                System.out
271:                        .println("usage: java PopulateMail <URLName> <domain> true|false");
272:            }
273:
274:            /*
275:             *
276:             *
277:             */
278:            public static void main(String[] args) {
279:
280:                if (args.length < 2) {
281:                    usage();
282:                    return;
283:                }
284:
285:                String host = args[0];
286:                String port = args[1];
287:                String domain = args[2];
288:                boolean debug = true;
289:
290:                if (args[3] != null) {
291:                    debug = Boolean.valueOf(args[3]).booleanValue();
292:                }
293:
294:                PopulateMail seed = new PopulateMail(host, port, domain, debug);
295:                seed.generate();
296:            }
297:
298:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.