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


001:        /**
002:         * $Id: DesktopAttributesBean.java,v 1.18 2006/09/11 22:32:11 bustamam 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.desktop;
014:
015:        import java.util.logging.Level;
016:        import java.util.List;
017:        import java.util.ArrayList;
018:        import java.util.ListIterator;
019:        import java.util.Map;
020:        import java.util.HashMap;
021:        import java.util.Set;
022:        import java.util.HashSet;
023:        import java.util.Iterator;
024:        import java.util.StringTokenizer;
025:        import javax.management.ObjectName;
026:        import javax.management.MBeanException;
027:        import javax.management.ReflectionException;
028:        import javax.management.MalformedObjectNameException;
029:
030:        import com.sun.web.ui.model.Option;
031:        import com.sun.web.ui.component.Checkbox;
032:        import com.sun.data.provider.RowKey;
033:        import com.sun.data.provider.DataProvider;
034:        import com.sun.data.provider.impl.ObjectListDataProvider;
035:        import com.sun.portal.admin.console.common.PSBaseBean;
036:        import com.sun.portal.admin.common.util.AdminUtil;
037:        import com.sun.portal.admin.common.DesktopConstants;
038:        import com.sun.portal.admin.common.AttrOptionConstants;
039:        import com.sun.portal.admin.common.PSMBeanException;
040:
041:        import com.sun.web.ui.model.Option;
042:
043:        import javax.faces.context.FacesContext;
044:        import javax.faces.el.VariableResolver;
045:
046:        /**
047:         * @author rt94277
048:         * This bean handles the Service Attributes page on Desktop tab.
049:         */
050:        public class DesktopAttributesBean extends PSBaseBean implements 
051:                DesktopConstants {
052:            public static final String RB_NAME = "desktop";
053:            public static final String COMPONENT = "desktop";
054:            private ObjectName objName = null;
055:            private Map attrValues = null;
056:            private Set attrNames = null;
057:            private Set globalAttrNames = null;
058:            private Map optionsMap = new HashMap();
059:            private Map nameValues = new HashMap();
060:            private Map globalNameValues = new HashMap();
061:            private List uidObjectList = new ArrayList();
062:            private String locationDN = null;
063:
064:            //global attributes
065:            private boolean enableFederation = false;
066:            private boolean disableAuthlessForFederated = true;
067:            private String hostedProviderID = "";
068:            private String maxClientSessions = "";
069:            private String clientSessionReapInterval = "";
070:            private String clientSessionMaxInactive = "";
071:            private boolean enableXMLValidation = false;
072:            private boolean enableAuthless = false;
073:
074:            //dynamic attributes
075:            private String defaultChannelName = "";
076:            private String editChannelName = "";
077:            private String desktopType = "";
078:            private boolean showPortalDesktopAttr = false;
079:
080:            //dp priority
081:            private String dpPriority = "";
082:            private boolean dpPriorityChanged = false;
083:
084:            //am conflict resolution level
085:            private String cosPriority = "0";
086:            private Option[] cosValues = null;
087:
088:            private boolean pendingChanges = false;
089:
090:            private boolean alert;
091:            private String alertSummary;
092:            private String alertDetail;
093:            private String alertType;
094:
095:            public DesktopAttributesBean() {
096:                locationDN = (String) getCurrentDN();
097:                log(Level.FINEST, "Current DN: " + locationDN);
098:
099:                //initialize am cos values
100:                cosValues = new Option[7];
101:                cosValues[0] = new Option("0", (String) getLocalizedString(
102:                        "desktop", "svcattr.amcos.value.highest"));
103:                cosValues[1] = new Option("1", (String) getLocalizedString(
104:                        "desktop", "svcattr.amcos.value.higher"));
105:                cosValues[2] = new Option("2", (String) getLocalizedString(
106:                        "desktop", "svcattr.amcos.value.high"));
107:                cosValues[3] = new Option("3", (String) getLocalizedString(
108:                        "desktop", "svcattr.amcos.value.medium"));
109:                cosValues[4] = new Option("4", (String) getLocalizedString(
110:                        "desktop", "svcattr.amcos.value.low"));
111:                cosValues[5] = new Option("5", (String) getLocalizedString(
112:                        "desktop", "svcattr.amcos.value.lower"));
113:                cosValues[6] = new Option("6", (String) getLocalizedString(
114:                        "desktop", "svcattr.amcos.value.lowest"));
115:
116:                //get MBean Object name
117:                objName = getMBeanObjectName();
118:
119:                initAttributeNames();
120:
121:            }
122:
123:            public void initAttributeNames() {
124:                attrNames = new HashSet();
125:                //dynamic attributes
126:                attrNames.add(DESKTOP_TYPE);
127:                attrNames.add(EDIT_CHANNEL);
128:                attrNames.add(DEFAULT_CHANNEL);
129:
130:                //global attributes
131:                globalAttrNames = new HashSet();
132:                globalAttrNames.add(ENABLE_AUTHLESS);
133:                globalAttrNames.add(ENABLE_FEDERATION);
134:                globalAttrNames.add(HOSTED_PROVIDER_ID);
135:                globalAttrNames.add(MAX_CLIENT_SESSION);
136:                globalAttrNames.add(ENABLE_XML_VALIDATION);
137:                globalAttrNames.add(CLIENT_SESSION_REAP_INTV);
138:                globalAttrNames.add(CLIENT_SESSION_MAX_INACTIVE);
139:                globalAttrNames.add(DIS_AUTHLESS_FOR_FEDERATED_USERS);
140:                globalAttrNames.addAll(attrNames);
141:
142:            }
143:
144:            //get service attribute values from backend.
145:            public void initAttributeValues() {
146:                optionsMap.put(AttrOptionConstants.OPT_COMPONENT, COMPONENT);
147:                optionsMap.put("operation", "get");
148:                log(Level.FINEST,
149:                        "Initializing Desktop Attribute Values for DN= "
150:                                + getCurrentDN());
151:
152:                if (getIsDynamic()) {
153:                    attrNames.add(SHOW_DESKTOP_ATTRIBUTE);
154:                    attrNames.add(COS_PRIORITY);
155:                }
156:                if (getIsGlobal()) {
157:                    optionsMap.put(AttrOptionConstants.OPT_ATTR_NAMES,
158:                            globalAttrNames);
159:                    if (optionsMap.containsKey(AttrOptionConstants.OPT_DN)) {
160:                        optionsMap.remove(AttrOptionConstants.OPT_DN);
161:                    }
162:                } else {
163:                    optionsMap.put(AttrOptionConstants.OPT_ATTR_NAMES,
164:                            attrNames);
165:                    optionsMap.put(AttrOptionConstants.OPT_DN, getCurrentDN());
166:                }
167:                // Setting the params and signature
168:                Object[] params = { optionsMap };
169:                String[] signature = { "java.util.Map" };
170:                try {
171:                    attrValues = (Map) getMBeanServerConnection().invoke(
172:                            objName, "getAttributes", params, signature);
173:                    log(Level.FINEST,
174:                            "Desktop Attribute Values from Mbean call="
175:                                    + attrValues);
176:
177:                } catch (MBeanException me) {
178:                    log(
179:                            Level.SEVERE,
180:                            "Exception in DesktopAttributesBean.initAttributeValues()",
181:                            me);
182:                } catch (ReflectionException re) {
183:                    log(
184:                            Level.SEVERE,
185:                            "Exception in DesktopAttributesBean.initAttributeValues()",
186:                            re);
187:                } catch (Exception e) {
188:                    log(
189:                            Level.SEVERE,
190:                            "Exception in DesktopAttributesBean.initAttributeValues()",
191:                            e);
192:                }
193:                defaultChannelName = getStringValueFromList(DEFAULT_CHANNEL);
194:                editChannelName = getStringValueFromList(EDIT_CHANNEL);
195:                desktopType = getStringValueFromList(DESKTOP_TYPE);
196:                if (getIsDynamic()) {
197:                    showPortalDesktopAttr = getBooleanValueFromList(SHOW_DESKTOP_ATTRIBUTE);
198:                    Integer cp = getIntegerValueFromList(COS_PRIORITY);
199:                    if (cp == null) {
200:                        cosPriority = "0";
201:                    } else {
202:                        cosPriority = cp.toString();
203:                    }
204:                }
205:                if (getIsGlobal()) {
206:                    hostedProviderID = getStringValueFromList(HOSTED_PROVIDER_ID);
207:                    maxClientSessions = getStringValueFromList(MAX_CLIENT_SESSION);
208:                    clientSessionReapInterval = getStringValueFromList(CLIENT_SESSION_REAP_INTV);
209:                    clientSessionMaxInactive = getStringValueFromList(CLIENT_SESSION_MAX_INACTIVE);
210:                    enableXMLValidation = getBooleanValueFromList(ENABLE_XML_VALIDATION);
211:                    enableFederation = getBooleanValueFromList(ENABLE_FEDERATION);
212:                    disableAuthlessForFederated = getBooleanValueFromList(DIS_AUTHLESS_FOR_FEDERATED_USERS);
213:                    enableAuthless = getBooleanValueFromList(ENABLE_AUTHLESS);
214:                }
215:
216:                //init DP Priority
217:                // Get the Domain MBean object
218:                try {
219:                    ObjectName dpObjName = AdminUtil
220:                            .getDisplayProfileMBeanObjectName(
221:                                    AdminUtil.DEFAULT_DOMAIN, getPortalId());
222:                    // Invoke the get method on the portal Desktop MBean
223:                    // Setting the params and signature
224:                    Object[] dpParams = { getCurrentDN() };
225:                    String[] dpSignature = { "java.lang.String" };
226:                    dpPriority = (String) getMBeanServerConnection().invoke(
227:                            dpObjName, "getDPPriority", dpParams, dpSignature);
228:                    log(Level.FINEST, "DP priority=" + dpPriority);
229:                } catch (Exception e) {
230:                    log(
231:                            Level.SEVERE,
232:                            "DesktopAttributesBean.initAttributeValues(): exception getting priority",
233:                            e);
234:                }
235:                pendingChanges = false;
236:            }
237:
238:            public Option[] getCosValues() {
239:                return cosValues;
240:            }
241:
242:            public String getCosPriority() {
243:                //reinitialize if attrValues is null
244:                //(first initialization for the request)
245:                //if DN Changed
246:                //if pendingChanges 
247:                //(this is a hack to reflect the page with right values when
248:                //the page is refreshed programmatically. If a page is refreshed 
249:                //programmatically, the setters on the page gets called after the
250:                //getter calls thus setting the form values to the values from the 
251:                //previous DN. To avoid this, the values have to be reinitialized with
252:                //the current DN. Overriding the setter calls is ok because this is a
253:                //request bean and is expected to get the values from the backend per 
254:                //every request.)
255:                if (attrValues == null || isDNChanged() || pendingChanges) {
256:                    initAttributeValues();
257:                }
258:                return cosPriority;
259:            }
260:
261:            public void setCosPriority(String value) {
262:                if (value != null && !cosPriority.equals(value)) {
263:                    cosPriority = value;
264:                    nameValues.put(COS_PRIORITY,
265:                            getAttrValueAsList(cosPriority));
266:                    pendingChanges = true;
267:                }
268:            }
269:
270:            public String getDpPriority() {
271:                if (attrValues == null || isDNChanged() || pendingChanges) {
272:                    initAttributeValues();
273:                }
274:                return dpPriority;
275:            }
276:
277:            public void setDpPriority(String value) {
278:                if (!dpPriority.equals(value)) {
279:                    dpPriorityChanged = true;
280:                    dpPriority = value;
281:                    log(Level.FINEST, "priority set to=" + value);
282:                    pendingChanges = true;
283:                }
284:            }
285:
286:            public String getDefaultChannelName() {
287:                if (attrValues == null || isDNChanged() || pendingChanges) {
288:                    initAttributeValues();
289:                }
290:                return defaultChannelName;
291:            }
292:
293:            public void setDefaultChannelName(String value) {
294:                if (value != null && !defaultChannelName.equals(value)) {
295:                    defaultChannelName = value;
296:                    nameValues.put(DEFAULT_CHANNEL,
297:                            getAttrValueAsList(defaultChannelName));
298:                    pendingChanges = true;
299:                }
300:            }
301:
302:            public String getEditChannelName() {
303:                if (attrValues == null || isDNChanged() || pendingChanges) {
304:                    initAttributeValues();
305:                }
306:                return editChannelName;
307:            }
308:
309:            public void setEditChannelName(String value) {
310:                if (value != null && !editChannelName.equals(value)) {
311:                    editChannelName = value;
312:                    nameValues.put(EDIT_CHANNEL,
313:                            getAttrValueAsList(editChannelName));
314:                    pendingChanges = true;
315:                }
316:            }
317:
318:            public String getDesktopType() {
319:                if (attrValues == null || isDNChanged() || pendingChanges) {
320:                    initAttributeValues();
321:                }
322:                return desktopType;
323:            }
324:
325:            public void setDesktopType(String value) {
326:                if (value != null && !desktopType.equals(value)) {
327:                    desktopType = value;
328:                    nameValues.put(DESKTOP_TYPE,
329:                            getAttrValueAsList(desktopType));
330:                    pendingChanges = true;
331:                }
332:            }
333:
334:            public boolean getShowPortalDesktopAttr() {
335:                if (attrValues == null || isDNChanged() || pendingChanges) {
336:                    initAttributeValues();
337:                }
338:                return showPortalDesktopAttr;
339:            }
340:
341:            public void setShowPortalDesktopAttr(boolean value) {
342:                if (showPortalDesktopAttr != value) {
343:                    showPortalDesktopAttr = value;
344:                    nameValues.put(SHOW_DESKTOP_ATTRIBUTE,
345:                            getAttrValueAsList(Boolean
346:                                    .toString(showPortalDesktopAttr)));
347:                    pendingChanges = true;
348:                }
349:            }
350:
351:            public String getHostedProviderID() {
352:                if (attrValues == null || isDNChanged() || pendingChanges) {
353:                    initAttributeValues();
354:                }
355:                return hostedProviderID;
356:            }
357:
358:            public void setHostedProviderID(String value) {
359:                if (value != null && !hostedProviderID.equals(value)) {
360:                    hostedProviderID = value;
361:                    globalNameValues.put(HOSTED_PROVIDER_ID,
362:                            getAttrValueAsList(hostedProviderID));
363:                    pendingChanges = true;
364:                }
365:            }
366:
367:            public String getMaxClientSessions() {
368:                if (attrValues == null || isDNChanged() || pendingChanges) {
369:                    initAttributeValues();
370:                }
371:                return maxClientSessions;
372:            }
373:
374:            public void setMaxClientSessions(String value) {
375:                if (value != null && !maxClientSessions.equals(value)) {
376:                    maxClientSessions = value;
377:                    globalNameValues.put(MAX_CLIENT_SESSION,
378:                            getAttrValueAsList(maxClientSessions));
379:                    pendingChanges = true;
380:                }
381:            }
382:
383:            public String getClientSessionReapInterval() {
384:                if (attrValues == null || isDNChanged() || pendingChanges) {
385:                    initAttributeValues();
386:                }
387:                return clientSessionReapInterval;
388:            }
389:
390:            public void setClientSessionReapInterval(String value) {
391:                if (value != null && !clientSessionReapInterval.equals(value)) {
392:                    clientSessionReapInterval = value;
393:                    globalNameValues.put(CLIENT_SESSION_REAP_INTV,
394:                            getAttrValueAsList(clientSessionReapInterval));
395:                    pendingChanges = true;
396:                }
397:            }
398:
399:            public String getClientSessionMaxInactive() {
400:                if (attrValues == null || isDNChanged() || pendingChanges) {
401:                    initAttributeValues();
402:                }
403:                return clientSessionMaxInactive;
404:            }
405:
406:            public void setClientSessionMaxInactive(String value) {
407:                if (value != null && !clientSessionMaxInactive.equals(value)) {
408:                    clientSessionMaxInactive = value;
409:                    globalNameValues.put(CLIENT_SESSION_MAX_INACTIVE,
410:                            getAttrValueAsList(clientSessionMaxInactive));
411:                    pendingChanges = true;
412:                }
413:            }
414:
415:            public boolean getEnableXMLValidation() {
416:                if (attrValues == null || isDNChanged() || pendingChanges) {
417:                    initAttributeValues();
418:                }
419:                return enableXMLValidation;
420:            }
421:
422:            public void setEnableXMLValidation(boolean value) {
423:                if (enableXMLValidation != value) {
424:                    enableXMLValidation = value;
425:                    globalNameValues.put(ENABLE_XML_VALIDATION,
426:                            getAttrValueAsList(Boolean
427:                                    .toString(enableXMLValidation)));
428:                    pendingChanges = true;
429:                }
430:            }
431:
432:            public boolean getEnableFederation() {
433:                if (attrValues == null || isDNChanged() || pendingChanges) {
434:                    initAttributeValues();
435:                }
436:                return enableFederation;
437:            }
438:
439:            public void setEnableFederation(boolean value) {
440:                if (enableFederation != value) {
441:                    enableFederation = value;
442:                    globalNameValues.put(ENABLE_FEDERATION,
443:                            getAttrValueAsList(Boolean
444:                                    .toString(enableFederation)));
445:                    pendingChanges = true;
446:                }
447:            }
448:
449:            public boolean getEnableAuthless() {
450:                if (attrValues == null || isDNChanged() || pendingChanges) {
451:                    initAttributeValues();
452:                }
453:                return enableAuthless;
454:            }
455:
456:            public void setEnableAuthless(boolean value) {
457:                if (enableAuthless != value) {
458:                    enableAuthless = value;
459:                    globalNameValues
460:                            .put(ENABLE_AUTHLESS, getAttrValueAsList(Boolean
461:                                    .toString(enableAuthless)));
462:                    pendingChanges = true;
463:                }
464:            }
465:
466:            public boolean getDisableAuthlessForFederated() {
467:                if (attrValues == null || isDNChanged() || pendingChanges) {
468:                    initAttributeValues();
469:                }
470:                return !disableAuthlessForFederated;
471:            }
472:
473:            public void setDisableAuthlessForFederated(boolean value) {
474:                if (!disableAuthlessForFederated != value) {
475:                    disableAuthlessForFederated = !value;
476:                    globalNameValues.put(DIS_AUTHLESS_FOR_FEDERATED_USERS,
477:                            getAttrValueAsList(Boolean
478:                                    .toString(disableAuthlessForFederated)));
479:                    pendingChanges = true;
480:                }
481:            }
482:
483:            public boolean getIsGlobal() {
484:                boolean isGlobal = false;
485:                if (isGlobalDN((String) getCurrentDN())) {
486:                    isGlobal = true;
487:                } else {
488:                    isGlobal = false;
489:                }
490:                return isGlobal;
491:            }
492:
493:            public boolean getIsUser() {
494:                boolean isUser = false;
495:                if (isUserDN((String) getCurrentDN())) {
496:                    isUser = true;
497:                } else {
498:                    isUser = false;
499:                }
500:                return isUser;
501:            }
502:
503:            public boolean getIsDynamic() {
504:                boolean isDynamic = false;
505:                String dn = (String) getCurrentDN();
506:                if (isOrgDN(dn) || isRoleDN(dn) || isFilteredRoleDN(dn)) {
507:                    isDynamic = true;
508:                } else {
509:                    isDynamic = false;
510:                }
511:                return isDynamic;
512:            }
513:
514:            public void saveAttributes() {
515:                log(Level.FINEST, "Saving Changes to DN =" + getCurrentDN());
516:                optionsMap.put(AttrOptionConstants.OPT_COMPONENT, COMPONENT);
517:                optionsMap.put("operation", "set");
518:                Object[] params = new Object[2];
519:                if (getIsGlobal()) {
520:                    Iterator i = globalAttrNames.iterator();
521:                    while (i.hasNext()) {
522:                        Object name = i.next();
523:                        if (!globalNameValues.containsKey(name)) {
524:                            log(Level.FINEST, "removing attr name " + name);
525:                            i.remove();
526:                        }
527:                    }
528:                    optionsMap.put(AttrOptionConstants.OPT_ATTR_NAMES,
529:                            globalAttrNames);
530:                    if (optionsMap.containsKey(AttrOptionConstants.OPT_DN)) {
531:                        optionsMap.remove(AttrOptionConstants.OPT_DN);
532:                    }
533:
534:                    Map valueMap = new HashMap();
535:                    valueMap.putAll(globalNameValues);
536:                    valueMap.putAll(nameValues);
537:                    params[0] = valueMap;
538:                    params[1] = optionsMap;
539:                    log(Level.FINEST, "nameValueMap=" + globalNameValues);
540:                    log(Level.FINEST, "attrNames=" + globalAttrNames);
541:                } else {
542:                    Iterator i = attrNames.iterator();
543:                    while (i.hasNext()) {
544:                        Object name = i.next();
545:                        if (!nameValues.containsKey(name)) {
546:                            log(Level.FINEST, "removing attr name " + name);
547:                            i.remove();
548:                        }
549:                    }
550:                    optionsMap.put(AttrOptionConstants.OPT_ATTR_NAMES,
551:                            attrNames);
552:                    optionsMap.put(AttrOptionConstants.OPT_DN, getCurrentDN());
553:                    if (!getIsDynamic()) {
554:                        attrNames.remove(SHOW_DESKTOP_ATTRIBUTE);
555:                        nameValues.remove(SHOW_DESKTOP_ATTRIBUTE);
556:                        attrNames.remove(COS_PRIORITY);
557:                        nameValues.remove(COS_PRIORITY);
558:                    }
559:                    log(Level.FINEST, "nameValueMap=" + nameValues);
560:                    log(Level.FINEST, "attrNames=" + attrNames);
561:                    params[0] = nameValues;
562:                    params[1] = optionsMap;
563:                }
564:                // Setting the params and signature
565:                String[] signature = { "java.util.Map", "java.util.Map" };
566:                try {
567:                    getMBeanServerConnection().invoke(objName, "setAttributes",
568:                            params, signature);
569:                } catch (MBeanException me) {
570:                    log(
571:                            Level.SEVERE,
572:                            "Exception in DesktopAttributesBean.saveAttributes()",
573:                            me);
574:                    if (me.getCause() instanceof  PSMBeanException) {
575:                        PSMBeanException psmbe = (PSMBeanException) me
576:                                .getCause();
577:                        alert = true;
578:                        alertType = "information";
579:                        alertSummary = (String) getLocalizedString("desktop",
580:                                "svcattr.save.failed.summary");
581:                        alertDetail = psmbe.getMessage();
582:                    }
583:                } catch (ReflectionException re) {
584:                    log(
585:                            Level.SEVERE,
586:                            "Exception in DesktopAttributesBean.saveAttributes()",
587:                            re);
588:                    alert = true;
589:                    alertType = "error";
590:                    alertSummary = (String) getLocalizedString("desktop",
591:                            "svcattr.save.failed.summary");
592:
593:                } catch (Exception e) {
594:                    log(
595:                            Level.SEVERE,
596:                            "Exception in DesktopAttributesBean.saveAttributes()",
597:                            e);
598:                    alert = true;
599:                    alertType = "error";
600:                    alertSummary = (String) getLocalizedString("desktop",
601:                            "svcattr.save.failed.summary");
602:                }
603:                //check if dp priority changed. make an mbean call
604:                //when it is changed
605:                if (dpPriorityChanged) {
606:                    //set DP Priority
607:                    // Get the Domain MBean object
608:                    try {
609:                        ObjectName dpObjName = AdminUtil
610:                                .getDisplayProfileMBeanObjectName(
611:                                        AdminUtil.DEFAULT_DOMAIN, getPortalId());
612:                        // Invoke the get method on the portal Desktop MBean
613:                        // Setting the params and signature
614:                        if (dpPriority != null && dpPriority.length() != 0) {
615:                            Object[] dpParams = { getCurrentDN(), dpPriority };
616:                            String[] dpSignature = { "java.lang.String",
617:                                    "java.lang.String" };
618:                            getMBeanServerConnection().invoke(dpObjName,
619:                                    "setDPPriority", dpParams, dpSignature);
620:                        } else {
621:                            setupAlert(null,
622:                                    "svcattr.setpriority.failed.summary",
623:                                    "svcattr.setpriority.failed.nullpriority",
624:                                    "information");
625:                        }
626:                    } catch (MBeanException me) {
627:                        log(
628:                                Level.SEVERE,
629:                                "DesktopAttributesBean.saveAttributes(): exception setting priority",
630:                                me);
631:                        if (me.getCause() instanceof  PSMBeanException) {
632:                            PSMBeanException psmbe = (PSMBeanException) me
633:                                    .getCause();
634:                            String i18nKey = psmbe.getErrorKey();
635:                            setupAlert(null,
636:                                    "svcattr.setpriority.failed.summary",
637:                                    i18nKey, "information");
638:                        }
639:                    } catch (Exception e) {
640:                        log(
641:                                Level.SEVERE,
642:                                "DesktopAttributesBean.saveAttributes(): exception setting priority",
643:                                e);
644:                        setupAlert(null, "svcattr.setpriority.failed.summary",
645:                                null, "information");
646:                    }
647:                }
648:                //reinitializa attribute names as the attrname map is corrupted
649:                //with the removal of some keys during save.
650:                initAttributeNames();
651:                initAttributeValues();
652:                //call AuthlessUIDBean's save to save authless uids.
653:                FacesContext context = FacesContext.getCurrentInstance();
654:                VariableResolver vr = context.getApplication()
655:                        .getVariableResolver();
656:                Object obj = (Object) vr.resolveVariable(context,
657:                        "AuthlessUIDBean");
658:                boolean authlessAlert = false;
659:                if ((obj != null) && (obj instanceof  AuthlessUIDBean)) {
660:                    AuthlessUIDBean authlessbean = (AuthlessUIDBean) obj;
661:                    authlessbean.saveAttributes();
662:                    authlessAlert = authlessbean.alert;
663:                }
664:                //set alert to save success if there is no error alert.
665:                if (!alert && !authlessAlert) {
666:                    setSuccessAlert();
667:                }
668:
669:            }
670:
671:            public void resetAttributes() {
672:                initAttributeValues();
673:                //call AuthlessUIDBean's reset
674:                FacesContext context = FacesContext.getCurrentInstance();
675:                VariableResolver vr = context.getApplication()
676:                        .getVariableResolver();
677:                Object obj = (Object) vr.resolveVariable(context,
678:                        "AuthlessUIDBean");
679:                if ((obj != null) && (obj instanceof  AuthlessUIDBean)) {
680:                    AuthlessUIDBean authlessbean = (AuthlessUIDBean) obj;
681:                    authlessbean.resetAttributes();
682:                }
683:            }
684:
685:            private boolean isDNChanged() {
686:                boolean dnChanged = false;
687:                String dn = (String) getCurrentDN();
688:                if (!locationDN.equals(dn)) {
689:                    log(Level.FINEST, "changed dn:" + dn);
690:                    dnChanged = true;
691:                    locationDN = dn;
692:                }
693:                return dnChanged;
694:            }
695:
696:            private String getPortalId() {
697:                String portalID = (String) getSessionAttribute(ATTR_SELECTED_PORTAL);
698:                return portalID;
699:            }
700:
701:            private ObjectName getMBeanObjectName() {
702:                //get PortalMBean object name
703:                ObjectName objectName = null;
704:                try {
705:                    objectName = AdminUtil.getPortalMBeanObjectName(
706:                            getDomain(), getPortalId());
707:                } catch (MalformedObjectNameException e) {
708:                    //throw e;            
709:                    log(
710:                            Level.SEVERE,
711:                            "Exception in DesktopAttributesBean.getMBeanObjectName()",
712:                            e);
713:                }
714:                return objectName;
715:            }
716:
717:            public boolean isAlert() {
718:                boolean show = alert;
719:                alert = false;
720:                return show;
721:            }
722:
723:            public void setAlert(boolean value) {
724:                alert = value;
725:            }
726:
727:            public String getAlertSummary() {
728:                return alertSummary;
729:            }
730:
731:            public void setAlertSummary(String summary) {
732:                alertSummary = summary;
733:            }
734:
735:            public String getAlertDetail() {
736:                return alertDetail;
737:            }
738:
739:            public void setAlertDetail(String detail) {
740:                alertDetail = detail;
741:            }
742:
743:            public String getAlertType() {
744:                return alertType;
745:            }
746:
747:            public void setAlertType(String atype) {
748:                alertType = atype;
749:            }
750:
751:            //============================================================
752:            // Alert Utility methods
753:            //============================================================
754:
755:            public void setupAlert(String token, String summary, String detail,
756:                    String type) {
757:
758:                String sm = (String) getLocalizedString("desktop", summary);
759:                String dm = (String) getLocalizedString("desktop", detail);
760:
761:                if (token != null) {
762:                    dm = dm + token;
763:                }
764:                alert = true;
765:                setAlertSummary(sm);
766:                setAlertDetail(dm);
767:                setAlertType(type);
768:            }
769:
770:            private List getAttrValueAsList(String value) {
771:                List values = new ArrayList();
772:                values.add(value);
773:                return values;
774:            }
775:
776:            private String getStringValueFromList(String key) {
777:                String value = "";
778:                if (attrValues != null && !attrValues.isEmpty()) {
779:                    List values = (List) attrValues.get(key);
780:                    if (values != null && !values.isEmpty()) {
781:                        value = (String) values.get(0);
782:                    }
783:                }
784:                return value;
785:            }
786:
787:            private Integer getIntegerValueFromList(String key) {
788:                Integer value = null;
789:                if (attrValues != null && !attrValues.isEmpty()) {
790:                    List values = (List) attrValues.get(key);
791:                    if (values != null && !values.isEmpty()) {
792:                        value = (Integer) values.get(0);
793:                    }
794:                }
795:                return value;
796:            }
797:
798:            private boolean getBooleanValueFromList(String key) {
799:                boolean value = false;
800:                String s = "";
801:                if (attrValues != null && !attrValues.isEmpty()) {
802:                    List values = (List) attrValues.get(key);
803:                    if (values != null && !values.isEmpty()) {
804:                        s = (String) values.get(0);
805:                        value = (Boolean.valueOf(s)).booleanValue();
806:                    }
807:                }
808:                return value;
809:            }
810:
811:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.