Source Code Cross Referenced for EditMailFactoryPropertiesAction.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » webapp » jonasadmin » resource » 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 » J2EE » JOnAS 4.8.6 » org.objectweb.jonas.webapp.jonasadmin.resource 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * --------------------------------------------------------------------------
022:         * $Id: 
023:         * --------------------------------------------------------------------------
024:         */
025:
026:        package org.objectweb.jonas.webapp.jonasadmin.resource;
027:
028:        import java.io.IOException;
029:        import java.util.Enumeration;
030:        import java.util.Properties;
031:
032:        import javax.servlet.ServletException;
033:        import javax.servlet.http.HttpServletRequest;
034:        import javax.servlet.http.HttpServletResponse;
035:
036:        import org.apache.struts.action.ActionForm;
037:        import org.apache.struts.action.ActionForward;
038:        import org.apache.struts.action.ActionMapping;
039:        import org.objectweb.jonas.webapp.jonasadmin.deploy.BaseDeployAction;
040:
041:        /**
042:         * Helper for actions for the deployment of Mail Factories
043:         * @author Adriana Danes
044:         */
045:        public class EditMailFactoryPropertiesAction extends BaseDeployAction {
046:
047:            public ActionForward executeAction(ActionMapping p_Mapping,
048:                    ActionForm p_Form, HttpServletRequest p_Request,
049:                    HttpServletResponse p_Response) throws IOException,
050:                    ServletException {
051:
052:                String sAction = p_Request.getParameter("action");
053:                MailFactoryPropertiesForm oForm = new MailFactoryPropertiesForm();
054:                oForm.reset(p_Mapping, p_Request);
055:                m_Session.setAttribute("mailFactoryPropertiesForm", oForm);
056:                String name = "";
057:                Properties props = new Properties();
058:                try {
059:                    populate(name, props, oForm);
060:                } catch (Throwable t) {
061:                    addGlobalError(t);
062:                    saveErrors(p_Request, m_Errors);
063:                    return (p_Mapping.findForward("Global Error"));
064:                }
065:
066:                // Forward to the jsp.
067:                return (p_Mapping.findForward("MailFactory Properties"));
068:            }
069:
070:            /**
071:             * Populate a form with configuration properties read in a configuration file
072:             *
073:             * @param mailFactoryName the name of the mail factory
074:             * @param props properties to configure the mail factory
075:             * param pForm the form used to print-out the configuration properties
076:             */
077:            void populate(String mailFactoryName, Properties props,
078:                    MailFactoryPropertiesForm pForm) throws Exception {
079:                // Set configuration attributes
080:                // - mail factory name
081:                pForm.setMailFactoryName(mailFactoryName);
082:                // - jndi name
083:                pForm.setJndiName(getStringAttribute(props,
084:                        "mail.factory.name", pForm.getJndiName()));
085:                props.remove("mail.factory.name");
086:                // - type 
087:                pForm.setType(getStringAttribute(props, "mail.factory.type",
088:                        pForm.getType()));
089:                props.remove("mail.factory.type");
090:
091:                // Set authentication properties
092:                pForm.setUsername(getStringAttribute(props,
093:                        "mail.authentication.username", pForm.getUsername()));
094:                props.remove("mail.authentication.username");
095:                pForm.setPassword(getStringAttribute(props,
096:                        "mail.authentication.password", pForm.getPassword()));
097:                props.remove("mail.authentication.password");
098:
099:                // Set mime part properties
100:                pForm
101:                        .setTo(getStringAttribute(props, "mail.to", pForm
102:                                .getTo()));
103:                pForm.setSubject(getStringAttribute(props, "mail.subject",
104:                        pForm.getSubject()));
105:                pForm
106:                        .setCc(getStringAttribute(props, "mail.cc", pForm
107:                                .getCc()));
108:                pForm.setBcc(getStringAttribute(props, "mail.bcc", pForm
109:                        .getBcc()));
110:                props.remove("mail.to");
111:                props.remove("mail.subject");
112:                props.remove("mail.cc");
113:                props.remove("mail.bcc");
114:
115:                // Set the rest of the properties as session properties
116:                String aName = null;
117:                String aValue = null;
118:                StringBuffer bufSessionProps = new StringBuffer();
119:                for (Enumeration pNames = props.propertyNames(); pNames
120:                        .hasMoreElements();) {
121:                    aName = (String) pNames.nextElement();
122:                    aValue = (String) props.getProperty(aName);
123:                    bufSessionProps.append(aName);
124:                    bufSessionProps.append("=");
125:                    bufSessionProps.append(aValue);
126:                    bufSessionProps.append(",");
127:                    bufSessionProps.append("\n");
128:                }
129:                if (!props.isEmpty()) {
130:                    // delete the last 2 chars (, and \n)
131:                    bufSessionProps.delete(bufSessionProps.length() - 2,
132:                            bufSessionProps.length() - 1);
133:                } else {
134:                    // Actually no chars in sessionPropsBuf
135:                    //System.out.println("no session props, append mail.host= ");
136:                    bufSessionProps.append("mail.host=");
137:                }
138:                String sSessionProps = new String(bufSessionProps);
139:                pForm.setSessionProps(sSessionProps);
140:            }
141:
142:            /**
143:             * Use a form's content to create the Properties object needed to create and load a Mail factory
144:             *
145:             */
146:            Properties getPropsFromForm(MailFactoryPropertiesForm p_Form,
147:                    boolean mimepart) throws Exception {
148:                Properties oProps = new Properties();
149:                Properties sProps = getPropsFromString(p_Form.getSessionProps());
150:                oProps.putAll(sProps);
151:                setStringAttribute(oProps, "mail.factory.name", p_Form
152:                        .getJndiName());
153:                setStringAttribute(oProps, "mail.factory.type", p_Form
154:                        .getType());
155:                setStringAttribute(oProps, "mail.authentication.username",
156:                        p_Form.getUsername());
157:                setStringAttribute(oProps, "mail.authentication.password",
158:                        p_Form.getPassword());
159:                String aName = null;
160:                String aValue = null;
161:                for (Enumeration pNames = oProps.propertyNames(); pNames
162:                        .hasMoreElements();) {
163:                    aName = (String) pNames.nextElement();
164:                    aValue = (String) oProps.getProperty(aName);
165:                }
166:                if (mimepart == true) {
167:                    setStringAttribute(oProps, "mail.to", p_Form.getTo());
168:                    setStringAttribute(oProps, "mail.subject", p_Form
169:                            .getSubject());
170:                    setStringAttribute(oProps, "mail.cc", p_Form.getCc());
171:                    setStringAttribute(oProps, "mail.bcc", p_Form.getBcc());
172:                }
173:                return oProps;
174:            }
175:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.