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


001:        /**
002:         * $Id: ConfiguredProducerBean.java,v 1.9 2006/03/02 12:21:28 pa157442 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.wsrp.consumer;
014:
015:        import java.text.DateFormat;
016:        import java.util.ArrayList;
017:        import java.util.Collections;
018:        import java.util.Date;
019:        import java.util.HashMap;
020:        import java.util.HashSet;
021:        import java.util.List;
022:        import java.util.Locale;
023:        import java.util.Map;
024:        import java.util.Set;
025:        import java.util.StringTokenizer;
026:        import java.util.logging.Level;
027:
028:        import javax.faces.context.FacesContext;
029:        import javax.management.ObjectName;
030:
031:        import com.sun.data.provider.impl.ObjectListDataProvider;
032:        import com.sun.portal.admin.common.AttrOptionConstants;
033:        import com.sun.portal.admin.common.util.AdminUtil;
034:        import com.sun.web.ui.model.Option;
035:
036:        public class ConfiguredProducerBean extends ConsumerBaseBean implements 
037:                CPAttributes {
038:
039:            public static final String DISABLED = "Disabled";
040:            private String id = null;
041:            private DateFormat df = null;
042:            private boolean dataLoaded = false;
043:            private String name = null;
044:            private Option[] statusOptions = null;
045:            private String status = null;
046:            private String identityPropagationType = null;
047:            private String wsdlURL = null;
048:            private String lastUpdated = null;
049:            private Option[] allRoles = null;
050:            private ObjectListDataProvider userCategoryMapping = null;
051:            private boolean registrationRequired = false;
052:            private String handle = null;
053:            private ObjectListDataProvider registrationProperties = null;
054:
055:            public ConfiguredProducerBean() {
056:                id = (String) getSessionAttribute(ATTR_SELECTED_CONFIGURED_PRODUCER);
057:                Locale l = FacesContext.getCurrentInstance().getViewRoot()
058:                        .getLocale();
059:                df = DateFormat.getDateTimeInstance(DateFormat.FULL,
060:                        DateFormat.FULL, l);
061:            }
062:
063:            public String getName() {
064:                if (!dataLoaded) {
065:                    loadData();
066:                }
067:
068:                return name;
069:            }
070:
071:            public Option[] getStatusOptions() {
072:                if (statusOptions == null) {
073:                    statusOptions = new Option[] {
074:                            new Option(ENABLED, rb
075:                                    .getString("generic.label.enabled")),
076:                            new Option(DISABLED, rb
077:                                    .getString("generic.label.disabled")) };
078:                }
079:
080:                return statusOptions;
081:            }
082:
083:            public String getStatus() {
084:                if (!dataLoaded) {
085:                    loadData();
086:                }
087:
088:                return status;
089:            }
090:
091:            public void setStatus(String status) {
092:                this .status = status;
093:            }
094:
095:            public String getIdentityPropagationType() {
096:                if (!dataLoaded) {
097:                    loadData();
098:                }
099:
100:                return identityPropagationType;
101:            }
102:
103:            public String getWSDLURL() {
104:                if (!dataLoaded) {
105:                    loadData();
106:                }
107:
108:                return wsdlURL;
109:            }
110:
111:            public String getServiceDescriptionLastUpdated() {
112:                if (!dataLoaded) {
113:                    loadData();
114:                }
115:
116:                return lastUpdated;
117:            }
118:
119:            public void updateServiceDescription() {
120:                // MBean path of ConfiguredProducer.
121:                List path = getConfiguredProducerPath();
122:
123:                try {
124:                    ObjectName objectName = AdminUtil
125:                            .getResourceMBeanObjectName(
126:                                    CONFIGURED_PRODUCER_TYPE, path);
127:
128:                    String[] signature = { String.class.getName(),
129:                            String.class.getName() };
130:
131:                    Object[] params = { getCurrentDN(), id };
132:
133:                    getMBeanServerConnection().invoke(objectName,
134:                            "updateServiceDescription", params, signature);
135:
136:                    loadData();
137:                    showAlert();
138:                    setAlertType(INFORMATION);
139:                    setAlertSummary(rb
140:                            .getString("configuredProducer.updateSD.success.summary"));
141:                    setAlertDetail(rb
142:                            .getString("configuredProducer.updateSD.success.detail"));
143:                } catch (Exception e) {
144:                    log(
145:                            Level.SEVERE,
146:                            "ConfiguredProducerBean.updateServiceDescription()",
147:                            e);
148:                    showAlert();
149:                    setAlertType(WARNING);
150:                    setAlertSummary(rb
151:                            .getString("configuredProducer.updateSD.failed.summary"));
152:                    setAlertDetail(rb
153:                            .getString("configuredProducer.updateSD.failed.detail"));
154:                }
155:            }
156:
157:            public Option[] getAllRoles() {
158:                if (!dataLoaded) {
159:                    loadData();
160:                }
161:
162:                return allRoles;
163:            }
164:
165:            public int getListBoxRows() {
166:                int rows = 0;
167:
168:                if (allRoles != null) {
169:                    rows = allRoles.length;
170:                }
171:
172:                if (rows > 12) {
173:                    rows = 12;
174:                }
175:
176:                return rows;
177:            }
178:
179:            public ObjectListDataProvider getUserCategoryMapping() {
180:                if (!dataLoaded) {
181:                    loadData();
182:                }
183:
184:                if (userCategoryMapping == null) {
185:                    userCategoryMapping = new ObjectListDataProvider(
186:                            Collections.EMPTY_LIST);
187:                    userCategoryMapping.setObjectType(SimpleUCMBean.class);
188:                }
189:
190:                return userCategoryMapping;
191:            }
192:
193:            public void setUserCategoryMapping(
194:                    ObjectListDataProvider userCategoryMapping) {
195:                this .userCategoryMapping = userCategoryMapping;
196:            }
197:
198:            public boolean isRegistrationRequired() {
199:                if (!dataLoaded) {
200:                    loadData();
201:                }
202:
203:                return registrationRequired;
204:            }
205:
206:            public String getHandle() {
207:                if (!dataLoaded) {
208:                    loadData();
209:                }
210:
211:                return handle;
212:            }
213:
214:            public ObjectListDataProvider getRegistrationProperties() {
215:                if (!dataLoaded) {
216:                    loadData();
217:                }
218:
219:                if (registrationProperties == null) {
220:                    registrationProperties = new ObjectListDataProvider(
221:                            Collections.EMPTY_LIST);
222:                    registrationProperties.setObjectType(SimpleRPBean.class);
223:                }
224:
225:                return registrationProperties;
226:            }
227:
228:            public void setRegistrationProperties(
229:                    ObjectListDataProvider registrationProperties) {
230:                this .registrationProperties = registrationProperties;
231:            }
232:
233:            public String ok() {
234:                Map optionsMap = new HashMap();
235:                optionsMap.put(AttrOptionConstants.OPT_COMPONENT, COMPONENT);
236:                optionsMap.put(AttrOptionConstants.OPT_DN, getCurrentDN());
237:                optionsMap.put("producer", id);
238:                Map nameValues = new HashMap();
239:                String enabledString = Boolean.toString(ENABLED.equals(status));
240:                nameValues.put(ENABLED, Collections
241:                        .singletonList(enabledString));
242:
243:                if (registrationProperties.getRowCount() > 0) {
244:                    List rps = new ArrayList();
245:                    registrationProperties.commitChanges();
246:                    List rpList = registrationProperties.getList();
247:
248:                    for (int i = 0; i < rpList.size(); i++) {
249:                        SimpleRPBean registrationProperty = (SimpleRPBean) rpList
250:                                .get(i);
251:                        String name = registrationProperty.getName();
252:                        String value = registrationProperty.getPropValue();
253:                        rps.add(name + "=" + value);
254:                    }
255:
256:                    nameValues.put(REGISTRATION_PROPERTIES, rps);
257:                }
258:
259:                if (userCategoryMapping.getRowCount() > 0) {
260:                    List ucms = new ArrayList();
261:                    userCategoryMapping.commitChanges();
262:                    List ucList = userCategoryMapping.getList();
263:
264:                    for (int i = 0; i < ucList.size(); i++) {
265:                        StringBuffer sb = new StringBuffer();
266:                        SimpleUCMBean ucm = (SimpleUCMBean) ucList.get(i);
267:                        sb.append(ucm.getUserCategory());
268:                        sb.append("^");
269:                        String[] roles = ucm.getRoles();
270:
271:                        if ((roles != null) && roles.length > 0) {
272:                            sb.append(roles[0]);
273:
274:                            for (int j = 1; j < roles.length; j++) {
275:                                sb.append("|");
276:                                sb.append(roles[j]);
277:                            }
278:                        }
279:
280:                        ucms.add(sb.toString());
281:                    }
282:
283:                    nameValues.put(USER_CATEGORY_MAPPING, ucms);
284:                }
285:
286:                String[] signature = { Map.class.getName(), Map.class.getName() };
287:                Object[] params = { nameValues, optionsMap };
288:
289:                try {
290:                    ObjectName objectName = AdminUtil.getPortalMBeanObjectName(
291:                            getDomain(), portalID);
292:
293:                    getMBeanServerConnection().invoke(objectName,
294:                            "setAttributes", params, signature);
295:
296:                    return "success";
297:                } catch (Exception e) {
298:                    log(Level.SEVERE, "ConfiguredProducerBean.ok()", e);
299:                    showAlert();
300:                    setAlertType(WARNING);
301:                    setAlertSummary(rb.getString("generic.save.failed.summary"));
302:                    setAlertDetail(rb.getString("generic.save.failed.detail"));
303:                    return "failed";
304:                }
305:            }
306:
307:            public String cancel() {
308:                return "success";
309:            }
310:
311:            private void loadData() {
312:                Set names = new HashSet();
313:                names.add(NAME);
314:                names.add(ENABLED);
315:                names.add(WSDL_URL);
316:                names.add(SERVICE_DESC_LAST_MOD);
317:                names.add(ALL_ROLES);
318:                names.add(USER_CATEGORY_DESCRIPTIONS);
319:                names.add(USER_CATEGORY_MAPPING);
320:                names.add(REGISTRATION_REQUIRED);
321:                names.add(REGISTRATION_HANDLE);
322:                names.add(REGISTRATION_PROPERTY_DESCRIPTION);
323:                names.add(REGISTRATION_PROPERTIES);
324:                names.add(IDENTITY_PROPAGATION_TYPE);
325:                Map optionsMap = new HashMap();
326:                optionsMap.put(AttrOptionConstants.OPT_COMPONENT, COMPONENT);
327:                optionsMap.put(AttrOptionConstants.OPT_DN, getCurrentDN());
328:                optionsMap.put("producer", id);
329:                optionsMap.put(AttrOptionConstants.OPT_ATTR_NAMES, names);
330:                String[] signature = { Map.class.getName() };
331:                Object[] params = { optionsMap };
332:
333:                try {
334:                    ObjectName objectName = AdminUtil.getPortalMBeanObjectName(
335:                            getDomain(), portalID);
336:
337:                    Map props = (Map) getMBeanServerConnection().invoke(
338:                            objectName, "getAttributes", params, signature);
339:
340:                    name = (String) ((List) props.get(NAME)).get(0);
341:                    String enabledString = (String) ((List) props.get(ENABLED))
342:                            .get(0);
343:                    boolean enabled = Boolean.valueOf(enabledString)
344:                            .booleanValue();
345:                    status = enabled ? ENABLED : DISABLED;
346:                    wsdlURL = (String) ((List) props.get(WSDL_URL)).get(0);
347:                    lastUpdated = (String) ((List) props
348:                            .get(SERVICE_DESC_LAST_MOD)).get(0);
349:                    List roleList = (List) props.get(ALL_ROLES);
350:                    allRoles = new Option[roleList.size()];
351:
352:                    for (int i = 0; i < roleList.size(); i++) {
353:                        String role = (String) roleList.get(i);
354:                        int index = role.indexOf(":");
355:                        String roleDN = role.substring(0, index);
356:                        String roleDNDisplayString = role.substring(index + 1);
357:                        allRoles[i] = new Option(roleDN, roleDNDisplayString);
358:                    }
359:
360:                    List ucds = (List) props.get(USER_CATEGORY_DESCRIPTIONS);
361:                    List ucms = (List) props.get(USER_CATEGORY_MAPPING);
362:                    userCategoryMapping = getUCM(ucds, ucms);
363:                    String requiredString = (String) ((List) props
364:                            .get(REGISTRATION_REQUIRED)).get(0);
365:                    registrationRequired = Boolean.valueOf(requiredString)
366:                            .booleanValue();
367:                    handle = (String) ((List) props.get(REGISTRATION_HANDLE))
368:                            .get(0);
369:                    List rpds = (List) props
370:                            .get(REGISTRATION_PROPERTY_DESCRIPTION);
371:                    List rps = (List) props.get(REGISTRATION_PROPERTIES);
372:                    registrationProperties = getRPs(rpds, rps);
373:                    identityPropagationType = rb
374:                            .getString((String) ((List) props
375:                                    .get(IDENTITY_PROPAGATION_TYPE)).get(0));
376:                } catch (Exception e) {
377:                    log(Level.SEVERE, "ConfiguredProducerBean.loadData()", e);
378:                    showAlert();
379:                    setAlertType(ERROR);
380:                    setAlertSummary(rb
381:                            .getString("configuredProducer.load.failed.summary"));
382:                    setAlertDetail(rb
383:                            .getString("configuredProducer.load.failed.detail"));
384:                }
385:
386:                dataLoaded = true;
387:            }
388:
389:            private ObjectListDataProvider getUCM(List ucds, List ucms) {
390:                List ucList = new ArrayList(ucds.size());
391:
392:                for (int i = 0; i < ucds.size(); i++) {
393:                    String ucd = (String) ucds.get(i);
394:                    int index = ucd.lastIndexOf("=");
395:                    String uc = ucd.substring(0, index);
396:                    String description = ucd.substring(index + 1);
397:                    String ucPlusEqualSign = uc + "=";
398:                    String roles = "";
399:
400:                    for (int j = 0; j < ucms.size(); j++) {
401:                        String ucm = (String) ucms.get(j);
402:
403:                        if (ucm.startsWith(ucPlusEqualSign)) {
404:                            roles = ucm.substring(ucPlusEqualSign.length());
405:                            break;
406:                        }
407:                    }
408:
409:                    SimpleUCMBean userCategory = new SimpleUCMBean();
410:                    userCategory.setUserCategory(uc);
411:                    StringTokenizer st = new StringTokenizer(roles, "|");
412:                    userCategory.setRoles((String[]) Collections.list(st)
413:                            .toArray(new String[0]));
414:                    userCategory.setDescription(description);
415:                    ucList.add(userCategory);
416:                }
417:
418:                ObjectListDataProvider result = new ObjectListDataProvider(
419:                        ucList);
420:                result.setObjectType(SimpleUCMBean.class);
421:                return result;
422:            }
423:
424:            private ObjectListDataProvider getRPs(List rpds, List rps) {
425:                List rpList = new ArrayList(rpds.size());
426:
427:                for (int i = 0; i < rpds.size(); i++) {
428:                    String rpd = (String) rpds.get(i);
429:                    int index = rpd.indexOf("=");
430:                    String name = rpd.substring(0, index);
431:                    String description = rpd.substring(index + 1);
432:                    String namePlusEqualSign = name + "=";
433:                    String value = "";
434:
435:                    for (int j = 0; j < rps.size(); j++) {
436:                        String rp = (String) rps.get(j);
437:
438:                        if (rp.startsWith(namePlusEqualSign)) {
439:                            value = rp.substring(namePlusEqualSign.length());
440:                            break;
441:                        }
442:                    }
443:
444:                    SimpleRPBean registrationProperty = new SimpleRPBean();
445:                    registrationProperty.setName(name);
446:                    registrationProperty.setDescription(description);
447:                    registrationProperty.setPropValue(value);
448:                    rpList.add(registrationProperty);
449:                }
450:
451:                ObjectListDataProvider result = new ObjectListDataProvider(
452:                        rpList);
453:                result.setObjectType(SimpleRPBean.class);
454:                return result;
455:            }
456:        }
w__w__w_.___ja__v__a2__s__.__co_m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.