Source Code Cross Referenced for CreateConfigurationBean.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: CreateConfigurationBean.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 CreateConfigurationBean extends ListConfigurationsByDnBean {
031:
032:            // restart is a switch to see if the wizard needs to be reset next time it is launched 
033:            private String basis;
034:            private String name;
035:            // Used to make sure there is no change in dn during name validation and vice-versa
036:            private String nameInValidation;
037:            private String dnInValidation;
038:
039:            private Option[] availableTemplates;
040:            private boolean hasService = false;
041:
042:            // Fulfil the abstract methods
043:            public String gotoConfigurationHome() {
044:                return "";
045:            }
046:
047:            // Make basis manipulate a session attribute.  This allows the been to be used from
048:            // the list by dn and list by template pages.
049:            public String getBasis() {
050:                if (basis == null) {
051:                    // If the basis is null, check first if it is set in the session.
052:                    basis = (String) getSessionAttribute(ATTR_SELECTED_TEMPLATE);
053:                    if (basis == null) {
054:                        // If not, have populateAvailableTemplates set it
055:                        populateAvailableTemplates();
056:                    }
057:                }
058:                return basis;
059:            }
060:
061:            public void setBasis(String basis) {
062:                this .basis = basis;
063:            }
064:
065:            public String getName() {
066:                return name;
067:            }
068:
069:            public void setName(String name) {
070:                this .name = name;
071:            }
072:
073:            // Populate the available templates if availableTemplates is null
074:            // In addition, set basis to the first template should basis be null
075:            public void populateAvailableTemplates() {
076:                log(Level.FINEST,
077:                        "CreateConfigurationsBean.populateAvailableTemplates start");
078:                // Get available templates
079:                MBeanServerConnection conn = getMBeanServerConnection();
080:                List tNames = new ArrayList();
081:                try {
082:                    // This can throw AttributeNotFoundException, MBeanException, InstanceNotFoundException
083:                    // ReflectionException, RuntimeOperationsException, or IOException
084:                    tNames = (List) conn.getAttribute(objectName,
085:                            "TemplateNames");
086:                } catch (Exception ex) {
087:                    log(
088:                            Level.SEVERE,
089:                            "CreateConfigurationsBean.getAvailableTemplates: Exception when trying to get the list of templates",
090:                            ex);
091:                }
092:                availableTemplates = new Option[tNames.size()];
093:                for (int i = 0; i < tNames.size(); i++) {
094:                    String tName = (String) tNames.get(i);
095:                    // If basis isn't set, set it to the first item
096:                    if ((i == 0) && (basis == null)) {
097:                        log(Level.FINEST,
098:                                "CreateConfigurationsBean.getAvailableTempaltes setting basis to "
099:                                        + tName);
100:                        setBasis(tName);
101:                    }
102:                    availableTemplates[i] = new Option(tName, tName);
103:                }
104:            }
105:
106:            // return the available templates
107:            public Option[] getAvailableTemplates() {
108:                if (availableTemplates == null) {
109:                    populateAvailableTemplates();
110:                }
111:                return availableTemplates;
112:            }
113:
114:            public String create() {
115:                try {
116:                    // Create a new template with these properties
117:                    String[] signature = { String.class.getName(),
118:                            String.class.getName(), String.class.getName() };
119:                    Object[] params = { getCurrentDN(), name, basis };
120:                    MBeanServerConnection connection = getMBeanServerConnection();
121:                    // This can throw AttributeNotFoundException, MBeanException, InstanceNotFoundException
122:                    // ReflectionException, RuntimeOperationsException, or IOException
123:                    connection.invoke(objectName, "createConfiguration",
124:                            params, signature);
125:                } catch (Exception ex) {
126:                    log(Level.SEVERE,
127:                            "CreateConfigurationBean.create: Exception when creating new configuration "
128:                                    + name + " at dn " + getCurrentDN(), ex);
129:                }
130:                // This will tell the configuration list by dn bean to re-query the list from the MBean
131:                setSessionAttribute("resetSSOA", "true");
132:                return cancel();
133:            }
134:
135:            //============================================================
136:            // validator for unique template name
137:            //============================================================
138:            public void validateName(FacesContext ctx, UIComponent comp,
139:                    Object value) {
140:                //nameInValidation = (String) value;
141:                log(Level.FINEST, "ListConfigurationsBean.validateName start");
142:
143:                String sm = (String) rbMap.get("error.validation.summary");
144:                String cn = (String) value;
145:                // Make sure no illegal characters are used
146:                // Allow alphanumerics, dash, and underscore only
147:                if (cn != null && cn.matches(".*[^a-zA-Z0-9-_].*")) {
148:                    String cm = (String) rbMap
149:                            .get("error.adapter.illegal.characters");
150:                    throw new ValidatorException(new FacesMessage(sm, cm));
151:                }
152:
153:                // Make sure this isn't in the list of configurations at the dn
154:                if (hasSSOAService(getCurrentDN())) {
155:                    MBeanServerConnection conn = getMBeanServerConnection();
156:                    Map configs = new HashMap();
157:                    try {
158:                        // This can throw AttributeNotFoundException, MBeanException, InstanceNotFoundException
159:                        // ReflectionException, RuntimeOperationsException, or IOException
160:                        String[] signature = { String.class.getName() };
161:                        Object[] params = { getCurrentDN() };
162:                        MBeanServerConnection connection = getMBeanServerConnection();
163:                        // This can throw AttributeNotFoundException, MBeanException, InstanceNotFoundException
164:                        // ReflectionException, RuntimeOperationsException, or IOException
165:                        configs = (Map) connection.invoke(objectName,
166:                                "getConfigurationNamesByDn", params, signature);
167:                    } catch (Exception ex) {
168:                        log(
169:                                Level.SEVERE,
170:                                "CreateConfigurationBean.validateName(): Exception when trying to get the list of configurations",
171:                                ex);
172:                        configs = new HashMap();
173:                    }
174:                    ArrayList configList = new ArrayList(configs.size());
175:                    Set names = configs.keySet();
176:                    Iterator iter = names.iterator();
177:                    while (iter.hasNext()) {
178:                        String name = (String) iter.next();
179:                        if (name.equals(cn)) {
180:                            String dm = (String) rbMap.get("error.duplicate");
181:                            log(Level.FINEST,
182:                                    "ListConfigurationsBean.validateName end with error");
183:                            throw new ValidatorException(new FacesMessage(sm,
184:                                    dm));
185:                        }
186:                    }
187:                }
188:                log(Level.FINEST, "ListConfigurationsBean.validateName end");
189:            }
190:
191:            //============================================================
192:            // validator for dn to have ssoadapter service
193:            //============================================================
194:            public void validateDn(FacesContext ctx, UIComponent comp,
195:                    Object value) {
196:                // Make sure the dn has the ssoadapter service template
197:                // Immediately set the current dn to the value in order to validate the name properly
198:                log(Level.FINEST,
199:                        "ListConfigurationsBean.validateDn start: currentDn is "
200:                                + getCurrentDN() + " and value passed is "
201:                                + value);
202:                setCurrentDN(value);
203:                /*		try {
204:                 String[] signature = {String.class.getName()};
205:                 Object[] params= {value};
206:                 MBeanServerConnection connection = getMBeanServerConnection();
207:                 // This can throw AttributeNotFoundException, MBeanException, InstanceNotFoundException
208:                 // ReflectionException, RuntimeOperationsException, or IOException
209:                 Boolean hasServiceBool = (Boolean) connection.invoke(objectName, "hasSSOAdapterService", params, signature);
210:                 hasService = hasServiceBool.booleanValue();
211:                 if (!hasService){
212:                 log(Level.SEVERE, "CreateConfigurationBean.validateDn: dn "+value+
213:                 " does not have the SSOAdapter service registered.");
214:                 }
215:                 } catch (Exception ex) {
216:                 log(Level.SEVERE, "CreateConfigurationBean.validateDn: Exception when" +
217:                 " attempting to check ssoadapter service for dn "+value, ex);
218:                 hasService = false;
219:                 }*/
220:                if (!hasSSOAService((String) value)) {
221:                    // Have to set current dn to the value otherwise the dn stays at the previous dn
222:                    setCurrentDN(value);
223:                    String sm = (String) rbMap.get("error.validation.summary");
224:                    String dm = (String) rbMap.get("error.noservice");
225:                    log(Level.FINEST,
226:                            "ListConfigurationsBean.validateDn end with error");
227:                    throw new ValidatorException(new FacesMessage(sm, dm));
228:                }
229:                // There is no way to force one validator to be called before the other.  All that can
230:                // be done is to call the name validator on the private variable "nameInValidation"
231:                // that is set by the validateName method immediately upon call
232:                log(Level.FINEST, "ListConfigurationsBean.validateDn end");
233:            }
234:
235:            // Reset the bean and return the cancel command
236:            public String cancel() {
237:                log(Level.FINEST, "CreateConfigurationBean.cancel: Start");
238:                // Reset the bean
239:                basis = null;
240:                name = null;
241:                availableTemplates = null;
242:                return "cancel";
243:            }
244:
245:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.