Source Code Cross Referenced for QuestionTool.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » tool » help » 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 » ERP CRM Financial » sakai » org.sakaiproject.tool.help 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/help/tags/sakai_2-4-1/help-tool/src/java/org/sakaiproject/tool/help/QuestionTool.java $
003:         * $Id: QuestionTool.java 7900 2006-04-18 08:04:32Z marquard@ched.uct.ac.za $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2003, 2004 The Sakai Foundation.
007:         * 
008:         * Licensed under the Educational Community License, Version 1.0 (the "License"); 
009:         * you may not use this file except in compliance with the License. 
010:         * You may obtain a copy of the License at
011:         * 
012:         *      http://www.opensource.org/licenses/ecl1.php
013:         * 
014:         * Unless required by applicable law or agreed to in writing, software 
015:         * distributed under the License is distributed on an "AS IS" BASIS, 
016:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
017:         * See the License for the specific language governing permissions and 
018:         * limitations under the License.
019:         *
020:         **********************************************************************************/package org.sakaiproject.tool.help;
021:
022:        import org.apache.commons.logging.Log;
023:
024:        import org.sakaiproject.api.app.help.HelpManager;
025:        import org.sakaiproject.component.cover.ServerConfigurationService;
026:        import org.sakaiproject.email.api.EmailService;
027:        import org.sakaiproject.event.cover.UsageSessionService;
028:        import org.sakaiproject.tool.cover.ToolManager;
029:
030:        /**
031:         * question tool
032:         * @version $Id: QuestionTool.java 7900 2006-04-18 08:04:32Z marquard@ched.uct.ac.za $
033:         */
034:        public class QuestionTool {
035:
036:            private String lastName;
037:            private String firstName;
038:            private String userName;
039:            private String emailAddress;
040:            private String subject;
041:            private String content;
042:
043:            private String toEmailAddress;
044:            private EmailService emailService;
045:            private Log logger;
046:            private HelpManager helpManager;
047:
048:            /**
049:             * get help manager
050:             * @return Returns the helpManager.
051:             */
052:            public HelpManager getHelpManager() {
053:                return helpManager;
054:            }
055:
056:            /**
057:             * set help manager
058:             * @param helpManager The helpManager to set.
059:             */
060:            public void setHelpManager(HelpManager helpManager) {
061:                this .helpManager = helpManager;
062:            }
063:
064:            /**
065:             * get email address
066:             * @return Returns the emailAddress.
067:             */
068:            public String getEmailAddress() {
069:                return emailAddress;
070:            }
071:
072:            /**
073:             * set email address
074:             * @param emailAddress The emailAddress to set.
075:             */
076:            public void setEmailAddress(String emailAddress) {
077:                this .emailAddress = emailAddress;
078:            }
079:
080:            /**
081:             * get first name
082:             * @return Returns the firstName.
083:             */
084:            public String getFirstName() {
085:                return firstName;
086:            }
087:
088:            /**
089:             * set first name
090:             * @param firstName The firstName to set.
091:             */
092:            public void setFirstName(String firstName) {
093:                this .firstName = firstName;
094:            }
095:
096:            /**
097:             * get last name
098:             * @return Returns the lastName.
099:             */
100:            public String getLastName() {
101:                return lastName;
102:            }
103:
104:            /**
105:             * set last name
106:             * @param lastName The lastName to set.
107:             */
108:            public void setLastName(String lastName) {
109:                this .lastName = lastName;
110:            }
111:
112:            /**
113:             * get subject
114:             * @return Returns the subject.
115:             */
116:            public String getSubject() {
117:                return subject;
118:            }
119:
120:            /**
121:             * set subject
122:             * @param subject The subject to set.
123:             */
124:            public void setSubject(String subject) {
125:                this .subject = subject;
126:            }
127:
128:            /**
129:             * get user name
130:             * @return Returns the userName.
131:             */
132:            public String getUserName() {
133:                return userName;
134:            }
135:
136:            /**
137:             * set user name
138:             * @param userName The userName to set.
139:             */
140:            public void setUserName(String userName) {
141:                this .userName = userName;
142:            }
143:
144:            /**
145:             * get email service
146:             * @return Returns the emailService.
147:             */
148:            public EmailService getEmailService() {
149:                return emailService;
150:            }
151:
152:            /**
153:             * set email service
154:             * @param emailService The emailService to set.
155:             */
156:            public void setEmailService(EmailService emailService) {
157:                this .emailService = emailService;
158:            }
159:
160:            /**
161:             * get to email address
162:             * @return Returns the toEmailAddress.
163:             */
164:            public String getToEmailAddress() {
165:                if (toEmailAddress == null) {
166:                    toEmailAddress = helpManager.getSupportEmailAddress();
167:                }
168:                return toEmailAddress;
169:            }
170:
171:            /**
172:             * set to email address
173:             * @param toEmailAddress The toEmailAddress to set.
174:             */
175:            public void setToEmailAddress(String toEmailAddress) {
176:                this .toEmailAddress = toEmailAddress;
177:            }
178:
179:            /**
180:             * get detailed content
181:             * @return content
182:             */
183:            public String getDetailedContent() {
184:
185:                String UNAVAILABLE = "~unavailable~";
186:
187:                String IP = UNAVAILABLE;
188:                String agent = UNAVAILABLE;
189:                String sessionId = UNAVAILABLE;
190:                String serverName = UNAVAILABLE;
191:
192:                if (UsageSessionService.getSession() != null) {
193:
194:                    IP = UsageSessionService.getSession().getIpAddress();
195:                    agent = UsageSessionService.getSession().getUserAgent();
196:                    sessionId = UsageSessionService.getSession().getId();
197:                    serverName = ServerConfigurationService.getServerName();
198:                }
199:
200:                String detailedContent = "\n\n" + "Sender's name: "
201:                        + this .firstName + " " + this .lastName + "\n"
202:                        + "Sender's UserName: " + userName + "\n"
203:                        + "Sender's IP: " + IP + "\n"
204:                        + "Sender's Browser/Agent: " + agent + "\n"
205:                        + "Sender's SessionID: " + sessionId + "\n"
206:                        + "Server Name: " + serverName + "\n"
207:                        + "Comments or questions: \n" + this .getContent()
208:                        + "\n\n" + "Sender's (reply-to) email: " + emailAddress
209:                        + "\n\n" + "Site: Help Tool" + "\n" + "Site Id: "
210:                        + ToolManager.getCurrentPlacement().getContext() + "\n";
211:
212:                return detailedContent;
213:
214:            }
215:
216:            /**
217:             * submit question
218:             * @return view
219:             */
220:            public String submitQuestion() {
221:                this .sendEmail();
222:                return "display";
223:            }
224:
225:            /**
226:             * reset
227:             * @return view
228:             */
229:            public String reset() {
230:                this .content = "";
231:                this .subject = "";
232:                this .firstName = "";
233:                this .lastName = "";
234:                this .emailAddress = "";
235:                this .userName = "";
236:
237:                return "main";
238:            }
239:
240:            /**
241:             * submit question cancel
242:             * @return
243:             */
244:            public String submitQuestionCancel() {
245:                return this .reset();
246:            }
247:
248:            /**
249:             * send email
250:             */
251:            private void sendEmail() {
252:                try {
253:                    String detailedContent = getDetailedContent();
254:                    emailService.send(emailAddress, this .getToEmailAddress(),
255:                            subject, detailedContent, null, null, null);
256:                } catch (Exception e) {
257:                    logger
258:                            .error(
259:                                    "email service is not set up correctly, can't send user question to support consultant!",
260:                                    e);
261:                }
262:            }
263:
264:            /**
265:             * get content
266:             * @return Returns the content.
267:             */
268:            public String getContent() {
269:                return content;
270:            }
271:
272:            /**
273:             * set content
274:             * @param content The content to set.
275:             */
276:            public void setContent(String content) {
277:                this .content = content;
278:            }
279:
280:            /**
281:             * get logger
282:             * @return Returns the logger.
283:             */
284:            public Log getLogger() {
285:                return logger;
286:            }
287:
288:            /**
289:             * set logger
290:             * @param logger The logger to set.
291:             */
292:            public void setLogger(Log logger) {
293:                this.logger = logger;
294:            }
295:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.