Source Code Cross Referenced for RegistrationNotification.java in  » Blogger-System » blojsom-3.1 » org » blojsom » plugin » registration » 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 » Blogger System » blojsom 3.1 » org.blojsom.plugin.registration 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright (c) 2003-2007, David A. Czarnecki
003:         * All rights reserved.
004:         *
005:         * Redistribution and use in source and binary forms, with or without
006:         * modification, are permitted provided that the following conditions are met:
007:         *
008:         * Redistributions of source code must retain the above copyright notice, this list of conditions and the
009:         *     following disclaimer.
010:         * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
011:         *     following disclaimer in the documentation and/or other materials provided with the distribution.
012:         * Neither the name of "David A. Czarnecki" and "blojsom" nor the names of its contributors may be used to
013:         *     endorse or promote products derived from this software without specific prior written permission.
014:         * Products derived from this software may not be called "blojsom", nor may "blojsom" appear in their name,
015:         *     without prior written permission of David A. Czarnecki.
016:         *
017:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
018:         * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
019:         * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
020:         * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
021:         * EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
022:         * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
023:         * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
024:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
025:         * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
026:         * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
027:         * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
028:         * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
029:         * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
030:         */package org.blojsom.plugin.registration;
031:
032:        import org.apache.commons.mail.Email;
033:        import org.apache.commons.mail.EmailException;
034:        import org.blojsom.blog.Blog;
035:        import org.blojsom.blog.User;
036:        import org.blojsom.plugin.notification.AbstractVelocityEmailNotification;
037:        import org.blojsom.plugin.notification.AbstractNotification;
038:
039:        import javax.mail.Address;
040:        import javax.mail.MessagingException;
041:        import java.net.URL;
042:        import java.util.*;
043:
044:        /**
045:         * RegistrationNotification
046:         *
047:         * @author Eric Broyles
048:         * @version $Id: RegistrationNotification.java,v 1.2 2007/01/17 02:35:05 czarneckid Exp $
049:         */
050:        public class RegistrationNotification extends
051:                AbstractVelocityEmailNotification {
052:
053:            private Email email;
054:
055:            /**
056:             * Create a new registration notification
057:             *
058:             * @param email E-mail message
059:             * @param emailTemplate URL for template
060:             * @param user {@link User}
061:             * @param blog {@link Blog}
062:             * @throws MessagingException If there is an error setting the e-mail content
063:             */
064:            public RegistrationNotification(Email email, URL emailTemplate,
065:                    User user, Blog blog) throws MessagingException {
066:                super (email, emailTemplate);
067:                setEmail(email);
068:                if (!"".equals(user.getUserName()))
069:                    put("name", user.getUserName());
070:                else
071:                    put("name", user.getUserLogin());
072:                put("subject", email.getSubject());
073:                put("blogName", blog.getBlogName());
074:                put("username", user.getUserLogin());
075:                put("password", user.getUserPassword());
076:                put("blogUrl", blog.getBlogURL());
077:                put("privacyUrl", blog.getProperty("privacy-policy-url",
078:                        (new StringBuffer()).append(blog.getBlogURL()).append(
079:                                "/privacy.html").toString(), false));
080:                put("blogOwner", blog.getBlogOwner());
081:                put("activationUrl", (new StringBuffer()).append(
082:                        blog.getBlogURL()).append(
083:                        "?plugins=registration&action=activate&username=")
084:                        .append(user.getUserLogin()).toString());
085:                try {
086:                    email.setContent(getMessage(), "text/html");
087:                } catch (Exception e) {
088:                    throw new MessagingException(
089:                            "Failed to set the content of the message. ", e);
090:                }
091:            }
092:
093:            /**
094:             * @see AbstractNotification#getBlindCarbonCopyRecipients()
095:             */
096:            protected List getBlindCarbonCopyRecipients() {
097:                try {
098:                    return convertElementsToString(getEmail()
099:                            .getMimeMessage()
100:                            .getRecipients(
101:                                    javax.mail.internet.MimeMessage.RecipientType.BCC));
102:                } catch (MessagingException e) {
103:                    e.printStackTrace();
104:                }
105:                return Collections.EMPTY_LIST;
106:            }
107:
108:            /**
109:             * @see AbstractNotification#getBlindCarbonCopyRecipients() 
110:             */
111:            protected List getCarbonCopyRecipients() {
112:                try {
113:                    return convertElementsToString(getEmail()
114:                            .getMimeMessage()
115:                            .getRecipients(
116:                                    javax.mail.internet.MimeMessage.RecipientType.CC));
117:                } catch (MessagingException e) {
118:                    e.printStackTrace();
119:                }
120:                return Collections.EMPTY_LIST;
121:            }
122:
123:            /**
124:             * @see AbstractNotification#getRecipients() 
125:             */
126:            protected List getRecipients() {
127:                try {
128:                    return convertElementsToString(getEmail()
129:                            .getMimeMessage()
130:                            .getRecipients(
131:                                    javax.mail.internet.MimeMessage.RecipientType.TO));
132:                } catch (MessagingException e) {
133:                    e.printStackTrace();
134:                }
135:                return Collections.EMPTY_LIST;
136:            }
137:
138:            /**
139:             * @see AbstractNotification#getSender()
140:             */
141:            protected String getSender() {
142:                try {
143:                    return getEmail().getFromAddress().getAddress();
144:                } catch (NullPointerException e) {
145:                    e.printStackTrace();
146:                }
147:                return null;
148:            }
149:
150:            /**
151:             * @see AbstractNotification#getSubject()
152:             */
153:            protected String getSubject() {
154:                return getEmail().getSubject();
155:            }
156:
157:            /**
158:             * Retrieve the e-mail message
159:             *
160:             * @return E-mail message
161:             */
162:            public Email getEmail() {
163:                return email;
164:            }
165:
166:            /**
167:             * Set the e-mail message
168:             *
169:             * @param email E-mail message
170:             */
171:            public void setEmail(Email email) {
172:                this .email = email;
173:            }
174:
175:            /**
176:             * Send the e-mail
177:             *
178:             * @throws EmailException If there is an error sending the e-mail
179:             */
180:            public void send() throws EmailException {
181:                getEmail().send();
182:            }
183:
184:            /**
185:             * Convert a list of addresses into the list
186:             *
187:             * @param addresses Array of addresses
188:             * @return List of addresses
189:             */
190:            protected List convertElementsToString(Address addresses[]) {
191:                if (addresses != null) {
192:                    List addressList = Arrays.asList(addresses);
193:                    List stringList = new ArrayList(addressList.size());
194:                    Address address;
195:                    for (Iterator iter = addressList.iterator(); iter.hasNext(); stringList
196:                            .add(address.toString()))
197:                        address = (Address) iter.next();
198:
199:                    return stringList;
200:                } else {
201:                    return Collections.EMPTY_LIST;
202:                }
203:            }
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.