Source Code Cross Referenced for EmailNotificationSupport.java in  » Project-Management » XPlanner-0.7b7 » com » technoetic » xplanner » mail » 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 » Project Management » XPlanner 0.7b7 » com.technoetic.xplanner.mail 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2006 Your Corporation. All Rights Reserved.
003:         */
004:
005:        package com.technoetic.xplanner.mail;
006:
007:        import java.util.ArrayList;
008:        import java.util.Iterator;
009:        import java.util.List;
010:        import java.util.Map;
011:        import java.util.ResourceBundle;
012:        import java.util.Set;
013:        import java.util.Properties;
014:
015:        import org.apache.log4j.Logger;
016:
017:        import com.technoetic.xplanner.DomainSpecificPropertiesFactory;
018:        import com.technoetic.xplanner.XPlannerProperties;
019:        import com.technoetic.xplanner.domain.Person;
020:        import com.technoetic.xplanner.domain.Project;
021:        import com.technoetic.xplanner.domain.Task;
022:        import com.technoetic.xplanner.domain.UserStory;
023:
024:        /**
025:         * User: mprokopowicz
026:         * Date: Feb 3, 2006
027:         * Time: 5:36:56 PM
028:         */
029:        public class EmailNotificationSupport {
030:            private EmailFormatter emailFormatter;
031:            private DomainSpecificPropertiesFactory propertiesFactory;
032:            private static final Logger log = Logger
033:                    .getLogger(EmailNotificationSupport.class);
034:            private EmailMessageFactory emailMessageFactory;
035:            static final String XPLANNER_MAIL_FROM_KEY = "xplanner.mail.from";
036:
037:            public EmailNotificationSupport(EmailFormatter emailFormatter,
038:                    EmailMessageFactory emailMessageFactory,
039:                    DomainSpecificPropertiesFactory propertiesFactory) {
040:                this .emailFormatter = emailFormatter;
041:                this .emailMessageFactory = emailMessageFactory;
042:                this .propertiesFactory = propertiesFactory;
043:            }
044:
045:            public void sendNotifications(Map notificationEmails,
046:                    String emailHeaderKey, String subjectKey) {
047:                Set keySet = notificationEmails.keySet();
048:                Iterator iterator = keySet.iterator();
049:                ResourceBundle bundle = ResourceBundle
050:                        .getBundle("ResourceBundle");
051:                String subject = bundle.getString(subjectKey);
052:                String emailHeader = bundle.getString(emailHeaderKey);
053:                String emailFooter = bundle
054:                        .getString(MissingTimeEntryNotifier.EMAIL_BODY_FOOTER);
055:                String emailTaskHeader = bundle
056:                        .getString(MissingTimeEntryNotifier.EMAIL_TASK_HEADER);
057:                String emailStoryHeader = bundle
058:                        .getString(MissingTimeEntryNotifier.EMAIL_STORY_HEADER);
059:                while (iterator.hasNext()) {
060:                    Integer id = (Integer) iterator.next();
061:                    List bodyEntryList = (List) notificationEmails.get(id);
062:                    try {
063:                        EmailMessage emailMessage = emailMessageFactory
064:                                .createMessage();
065:                        emailMessage.setRecipient(id.intValue());
066:                        emailMessage.setSubject(subject);
067:                        emailMessage.setFrom(propertiesFactory
068:                                .getDefaultProperties().getProperty(
069:                                        XPLANNER_MAIL_FROM_KEY));
070:                        String formatedText = emailFormatter.formatEmailEntry(
071:                                emailHeader, emailFooter, emailStoryHeader,
072:                                emailTaskHeader, bodyEntryList);
073:                        emailMessage.setBody(formatedText);
074:                        emailMessage.send();
075:                    } catch (Exception e) {
076:                        log.error("Error sending email: ", e);
077:                    }
078:                }
079:            }
080:
081:            public void compileEmail(Map notificationEmails, int receiverId,
082:                    Person acceptor, Task task, UserStory story) {
083:                List emailBodyList;
084:                if (notificationEmails.containsKey(new Integer(receiverId))) {
085:                    emailBodyList = (List) notificationEmails.get(new Integer(
086:                            receiverId));
087:                } else {
088:                    emailBodyList = new ArrayList();
089:                    notificationEmails.put(new Integer(receiverId),
090:                            emailBodyList);
091:                }
092:                List entryList = new ArrayList();
093:                entryList.add(task);
094:                entryList.add(story);
095:                if (acceptor != null) {
096:                    entryList.add(acceptor.getName());
097:                }
098:                emailBodyList.add(entryList);
099:            }
100:
101:            public boolean isProjectToBeNotified(Map projectsToBeNotified,
102:                    Project project) {
103:                Boolean isNotified = (Boolean) projectsToBeNotified
104:                        .get(new Integer(project.getId()));
105:                if (isNotified == null) {
106:                    isNotified = Boolean
107:                            .valueOf(isProjectToBeNotified(project));
108:                    projectsToBeNotified.put(new Integer(project.getId()),
109:                            isNotified);
110:                }
111:                return isNotified.booleanValue();
112:            }
113:
114:            public boolean isProjectToBeNotified(Project project) {
115:                Boolean isNotified;
116:                Properties projectDynamicProperties = propertiesFactory
117:                        .createPropertiesFor(project);
118:                String stringValue = projectDynamicProperties.getProperty(
119:                        XPlannerProperties.SEND_NOTIFICATION_KEY, Boolean.TRUE
120:                                .toString());
121:                return Boolean.valueOf(stringValue).booleanValue();
122:            }
123:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.