Source Code Cross Referenced for CreateTemplateBean.java in  » Portal » Open-Portal » com » sun » portal » admin » console » ssoa » 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.admin.console.ssoa 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * $Id: CreateTemplateBean.java,v 1.7 2006/06/01 18:10:55 sorensen Exp $
003:         * Copyright 2005 Sun Microsystems, Inc. All
004:         * rights reserved. Use of this product is subject
005:         * to license terms. Federal Acquisitions:
006:         * Commercial Software -- Government Users
007:         * Subject to Standard License Terms and
008:         * Conditions.
009:         *
010:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
011:         * are trademarks or registered trademarks of Sun Microsystems,
012:         * Inc. in the United States and other countries.
013:         */package com.sun.portal.admin.console.ssoa;
014:
015:        import java.util.*;
016:        import java.io.*;
017:        import java.util.logging.Level;
018:        import com.sun.data.provider.impl.ObjectListDataProvider;
019:        import com.sun.web.ui.model.Option;
020:        import com.sun.web.ui.event.WizardEvent;
021:        import com.sun.web.ui.event.WizardEventListener;
022:
023:        import javax.faces.application.FacesMessage;
024:        import javax.faces.component.UIComponent;
025:        import javax.faces.context.FacesContext;
026:        import javax.faces.event.ActionEvent;
027:        import javax.faces.validator.ValidatorException;
028:        import javax.management.MBeanServerConnection;
029:
030:        public class CreateTemplateBean extends ListTemplatesBean {
031:
032:            private String basis;
033:            private String name;
034:            private Option[] availableTemplates;
035:            public static String GENERIC_TEMPLATE = "GENERIC_TEMPLATE";
036:
037:            private void resetAvailableTemplates() {
038:                availableTemplates = new Option[templatesList.size()];
039:                for (int i = 0; i < templatesList.size(); i++) {
040:                    TemplateNameBean tnb = (TemplateNameBean) templatesList
041:                            .get(i);
042:                    availableTemplates[i] = new Option(tnb.getName(), tnb
043:                            .getName());
044:                }
045:                // Make sure that basis is set to null for options
046:                if ((basis == null) && (templatesList.size() > 0)) {
047:                    TemplateNameBean tnb = (TemplateNameBean) templatesList
048:                            .get(0);
049:                    basis = tnb.getName();
050:                    log(Level.FINEST,
051:                            "CreateTemplateBean.resetAvailableTemplates setting basis to "
052:                                    + basis);
053:                }
054:            }
055:
056:            public String getBasis() {
057:                if (basis == null) {
058:                    // If the basis is null, check first if it is set in the session.
059:                    basis = (String) getSessionAttribute(ATTR_SELECTED_TEMPLATE);
060:                    if (basis == null) {
061:                        basis = GENERIC_TEMPLATE;
062:                    }
063:                }
064:                return basis;
065:            }
066:
067:            public void setBasis(String basis) {
068:                this .basis = basis;
069:            }
070:
071:            public String getName() {
072:                return name;
073:            }
074:
075:            public void setName(String name) {
076:                this .name = name;
077:            }
078:
079:            // Reset the available templates every time this is called
080:            // in order to catch any other actions (delete) that could occur between
081:            // runnings of the template wizard
082:            public Option[] getAvailableTemplates() {
083:                log(Level.FINEST,
084:                        "CreateTemplateBean.getAvailableTemplates start");
085:                if (availableTemplates == null) {
086:                    resetTemplateNames();
087:                    resetAvailableTemplates();
088:                }
089:                return availableTemplates;
090:            }
091:
092:            public String create() {
093:                Map basisAttributes = null;
094:                MBeanServerConnection connection = getMBeanServerConnection();
095:                try {
096:                    // Create a new template with these properties
097:                    String[] signature = { String.class.getName(),
098:                            String.class.getName() };
099:                    Object[] params = { name, basis };
100:                    // This can throw AttributeNotFoundException, MBeanException, InstanceNotFoundException
101:                    // ReflectionException, RuntimeOperationsException, or IOException
102:                    connection.invoke(objectName, "createTemplate", params,
103:                            signature);
104:                } catch (Exception ex) {
105:                    log(Level.SEVERE,
106:                            "CreateTemplateBean.create: Exception when"
107:                                    + " creating new template " + name, ex);
108:                    // Put alert stuff here
109:                }
110:                return cancel();
111:            }
112:
113:            //============================================================
114:            // validator for unique template name
115:            //============================================================
116:            public void validateName(FacesContext ctx, UIComponent comp,
117:                    Object value) {
118:                log(Level.FINEST, "CreateTemplatesBean.validateName start");
119:                String sm = (String) rbMap.get("error.validation.summary");
120:                String cn = (String) value;
121:                // Make sure no illegal characters are used
122:                // Allow alphanumerics, dash, and underscore only
123:                if (cn != null && cn.matches(".*[^a-zA-Z0-9-_].*")) {
124:                    String cm = (String) rbMap
125:                            .get("error.meta.illegal.characters");
126:                    throw new ValidatorException(new FacesMessage(sm, cm));
127:                }
128:
129:                // Make sure this isn't in the list of availableTemplate options
130:                for (int i = 0; i < templatesList.size(); i++) {
131:                    TemplateNameBean tnb = (TemplateNameBean) templatesList
132:                            .get(i);
133:                    if (value.equals(tnb.getName())) {
134:                        String dm = (String) rbMap.get("error.duplicate");
135:                        throw new ValidatorException(new FacesMessage(sm, dm));
136:                    }
137:                }
138:            }
139:
140:            public String cancel() {
141:                log(Level.FINEST, "CreateTemplateBean.cancel start");
142:                // Reset the bean
143:                basis = null;
144:                name = null;
145:                availableTemplates = null;
146:                return "cancel";
147:            }
148:
149:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.