Source Code Cross Referenced for ListTemplatesBean.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: ListTemplatesBean.java,v 1.5 2005/09/21 15:29:57 fo160993 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.util.logging.Level;
017:        import java.io.IOException;
018:
019:        import javax.faces.application.FacesMessage;
020:        import javax.faces.context.FacesContext;
021:        import javax.faces.validator.ValidatorException;
022:
023:        import javax.management.ObjectName;
024:        import javax.management.MBeanServerConnection;
025:        import javax.management.MalformedObjectNameException;
026:
027:        import javax.servlet.http.HttpServletRequest;
028:
029:        import com.sun.data.provider.DataProvider;
030:        import com.sun.data.provider.impl.ObjectListDataProvider;
031:        import com.sun.web.ui.component.RadioButton; //import com.sun.web.ui.component.Checkbox;
032:
033:        import com.sun.portal.admin.common.util.AdminClientUtil;
034:
035:        import com.sun.portal.admin.console.common.PSBaseBean;
036:
037:        public class ListTemplatesBean extends PSBaseBean {
038:
039:            public static final String RB_NAME = "ssoa";
040:            public static final int CONFIG_CHAR_LIMIT = 75;
041:
042:            protected Map rbMap;
043:
044:            protected DataProvider templates = null;
045:            protected List templatesList = new ArrayList();
046:            protected ObjectName objectName = null;
047:
048:            /** Creates a new instance of ListTemplatesBean*/
049:            public ListTemplatesBean() {
050:                log(Level.FINEST, "ListTemplatesBean.constructor start");
051:                // Get resource bundle
052:                rbMap = getResourceStringMap(RB_NAME);
053:
054:                // MBean path of SSOAdapter.
055:                LinkedList path = new LinkedList();
056:                path.addFirst(getDomain());
057:                path.addFirst("ssoadapter");
058:
059:                try {
060:                    objectName = AdminClientUtil.getResourceMBeanObjectName(
061:                            AdminClientUtil.SSOADAPTER_MBEAN_TYPE, path);
062:                } catch (MalformedObjectNameException e) {
063:                    log(Level.SEVERE,
064:                            "ListTemplatesBean.constructor: Exception when"
065:                                    + " getting MBean object name", e);
066:                }
067:                resetTemplateNames();
068:            }
069:
070:            public DataProvider getTemplates() {
071:                return templates;
072:            }
073:
074:            public void setTemplates(DataProvider templates) {
075:                this .templates = templates;
076:            }
077:
078:            // Do the mbean server connection to pull the template names and associated configs
079:            // NOTE: Configs no longer needed due to UI review
080:            // The config list character limit is set by CONFIG_CHAR_LIMIT  
081:            // Will also reset the data object to reflect the template names
082:            protected void resetTemplateNames() {
083:                log(Level.FINEST, "ListTemplatesBean.resetTemplateNames start");
084:                List tNames = null;
085:                // SSOA templates names are returned by SSOAdapter MBean method resetTemplateNames
086:                MBeanServerConnection conn = getMBeanServerConnection();
087:                try {
088:                    // This can throw AttributeNotFoundException, MBeanException, InstanceNotFoundException
089:                    // ReflectionException, RuntimeOperationsException, or IOException
090:                    tNames = (List) conn.getAttribute(objectName,
091:                            "TemplateNames");
092:                } catch (Exception ex) {
093:                    log(
094:                            Level.SEVERE,
095:                            "ListTemplatesBean.resetTemplateNames: Exception when trying to get the list of templates",
096:                            ex);
097:                }
098:                //Map configs = getGlobalConfigs();
099:                templatesList = new ArrayList(tNames.size());
100:                Iterator iter = tNames.iterator();
101:                while (iter.hasNext()) {
102:                    String name = (String) iter.next();
103:                    //templatesList.add(new TemplateNameBean(name, (String) configs.get(name))); // See note in comment
104:                    templatesList.add(new TemplateNameBean(name));
105:                }
106:                templates = new ObjectListDataProvider(templatesList);
107:            }
108:
109:            // Return a Map of global configurations.  Template basis is the key, an
110:            // alphabetical comma-seperated list of configuration names is the value.
111:            protected Map getGlobalConfigs() {
112:                Map configs = null;
113:                log(Level.FINEST, "Getting global configurations");
114:                MBeanServerConnection conn = getMBeanServerConnection();
115:                try {
116:                    // This can throw AttributeNotFoundException, MBeanException, InstanceNotFoundException
117:                    // ReflectionException, RuntimeOperationsException, or IOException
118:                    String[] signature = { String.class.getName() };
119:                    Object[] params = { GLOBAL_LOCATION_DN };
120:                    MBeanServerConnection connection = getMBeanServerConnection();
121:                    // This can throw AttributeNotFoundException, MBeanException, InstanceNotFoundException
122:                    // ReflectionException, RuntimeOperationsException, or IOException
123:                    configs = (Map) connection.invoke(objectName,
124:                            "getConfigurationNamesByDn", params, signature);
125:                } catch (Exception ex) {
126:                    log(
127:                            Level.SEVERE,
128:                            "ListTemplatesBean.getGlobalConfigs(): Exception when trying to get the list of configurations",
129:                            ex);
130:                    configs = new HashMap();
131:                }
132:                HashMap returnConfigs = new HashMap(configs.size());
133:                Set names = configs.keySet();
134:                Iterator iter = names.iterator();
135:                while (iter.hasNext()) {
136:                    String name = (String) iter.next();
137:                    String basis = (String) configs.get(name);
138:                    // Invert map to have basis as the key and an arraylist of configs as the value
139:                    if (returnConfigs.containsKey(basis)) {
140:                        // Add this to the list
141:                        List values = (List) returnConfigs.get(basis);
142:                        values.add(name);
143:                    } else {
144:                        List values = new ArrayList();
145:                        values.add(name);
146:                        returnConfigs.put(basis, values);
147:                    }
148:                }
149:                // Sort each basis' config list and create a comma-seperated list that
150:                // doesn't exceed CONFIG_CHAR_LIMIT
151:                names = returnConfigs.keySet();
152:                iter = names.iterator();
153:                while (iter.hasNext()) {
154:                    String basis = (String) iter.next();
155:                    List values = (List) returnConfigs.get(basis);
156:                    Collections.sort(values);
157:                    StringBuffer listSB = new StringBuffer();
158:                    for (int i = 0; i < values.size(); i++) {
159:                        String config = (String) values.get(i);
160:                        if (i > 0)
161:                            listSB.append(", ");
162:                        if ((config.length() + listSB.length()) > CONFIG_CHAR_LIMIT) {
163:                            listSB.append("...");
164:                            break;
165:                        }
166:                        listSB.append(config);
167:                    }
168:                    //log(Level.FINEST, "ListTemplatesBean.getGlobalConfigs: setting "+basis+" to "+listSB.toString());
169:                    returnConfigs.put(basis, listSB.toString());
170:                }
171:                return returnConfigs;
172:            }
173:
174:            public String gotoTemplateHome() {
175:                HttpServletRequest req = (HttpServletRequest) FacesContext
176:                        .getCurrentInstance().getExternalContext().getRequest();
177:                String templateId = (String) req
178:                        .getParameter(ATTR_SELECTED_TEMPLATE);
179:                setSessionAttribute(ATTR_SELECTED_TEMPLATE, templateId);
180:                log(Level.FINEST, "ListTemplatesBean.gotoTemplateHome: go to "
181:                        + templateId);
182:                return "gotoTemplateHome";
183:            }
184:
185:            public String gotoCreateTemplate() {
186:                String templateId = (String) RadioButton.getSelected("rb");
187:                //        List selectedcbs = Checkbox.getSelected("checkbox");
188:                //if (templateId != null){
189:                //		if ((selectedcbs != null) && (selectedcbs.size() > 0)) {
190:                //			String templateId = (String) selectedcbs.get(0);
191:                setSessionAttribute(ATTR_SELECTED_TEMPLATE, templateId);
192:                //		}
193:                return "gotoCreateTemplate";
194:            }
195:
196:            public String gotoConfigurationsByTemplateHome() {
197:                String templateId = (String) RadioButton.getSelected("rb");
198:                //List selectedcbs = Checkbox.getSelected("checkbox");
199:                //if ((selectedcbs != null) && (selectedcbs.size() > 0)) {
200:                //String templateId = (String) selectedcbs.get(0);
201:                setSessionAttribute(ATTR_SELECTED_TEMPLATE, templateId);
202:                log(Level.FINEST,
203:                        "ListTemplatesBean.gotoConfigurationsByTemplateHome: go to "
204:                                + templateId);
205:                //}
206:                return "gotoConfigurationsByTemplateHome";
207:            }
208:
209:            public String gotoConfigurationsByDnHome() {
210:                HttpServletRequest req = (HttpServletRequest) FacesContext
211:                        .getCurrentInstance().getExternalContext().getRequest();
212:                String configDn = (String) req
213:                        .getParameter(ATTR_CURRENT_LOCATION_DN);
214:                if (configDn != null) {
215:                    setCurrentDN(configDn);
216:                }
217:                return "gotoConfigurationsByDnHome";
218:            }
219:
220:            public void createTemplate() {
221:                log(Level.FINEST, "ListTemplatesBean.createTemplate start");
222:            }
223:
224:            /*	public void deleteTemplates(){
225:             List selectedcbs = Checkbox.getSelected("checkbox");
226:             for (Iterator i=selectedcbs.iterator();i.hasNext();){
227:             deleteTemplate((String) i.next());
228:             }
229:             resetTemplateNames();
230:             }*/
231:
232:            //	private void deleteTemplate(String name) {
233:            public void deleteTemplate() {
234:                log(Level.FINEST, "ListTemplatesBean.deleteTemplate start");
235:                // RadioButton.getSelected(String groupName) is
236:                // a static convenience method that obtains the 
237:                // selected radio button value from the request map
238:                // ONLY when the radio button is part of a group.
239:                //
240:                String name = (String) RadioButton.getSelected("rb");
241:                log(Level.FINEST,
242:                        "ListTemplatesBean.deleteTemplate: Deleting template "
243:                                + name);
244:                if ((name == null) || (name.length() == 0)) {
245:                    log(Level.WARNING,
246:                            "ListTemplatesBean.deleteTemplate: Template name is invalid");
247:                    return;
248:                }
249:                try {
250:                    String[] signature = { String.class.getName() };
251:                    Object[] params = { name };
252:                    MBeanServerConnection connection = getMBeanServerConnection();
253:                    // This can throw AttributeNotFoundException, MBeanException, InstanceNotFoundException
254:                    // ReflectionException, RuntimeOperationsException, or IOException
255:                    connection.invoke(objectName, "deleteTemplate", params,
256:                            signature);
257:                } catch (Exception ex) {
258:                    log(Level.SEVERE,
259:                            "ListTemplatesBean.deleteTemplate: Exception when attempting to delete "
260:                                    + name, ex);
261:                }
262:                resetTemplateNames();
263:            }
264:
265:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.