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


001:        /**
002:         * Copyright 2005 Sun Microsystems, Inc. All
003:         * rights reserved. Use of this product is subject
004:         * to license terms. Federal Acquisitions:
005:         * Commercial Software -- Government Users
006:         * Subject to Standard License Terms and
007:         * Conditions.
008:         *
009:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
010:         * are trademarks or registered trademarks of Sun Microsystems,
011:         * Inc. in the United States and other countries.
012:         */package com.sun.portal.admin.console.subscriptions;
013:
014:        import java.util.*;
015:        import java.util.logging.Level;
016:        import java.io.*;
017:
018:        import javax.faces.context.FacesContext;
019:        import javax.faces.application.FacesMessage;
020:        import javax.faces.component.UIComponent;
021:        import javax.faces.event.*;
022:        import javax.faces.validator.*;
023:        import javax.faces.el.ValueBinding;
024:        import javax.servlet.http.HttpServletRequest;
025:        import javax.management.*;
026:
027:        import com.sun.web.ui.model.*;
028:        import com.sun.web.ui.event.*;
029:        import com.sun.web.ui.component.*;
030:
031:        import com.sun.data.provider.*;
032:        import com.sun.data.provider.impl.ObjectListDataProvider;
033:
034:        import com.sun.cacao.agent.JmxClient;
035:
036:        import com.sun.portal.admin.common.AttrOptionConstants;
037:        import com.sun.portal.admin.common.util.*;
038:        import com.sun.portal.admin.console.common.PSBaseBean;
039:
040:        public class AttributesBean extends PSBaseBean {
041:
042:            public static final String COMPONENT = "subscriptions";
043:
044:            // List of organization attributes
045:            private static final String STARTPROFILER = "StartProfiler";
046:            private static final String STOPPROFILER = "StopProfiler";
047:            private static final String PROFILERSMTP = "ProfilerSMTP";
048:            private static final String PROFILEREMAIL = "ProfilerEmail";
049:            private static final String PROFILERPROVIDER = "ProfilerProvider";
050:            private static final String PROFILERDEFAULTSEARCH = "ProfilerDefaultSearch";
051:            private static final String PROFILERMAXHITS = "ProfilerMaxHits";
052:
053:            // List of dynamic attributes
054:            private static final String MAXCATEGORYSUBSCRIPTIONS = "MaxCategorySubscriptions";
055:            private static final String MAXDISCUSSIONSUBSCRIPTIONS = "MaxDiscussionSubscriptions";
056:            private static final String MAXSAVEDSEARCH = "MaxSavedSearch";
057:
058:            // List of user attributes
059:            private static final String CATEGORYSUBSCRIPTIONS = "CategorySubscriptions";
060:            private static final String DISCUSSIONSUBSCRIPTIONS = "DiscussionSubscriptions";
061:            private static final String SAVEDSEARCH = "SavedSearch";
062:            private static final String PROFILERLASTRUN = "ProfilerLastRun";
063:            private static final String PROFILERENABLED = "ProfilerEnabled";
064:
065:            private HashSet globalAttributes = null;
066:            private HashSet orgAttributes = null;
067:            private HashSet roleAttributes = null;
068:            private HashSet userAttributes = null;
069:
070:            private HashMap globalAttributeValues = null;
071:            private HashMap orgAttributeValues = null;
072:            private HashMap roleAttributeValues = null;
073:            private HashMap userAttributeValues = null;
074:
075:            private String lastDN = null;
076:
077:            public AttributesBean() {
078:                globalAttributes = new HashSet();
079:                globalAttributes.add(MAXCATEGORYSUBSCRIPTIONS);
080:                globalAttributes.add(MAXDISCUSSIONSUBSCRIPTIONS);
081:                globalAttributes.add(MAXSAVEDSEARCH);
082:
083:                orgAttributes = new HashSet();
084:                orgAttributes.add(STARTPROFILER);
085:                orgAttributes.add(STOPPROFILER);
086:                orgAttributes.add(PROFILERSMTP);
087:                orgAttributes.add(PROFILEREMAIL);
088:                orgAttributes.add(PROFILERPROVIDER);
089:                orgAttributes.add(PROFILERDEFAULTSEARCH);
090:                orgAttributes.add(PROFILERMAXHITS);
091:                orgAttributes.add(MAXCATEGORYSUBSCRIPTIONS);
092:                orgAttributes.add(MAXDISCUSSIONSUBSCRIPTIONS);
093:                orgAttributes.add(MAXSAVEDSEARCH);
094:
095:                roleAttributes = new HashSet();
096:                roleAttributes.add(MAXCATEGORYSUBSCRIPTIONS);
097:                roleAttributes.add(MAXDISCUSSIONSUBSCRIPTIONS);
098:                roleAttributes.add(MAXSAVEDSEARCH);
099:
100:                userAttributes = new HashSet();
101:                userAttributes.add(CATEGORYSUBSCRIPTIONS);
102:                userAttributes.add(DISCUSSIONSUBSCRIPTIONS);
103:                userAttributes.add(SAVEDSEARCH);
104:                userAttributes.add(PROFILERLASTRUN);
105:                userAttributes.add(PROFILERENABLED);
106:
107:                lastDN = "";
108:            }
109:
110:            public boolean getShowError() {
111:                retrieveAttributeValues(false);
112:
113:                String value = (String) getSessionAttribute("subscriptions.showerror");
114:                if (value == null || value.equals("false")) {
115:                    return false;
116:                } else {
117:                    return true;
118:                }
119:            }
120:
121:            public Option[] getAvailableBoolean() {
122:                Option[] options = new Option[2];
123:                options[0] = new Option("enabled", getLocalizedString(
124:                        "subscriptions", "subscriptions.general.enabled"));
125:                options[1] = new Option("disabled", getLocalizedString(
126:                        "subscriptions", "subscriptions.general.disabled"));
127:                return options;
128:            }
129:
130:            public String[] getStartProfiler() {
131:                return new String[0];
132:            }
133:
134:            public void setStartProfiler(String[] values) {
135:            }
136:
137:            public boolean isRenderStartProfiler() {
138:                return false;
139:            }
140:
141:            public String[] getStopProfiler() {
142:                return new String[0];
143:            }
144:
145:            public void setStopProfiler(String[] values) {
146:            }
147:
148:            public boolean isRenderStopProfiler() {
149:                return false;
150:            }
151:
152:            public String getProfilerSMTP() {
153:                if (isOrgDN((String) getCurrentDN())) {
154:                    retrieveAttributeValues(true);
155:                    return retrieveValue(orgAttributeValues, PROFILERSMTP);
156:                } else {
157:                    return "";
158:                }
159:            }
160:
161:            public void setProfilerSMTP(String value) {
162:                if (isOrgDN((String) getCurrentDN())) {
163:                    storeValue(orgAttributeValues, PROFILERSMTP, value);
164:                }
165:            }
166:
167:            public boolean isRenderProfilerSMTP() {
168:                if (isOrgDN((String) getCurrentDN())) {
169:                    return true;
170:                } else {
171:                    return false;
172:                }
173:            }
174:
175:            public String getProfilerEmail() {
176:                if (isOrgDN((String) getCurrentDN())) {
177:                    retrieveAttributeValues(true);
178:                    return retrieveValue(orgAttributeValues, PROFILEREMAIL);
179:                } else {
180:                    return "";
181:                }
182:            }
183:
184:            public void setProfilerEmail(String value) {
185:                if (isOrgDN((String) getCurrentDN())) {
186:                    storeValue(orgAttributeValues, PROFILEREMAIL, value);
187:                }
188:            }
189:
190:            public boolean isRenderProfilerEmail() {
191:                if (isOrgDN((String) getCurrentDN())) {
192:                    return true;
193:                } else {
194:                    return false;
195:                }
196:            }
197:
198:            public String getProfilerProvider() {
199:                if (isOrgDN((String) getCurrentDN())) {
200:                    retrieveAttributeValues(true);
201:                    return retrieveValue(orgAttributeValues, PROFILERPROVIDER);
202:                } else {
203:                    return "";
204:                }
205:            }
206:
207:            public void setProfilerProvider(String value) {
208:                if (isOrgDN((String) getCurrentDN())) {
209:                    storeValue(orgAttributeValues, PROFILERPROVIDER, value);
210:                }
211:            }
212:
213:            public boolean isRenderProfilerProvider() {
214:                if (isOrgDN((String) getCurrentDN())) {
215:                    return true;
216:                } else {
217:                    return false;
218:                }
219:            }
220:
221:            public String getProfilerDefaultSearch() {
222:                if (isOrgDN((String) getCurrentDN())) {
223:                    retrieveAttributeValues(true);
224:                    return retrieveValue(orgAttributeValues,
225:                            PROFILERDEFAULTSEARCH);
226:                } else {
227:                    return "";
228:                }
229:            }
230:
231:            public void setProfilerDefaultSearch(String value) {
232:                if (isOrgDN((String) getCurrentDN())) {
233:                    storeValue(orgAttributeValues, PROFILERDEFAULTSEARCH, value);
234:                }
235:            }
236:
237:            public boolean isRenderProfilerDefaultSearch() {
238:                if (isOrgDN((String) getCurrentDN())) {
239:                    return true;
240:                } else {
241:                    return false;
242:                }
243:            }
244:
245:            public String getProfilerMaxHits() {
246:                if (isOrgDN((String) getCurrentDN())) {
247:                    retrieveAttributeValues(true);
248:                    return retrieveValue(orgAttributeValues, PROFILERMAXHITS);
249:                } else {
250:                    return "";
251:                }
252:            }
253:
254:            public void setProfilerMaxHits(String value) {
255:                if (isOrgDN((String) getCurrentDN())) {
256:                    storeValue(orgAttributeValues, PROFILERMAXHITS, value);
257:                }
258:            }
259:
260:            public boolean isRenderProfilerMaxHits() {
261:                if (isOrgDN((String) getCurrentDN())) {
262:                    return true;
263:                } else {
264:                    return false;
265:                }
266:            }
267:
268:            public String getMaxCategorySubscriptions() {
269:                String currentDN = (String) getCurrentDN();
270:                if (isGlobalDN(currentDN)) {
271:                    retrieveAttributeValues(true);
272:                    return retrieveValue(globalAttributeValues,
273:                            MAXCATEGORYSUBSCRIPTIONS);
274:                } else if (isOrgDN(currentDN)) {
275:                    retrieveAttributeValues(true);
276:                    return retrieveValue(orgAttributeValues,
277:                            MAXCATEGORYSUBSCRIPTIONS);
278:                } else if (isRoleDN(currentDN)) {
279:                    retrieveAttributeValues(true);
280:                    return retrieveValue(roleAttributeValues,
281:                            MAXCATEGORYSUBSCRIPTIONS);
282:                } else {
283:                    return "";
284:                }
285:            }
286:
287:            public void setMaxCategorySubscriptions(String value) {
288:                String currentDN = (String) getCurrentDN();
289:                if (isGlobalDN(currentDN)) {
290:                    storeValue(globalAttributeValues, MAXCATEGORYSUBSCRIPTIONS,
291:                            value);
292:                } else if (isOrgDN(currentDN)) {
293:                    storeValue(orgAttributeValues, MAXCATEGORYSUBSCRIPTIONS,
294:                            value);
295:                } else if (isRoleDN(currentDN)) {
296:                    storeValue(roleAttributeValues, MAXCATEGORYSUBSCRIPTIONS,
297:                            value);
298:                }
299:            }
300:
301:            public boolean isRenderMaxCategorySubscriptions() {
302:                String currentDN = (String) getCurrentDN();
303:                if (isGlobalDN(currentDN) || isOrgDN(currentDN)
304:                        || isRoleDN(currentDN)) {
305:                    return true;
306:                } else {
307:                    return false;
308:                }
309:            }
310:
311:            public String getMaxDiscussionSubscriptions() {
312:                String currentDN = (String) getCurrentDN();
313:                if (isGlobalDN(currentDN)) {
314:                    retrieveAttributeValues(true);
315:                    return retrieveValue(globalAttributeValues,
316:                            MAXDISCUSSIONSUBSCRIPTIONS);
317:                } else if (isOrgDN(currentDN)) {
318:                    retrieveAttributeValues(true);
319:                    return retrieveValue(orgAttributeValues,
320:                            MAXDISCUSSIONSUBSCRIPTIONS);
321:                } else if (isRoleDN(currentDN)) {
322:                    retrieveAttributeValues(true);
323:                    return retrieveValue(roleAttributeValues,
324:                            MAXDISCUSSIONSUBSCRIPTIONS);
325:                } else {
326:                    return "";
327:                }
328:            }
329:
330:            public void setMaxDiscussionSubscriptions(String value) {
331:                String currentDN = (String) getCurrentDN();
332:                if (isGlobalDN(currentDN)) {
333:                    storeValue(globalAttributeValues,
334:                            MAXDISCUSSIONSUBSCRIPTIONS, value);
335:                } else if (isOrgDN(currentDN)) {
336:                    storeValue(orgAttributeValues, MAXDISCUSSIONSUBSCRIPTIONS,
337:                            value);
338:                } else if (isRoleDN(currentDN)) {
339:                    storeValue(roleAttributeValues, MAXDISCUSSIONSUBSCRIPTIONS,
340:                            value);
341:                }
342:            }
343:
344:            public boolean isRenderMaxDiscussionSubscriptions() {
345:                String currentDN = (String) getCurrentDN();
346:                if (isGlobalDN(currentDN) || isOrgDN(currentDN)
347:                        || isRoleDN(currentDN)) {
348:                    return true;
349:                } else {
350:                    return false;
351:                }
352:            }
353:
354:            public String getMaxSavedSearch() {
355:                String currentDN = (String) getCurrentDN();
356:                if (isGlobalDN(currentDN)) {
357:                    retrieveAttributeValues(true);
358:                    return retrieveValue(globalAttributeValues, MAXSAVEDSEARCH);
359:                } else if (isOrgDN(currentDN)) {
360:                    retrieveAttributeValues(true);
361:                    return retrieveValue(orgAttributeValues, MAXSAVEDSEARCH);
362:                } else if (isRoleDN(currentDN)) {
363:                    retrieveAttributeValues(true);
364:                    return retrieveValue(roleAttributeValues, MAXSAVEDSEARCH);
365:                } else {
366:                    return "";
367:                }
368:            }
369:
370:            public void setMaxSavedSearch(String value) {
371:                String currentDN = (String) getCurrentDN();
372:                if (isGlobalDN(currentDN)) {
373:                    storeValue(globalAttributeValues, MAXSAVEDSEARCH, value);
374:                } else if (isOrgDN(currentDN)) {
375:                    storeValue(orgAttributeValues, MAXSAVEDSEARCH, value);
376:                } else if (isRoleDN(currentDN)) {
377:                    storeValue(roleAttributeValues, MAXSAVEDSEARCH, value);
378:                }
379:            }
380:
381:            public boolean isRenderMaxSavedSearch() {
382:                String currentDN = (String) getCurrentDN();
383:                if (isGlobalDN(currentDN) || isOrgDN(currentDN)
384:                        || isRoleDN(currentDN)) {
385:                    return true;
386:                } else {
387:                    return false;
388:                }
389:            }
390:
391:            public String[] getCategorySubscriptions() {
392:                if (isUserDN((String) getCurrentDN())) {
393:                    retrieveAttributeValues(true);
394:                    return retrieveValues(userAttributeValues,
395:                            CATEGORYSUBSCRIPTIONS);
396:                } else {
397:                    return new String[0];
398:                }
399:            }
400:
401:            public void setCategorySubscriptions(String[] values) {
402:                if (isUserDN((String) getCurrentDN())) {
403:                    storeValues(userAttributeValues, CATEGORYSUBSCRIPTIONS,
404:                            values);
405:                }
406:            }
407:
408:            public boolean isRenderCategorySubscriptions() {
409:                if (isUserDN((String) getCurrentDN())) {
410:                    return true;
411:                } else {
412:                    return false;
413:                }
414:            }
415:
416:            public String[] getDiscussionSubscriptions() {
417:                if (isUserDN((String) getCurrentDN())) {
418:                    retrieveAttributeValues(true);
419:                    return retrieveValues(userAttributeValues,
420:                            DISCUSSIONSUBSCRIPTIONS);
421:                } else {
422:                    return new String[0];
423:                }
424:            }
425:
426:            public void setDiscussionSubscriptions(String[] values) {
427:                if (isUserDN((String) getCurrentDN())) {
428:                    storeValues(userAttributeValues, DISCUSSIONSUBSCRIPTIONS,
429:                            values);
430:                }
431:            }
432:
433:            public boolean isRenderDiscussionSubscriptions() {
434:                if (isUserDN((String) getCurrentDN())) {
435:                    return true;
436:                } else {
437:                    return false;
438:                }
439:            }
440:
441:            public String[] getSavedSearch() {
442:                if (isUserDN((String) getCurrentDN())) {
443:                    retrieveAttributeValues(true);
444:                    return retrieveValues(userAttributeValues, SAVEDSEARCH);
445:                } else {
446:                    return new String[0];
447:                }
448:            }
449:
450:            public void setSavedSearch(String[] values) {
451:                if (isUserDN((String) getCurrentDN())) {
452:                    storeValues(userAttributeValues, SAVEDSEARCH, values);
453:                }
454:            }
455:
456:            public boolean isRenderSavedSearch() {
457:                if (isUserDN((String) getCurrentDN())) {
458:                    return true;
459:                } else {
460:                    return false;
461:                }
462:            }
463:
464:            public String getProfilerLastRun() {
465:                return "";
466:            }
467:
468:            public void setProfilerLastRun(String value) {
469:            }
470:
471:            public boolean isRenderProfilerLastRun() {
472:                return false;
473:            }
474:
475:            public String getProfilerEnabled() {
476:                if (isUserDN((String) getCurrentDN())) {
477:                    retrieveAttributeValues(true);
478:                    String value = retrieveValue(userAttributeValues,
479:                            PROFILERENABLED);
480:                    return (value.equals("true")) ? "enabled" : "disabled";
481:                } else {
482:                    return "disabled";
483:                }
484:            }
485:
486:            public void setProfilerEnabled(String value) {
487:                if (isUserDN((String) getCurrentDN())) {
488:                    storeValue(userAttributeValues, PROFILERENABLED, (value
489:                            .equals("enabled")) ? "true" : "false");
490:                }
491:            }
492:
493:            public boolean isRenderProfilerEnabled() {
494:                if (isUserDN((String) getCurrentDN())) {
495:                    return true;
496:                } else {
497:                    return false;
498:                }
499:            }
500:
501:            public void validate(FacesContext context, UIComponent component,
502:                    Object value) throws ValidatorException {
503:                String id = component.getId();
504:                if (id.equals("profilermaxhits")) {
505:                    if (!isValidPositiveInteger((String) value)) {
506:                        throw new ValidatorException(new FacesMessage(
507:                                FacesMessage.SEVERITY_ERROR,
508:                                getLocalizedString("subscriptions",
509:                                        "subscriptions.error.error"),
510:                                getLocalizedString("subscriptions",
511:                                        "subscriptions.error.positiveinteger")));
512:                    }
513:                } else if (id.equals("maxcategorysubscriptions")) {
514:                    if (!isValidPositiveInteger((String) value)) {
515:                        throw new ValidatorException(new FacesMessage(
516:                                FacesMessage.SEVERITY_ERROR,
517:                                getLocalizedString("subscriptions",
518:                                        "subscriptions.error.error"),
519:                                getLocalizedString("subscriptions",
520:                                        "subscriptions.error.positiveinteger")));
521:                    }
522:                } else if (id.equals("maxdiscussionsubscriptions")) {
523:                    if (!isValidPositiveInteger((String) value)) {
524:                        throw new ValidatorException(new FacesMessage(
525:                                FacesMessage.SEVERITY_ERROR,
526:                                getLocalizedString("subscriptions",
527:                                        "subscriptions.error.error"),
528:                                getLocalizedString("subscriptions",
529:                                        "subscriptions.error.positiveinteger")));
530:                    }
531:                } else if (id.equals("maxsavedsearch")) {
532:                    if (!isValidPositiveInteger((String) value)) {
533:                        throw new ValidatorException(new FacesMessage(
534:                                FacesMessage.SEVERITY_ERROR,
535:                                getLocalizedString("subscriptions",
536:                                        "subscriptions.error.error"),
537:                                getLocalizedString("subscriptions",
538:                                        "subscriptions.error.positiveinteger")));
539:                    }
540:                }
541:            }
542:
543:            public String save() {
544:                String currentDN = (String) getCurrentDN();
545:                try {
546:                    Object[] params = new Object[2];
547:                    Map optionsMap = new HashMap();
548:                    optionsMap
549:                            .put(AttrOptionConstants.OPT_COMPONENT, COMPONENT);
550:                    if (isGlobalDN(currentDN)) {
551:                        optionsMap.put(AttrOptionConstants.OPT_ATTR_NAMES,
552:                                globalAttributes);
553:                        params[0] = globalAttributeValues;
554:                    } else if (isOrgDN(currentDN)) {
555:                        optionsMap.put(AttrOptionConstants.OPT_ATTR_NAMES,
556:                                orgAttributes);
557:                        optionsMap.put(AttrOptionConstants.OPT_DN, currentDN);
558:                        params[0] = orgAttributeValues;
559:                    } else if (isRoleDN(currentDN)) {
560:                        optionsMap.put(AttrOptionConstants.OPT_ATTR_NAMES,
561:                                roleAttributes);
562:                        optionsMap.put(AttrOptionConstants.OPT_DN, currentDN);
563:                        params[0] = roleAttributeValues;
564:                    } else if (isUserDN(currentDN)) {
565:                        optionsMap.put(AttrOptionConstants.OPT_ATTR_NAMES,
566:                                userAttributes);
567:                        optionsMap.put(AttrOptionConstants.OPT_DN, currentDN);
568:                        params[0] = userAttributeValues;
569:                    }
570:                    params[1] = optionsMap;
571:                    String[] signature = { "java.util.Map", "java.util.Map" };
572:
573:                    ObjectName on = AdminUtil.getPortalMBeanObjectName(
574:                            getDomain(),
575:                            (String) getSessionAttribute(ATTR_SELECTED_PORTAL));
576:                    getMBeanServerConnection().invoke(on, "setAttributes",
577:                            params, signature);
578:                    setSessionAttribute("subscriptions.showerror", "false");
579:                } catch (Exception e) {
580:                    log(Level.SEVERE, "AttributesBean.save()", e);
581:                    setSessionAttribute("subscriptions.showerror", "true");
582:                }
583:
584:                lastDN = "";
585:                return "reload";
586:            }
587:
588:            public String reset() {
589:                lastDN = "";
590:                return "reload";
591:            }
592:
593:            private void retrieveAttributeValues(boolean save) {
594:                String currentDN = (String) getCurrentDN();
595:                if (!currentDN.equals(lastDN)) {
596:                    try {
597:                        Map optionsMap = new HashMap();
598:                        optionsMap.put(AttrOptionConstants.OPT_COMPONENT,
599:                                COMPONENT);
600:                        if (isGlobalDN(currentDN)) {
601:                            optionsMap.put(AttrOptionConstants.OPT_ATTR_NAMES,
602:                                    globalAttributes);
603:                        } else if (isOrgDN(currentDN)) {
604:                            optionsMap.put(AttrOptionConstants.OPT_ATTR_NAMES,
605:                                    orgAttributes);
606:                            optionsMap.put(AttrOptionConstants.OPT_DN,
607:                                    currentDN);
608:                        } else if (isRoleDN(currentDN)) {
609:                            optionsMap.put(AttrOptionConstants.OPT_ATTR_NAMES,
610:                                    roleAttributes);
611:                            optionsMap.put(AttrOptionConstants.OPT_DN,
612:                                    currentDN);
613:                        } else if (isUserDN(currentDN)) {
614:                            optionsMap.put(AttrOptionConstants.OPT_ATTR_NAMES,
615:                                    userAttributes);
616:                            optionsMap.put(AttrOptionConstants.OPT_DN,
617:                                    currentDN);
618:                        }
619:
620:                        Object[] params = { optionsMap };
621:                        String[] signature = { "java.util.Map" };
622:
623:                        ObjectName on = AdminUtil
624:                                .getPortalMBeanObjectName(
625:                                        getDomain(),
626:                                        (String) getSessionAttribute(ATTR_SELECTED_PORTAL));
627:                        Map m = (Map) getMBeanServerConnection().invoke(on,
628:                                "getAttributes", params, signature);
629:
630:                        globalAttributeValues = new HashMap();
631:                        orgAttributeValues = new HashMap();
632:                        roleAttributeValues = new HashMap();
633:                        userAttributeValues = new HashMap();
634:
635:                        if (isGlobalDN(currentDN)) {
636:                            initValue(m, globalAttributeValues,
637:                                    MAXCATEGORYSUBSCRIPTIONS);
638:                            initValue(m, globalAttributeValues,
639:                                    MAXDISCUSSIONSUBSCRIPTIONS);
640:                            initValue(m, globalAttributeValues, MAXSAVEDSEARCH);
641:                        } else if (isOrgDN(currentDN)) {
642:                            initValue(m, orgAttributeValues, STARTPROFILER);
643:                            initValue(m, orgAttributeValues, STOPPROFILER);
644:                            initValue(m, orgAttributeValues, PROFILERSMTP);
645:                            initValue(m, orgAttributeValues, PROFILEREMAIL);
646:                            initValue(m, orgAttributeValues, PROFILERPROVIDER);
647:                            initValue(m, orgAttributeValues,
648:                                    PROFILERDEFAULTSEARCH);
649:                            initValue(m, orgAttributeValues, PROFILERMAXHITS);
650:                            initValue(m, orgAttributeValues,
651:                                    MAXCATEGORYSUBSCRIPTIONS);
652:                            initValue(m, orgAttributeValues,
653:                                    MAXDISCUSSIONSUBSCRIPTIONS);
654:                            initValue(m, orgAttributeValues, MAXSAVEDSEARCH);
655:                        } else if (isRoleDN(currentDN)) {
656:                            initValue(m, roleAttributeValues,
657:                                    MAXCATEGORYSUBSCRIPTIONS);
658:                            initValue(m, roleAttributeValues,
659:                                    MAXDISCUSSIONSUBSCRIPTIONS);
660:                            initValue(m, roleAttributeValues, MAXSAVEDSEARCH);
661:                        } else if (isUserDN(currentDN)) {
662:                            initValue(m, userAttributeValues,
663:                                    CATEGORYSUBSCRIPTIONS);
664:                            initValue(m, userAttributeValues,
665:                                    DISCUSSIONSUBSCRIPTIONS);
666:                            initValue(m, userAttributeValues, SAVEDSEARCH);
667:                            initValue(m, userAttributeValues, PROFILERLASTRUN);
668:                            initValue(m, userAttributeValues, PROFILERENABLED);
669:                        }
670:                        setSessionAttribute("subscriptions.showerror", "false");
671:                    } catch (Exception e) {
672:                        log(Level.SEVERE,
673:                                "AttributesBean.retrieveAttributeValues()", e);
674:                        setSessionAttribute("subscriptions.showerror", "true");
675:                    }
676:
677:                    if (save) {
678:                        lastDN = currentDN;
679:                    }
680:                }
681:            }
682:
683:            private void initValue(Map srcMap, Map destMap, String key) {
684:                if (srcMap.containsKey(key)) {
685:                    List values = (List) srcMap.get(key);
686:                    if (!values.isEmpty()) {
687:                        destMap.put(key, values);
688:                    } else {
689:                        ArrayList al = new ArrayList();
690:                        al.add("");
691:                        destMap.put(key, al);
692:                    }
693:                } else {
694:                    ArrayList al = new ArrayList();
695:                    al.add("");
696:                    destMap.put(key, al);
697:                }
698:            }
699:
700:            private String retrieveValue(Map map, String key) {
701:                String inError = (String) getSessionAttribute("subscriptions.showerror");
702:                if ((inError == null || inError.equals("false"))
703:                        && (map != null && map.containsKey(key))) {
704:                    List l = (List) map.get(key);
705:                    if (!l.isEmpty()) {
706:                        return (String) l.get(0);
707:                    } else {
708:                        return "";
709:                    }
710:                } else {
711:                    return "";
712:                }
713:            }
714:
715:            private String[] retrieveValues(Map map, String key) {
716:                String inError = (String) getSessionAttribute("subscriptions.showerror");
717:                if ((inError == null || inError.equals("false"))
718:                        && (map != null && map.containsKey(key))) {
719:                    List l = (List) map.get(key);
720:                    int size = l.size();
721:                    if (size == 0) {
722:                        return new String[0];
723:                    } else if (size == 1) {
724:                        String value = (String) l.get(0);
725:                        if (value.equals("")) {
726:                            return new String[0];
727:                        } else {
728:                            String[] values = new String[1];
729:                            values[0] = value;
730:                            return values;
731:                        }
732:                    } else {
733:                        String[] values = new String[size];
734:                        for (int index = 0; index < size; index++) {
735:                            values[index] = (String) l.get(index);
736:                        }
737:                        return values;
738:                    }
739:                } else {
740:                    return new String[0];
741:                }
742:            }
743:
744:            private void storeValue(Map map, String key, String value) {
745:                String inError = (String) getSessionAttribute("subscriptions.showerror");
746:                if ((inError == null || inError.equals("false")) && map != null) {
747:                    ArrayList al = new ArrayList();
748:                    al.add(value);
749:                    map.put(key, al);
750:                }
751:            }
752:
753:            private void storeValues(Map map, String key, String[] values) {
754:                String inError = (String) getSessionAttribute("subscriptions.showerror");
755:                if ((inError == null || inError.equals("false")) && map != null) {
756:                    ArrayList al = new ArrayList();
757:                    if (values.length != 1 || !values[0].equals("")) {
758:                        for (int index = 0; index < values.length; al
759:                                .add(values[index++]))
760:                            ;
761:                    }
762:                    map.put(key, al);
763:                }
764:            }
765:
766:            private boolean isValidPositiveInteger(String value) {
767:                if (value.equals("")) {
768:                    return true;
769:                }
770:                try {
771:                    int number = Integer.parseInt(value);
772:                    if (number < 0) {
773:                        return false;
774:                    }
775:                } catch (Exception e) {
776:                    return false;
777:                }
778:                return true;
779:            }
780:
781:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.