Source Code Cross Referenced for ConfigurationAttributesBean.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: ConfigurationAttributesBean.java,v 1.7 2005/10/11 16:28:58 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.util.logging.Level;
017:        import java.io.IOException;
018:
019:        import javax.faces.context.FacesContext;
020:        import javax.servlet.http.HttpServletRequest;
021:
022:        import com.sun.data.provider.DataProvider;
023:        import com.sun.data.provider.FieldKey;
024:        import com.sun.data.provider.impl.ObjectListDataProvider;
025:        import com.sun.web.ui.component.RadioButton;
026:
027:        import com.sun.portal.admin.common.util.AdminClientUtil;
028:
029:        import javax.management.ObjectName;
030:        import javax.management.MBeanServerConnection;
031:        import javax.management.MalformedObjectNameException;
032:
033:        import com.sun.portal.admin.console.common.PSBaseBean;
034:
035:        // This class should be instantiated on a request-basis
036:        public class ConfigurationAttributesBean extends PSBaseBean {
037:
038:            //	public static final String ATTR_SELECTED_CONFIG = "ssoa.config.selected";
039:            //	public static final String ATTR_SELECTED_DN = "ssoa.dn.selected";
040:
041:            private ObjectListDataProvider attributesDataProvider = null;
042:            private ObjectName objectName = null;
043:            private String name = null;
044:            private String dn = null;
045:            private String configDesc = null;
046:            private String basis = null;
047:            public static final String RB_NAME = "ssoa";
048:            protected Map rbMap;
049:
050:            /** Creates a new instance of ConfigurationAttributesBean*/
051:            public ConfigurationAttributesBean() {
052:                log(Level.FINEST,
053:                        "ConfigurationAttributesBean.constructor start");
054:                rbMap = getResourceStringMap(RB_NAME);
055:                // MBean path of SSOAdapter.
056:                LinkedList path = new LinkedList();
057:                path.addFirst(getDomain());
058:                path.addFirst("ssoadapter");
059:                try {
060:                    objectName = AdminClientUtil.getResourceMBeanObjectName(
061:                            AdminClientUtil.SSOADAPTER_MBEAN_TYPE, path);
062:                } catch (MalformedObjectNameException e) {
063:                    log(
064:                            Level.SEVERE,
065:                            "ConfigurationAttributesBean.constructor: Exception when getting MBean object name",
066:                            e);
067:                }
068:            }
069:
070:            // Reset the data values - only called when a reset is necessary. 
071:            private void resetBean() {
072:                name = (String) getSessionAttribute(ATTR_SELECTED_CONFIG);
073:                dn = (String) getSessionAttribute(ATTR_CURRENT_LOCATION_DN);
074:                log(Level.FINEST,
075:                        "ConfigurationAttributesBean.resetBean: name is "
076:                                + name + ", dn is " + dn);
077:                Map attributes = null;
078:                try {
079:                    String[] signature = { String.class.getName(),
080:                            String.class.getName() };
081:                    Object[] params = { dn, name };
082:                    MBeanServerConnection connection = getMBeanServerConnection();
083:                    // This can throw AttributeNotFoundException, MBeanException, InstanceNotFoundException
084:                    // ReflectionException, RuntimeOperationsException, or IOException
085:                    attributes = (Map) connection.invoke(objectName,
086:                            "getConfigurationProperties", params, signature);
087:                } catch (Exception ex) {
088:                    log(
089:                            Level.SEVERE,
090:                            "ConfigurationAttributesBean.resetBean: Exception when getting the list of attributes for template "
091:                                    + name, ex);
092:                }
093:                log(Level.FINEST,
094:                        "ConfigurationAttributesBean.resetBean: retrieved attributes");
095:                Set keys = attributes.keySet();
096:                log(Level.FINEST,
097:                        "ConfigurationAttributesBean.resetBean: attribute keys are: "
098:                                + keys);
099:                String[] basisArray = (String[]) attributes
100:                        .remove("configDesc");
101:                basis = (basisArray != null) ? basisArray[0] : "";
102:                String[] encoded = (String[]) attributes.remove("encoded");
103:                List encodedList = (encoded != null) ? Arrays.asList(encoded)
104:                        : Collections.EMPTY_LIST;
105:                LinkedList attributesList = new LinkedList();
106:                for (Iterator i = keys.iterator(); i.hasNext();) {
107:                    String key = (String) i.next();
108:                    String[] values = (String[]) attributes.get(key);
109:                    String value = (values != null) ? values[0] : null;
110:                    boolean encrypted = encodedList.contains(key);
111:                    AttributeBean aBean = new AttributeBean(key, value,
112:                            encrypted);
113:                    attributesList.add(aBean);
114:                }
115:                attributesDataProvider = new ObjectListDataProvider(
116:                        attributesList);
117:            }
118:
119:            public DataProvider getAttributes() {
120:                log(Level.FINEST,
121:                        "ConfigurationAttributesBean.getAttributes: Start");
122:                if (needsReset()) {
123:                    resetBean();
124:                }
125:                return attributesDataProvider;
126:            }
127:
128:            // Check if the data provider is null, or if the name or dn has changed.  Needed because
129:            // this is now a session-based bean
130:            private boolean needsReset() {
131:                if ((dn == null) || (name == null)
132:                        || (attributesDataProvider == null))
133:                    return true;
134:                if (!dn
135:                        .equals((String) getSessionAttribute(ATTR_CURRENT_LOCATION_DN)))
136:                    return true;
137:                if (!name
138:                        .equals((String) getSessionAttribute(ATTR_SELECTED_CONFIG)))
139:                    return true;
140:                // Catch the case when a template is modified after a configuration is viewed
141:                if (getSessionAttribute("resetSSOAConfigs") != null) {
142:                    log(Level.FINEST, "resetSSOAConfigs is non-null");
143:                    removeFromSession("resetSSOAConfigs");
144:                    return true;
145:                }
146:                return false;
147:            }
148:
149:            public void setAttributes(DataProvider atts) {
150:                log(Level.FINEST,
151:                        "ConfigurationAttributesBean.setAttributes: Start");
152:                this .attributesDataProvider = (ObjectListDataProvider) atts;
153:            }
154:
155:            // Per UI recommendation, go back one screen after saving
156:            public String save() {
157:                log(Level.FINEST,
158:                        "ConfigurationAttributesBean.saveAttributes: Start");
159:                attributesDataProvider.commitChanges();
160:                HashMap attMap = new HashMap();
161:                ArrayList encryptedList = new ArrayList();
162:
163:                List attList = attributesDataProvider.getList();
164:                for (int i = 0; i < attList.size(); i++) {
165:                    AttributeBean ab = (AttributeBean) attList.get(i);
166:                    String attname = ab.getName();
167:                    String value = ab.getSetting();
168:                    if ((value == null) || (value.length() == 0)) {
169:                        // Empty value set - do not put name in the return map
170:                        log(Level.FINEST,
171:                                "ConfigurationAttributesBean.saveAttributes: Skipping "
172:                                        + attname
173:                                        + " because value is null or empty");
174:                    } else {
175:                        log(Level.FINEST,
176:                                "ConfigurationAttributesBean.saveAttributes: Saving "
177:                                        + attname + "=" + value);
178:                        String[] values = { value };
179:                        attMap.put(attname, values);
180:                    }
181:                    /*
182:                    String value = (ab.getSetting()!=null)?ab.getSetting():"";
183:                    log(Level.FINEST, "ConfigurationAttributesBean.saveAttributes: saving "+ab.getName()+":"+value);
184:                    String [] values = {value};
185:                    attMap.put(ab.getName(),values);
186:                     */
187:                }
188:                try {
189:                    String[] signature = { String.class.getName(),
190:                            String.class.getName(), Map.class.getName() };
191:                    Object[] params = { dn, name, attMap };
192:                    MBeanServerConnection connection = getMBeanServerConnection();
193:                    // This can throw AttributeNotFoundException, MBeanException, InstanceNotFoundException
194:                    // ReflectionException, RuntimeOperationsException, or IOException
195:                    connection.invoke(objectName, "setConfigurationProperties",
196:                            params, signature);
197:                } catch (Exception ex) {
198:                    log(
199:                            Level.SEVERE,
200:                            "ConfigurationAttributesBean.saveTemplate: Exception when saving the attributes for template "
201:                                    + name, ex);
202:                }
203:                return cancel();
204:            }
205:
206:            /*	public String addAttribute() {
207:             return "addAttribute";
208:             }
209:             public void removeAttribute() {
210:             String name = (String)RadioButton.getSelected("rb"); 
211:             log(Level.FINEST, "ConfigurationAttributesBean.removeAttribute: Selected attribute "+name);
212:             // Check admin, then user
213:             boolean found = false;
214:             List aal = attributesDataProvider.getList();
215:             for (int i=0; i<aal.size(); i++) {
216:             AttributeBean ab = (AttributeBean) aal.get(i);
217:             if (ab.getName().equals(name)){
218:             log(Level.FINEST, "ConfigurationAttributesBean.removeAttribute: Found "+name);
219:             aal.remove(i);
220:             found=true;
221:             }
222:             }
223:             if (!found){
224:             log(Level.WARNING, "ConfigurationAttributesBean.removeAttribute: Attempted to remove non-existant attribute "+name);
225:             } else {
226:             saveAttributes();
227:             }
228:             }
229:             */
230:            public String getName() {
231:                return name;
232:            }
233:
234:            public String getDn() {
235:                return dn;
236:            }
237:
238:            public String getDnLabel() {
239:                if (GLOBAL_LOCATION_DN.equals(dn)) {
240:                    return (String) rbMap.get("ssoa.global.dn.label");
241:                }
242:                return dn;
243:            }
244:
245:            public String getBasis() {
246:                return basis;
247:            }
248:
249:            public String cancel() {
250:                return "cancel";
251:            }
252:
253:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.