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


001:        /**
002:         * $Id: SraBaseBean.java,v 1.28 2006/09/11 22:32:12 bustamam Exp $ Copyright
003:         * 2005 Sun Microsystems, Inc. All rights reserved. Use of this product is
004:         * subject to license terms. Federal Acquisitions: Commercial Software --
005:         * Government Users Subject to Standard License Terms and Conditions.
006:         *
007:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE are trademarks or registered
008:         * trademarks of Sun Microsystems, Inc. in the United States and other
009:         * countries.
010:         */package com.sun.portal.admin.console.sra;
011:
012:        import java.io.IOException;
013:        import java.io.Serializable;
014:        import java.util.ArrayList;
015:        import java.util.Arrays;
016:        import java.util.Collections;
017:        import java.util.HashMap;
018:        import java.util.Iterator;
019:        import java.util.LinkedList;
020:        import java.util.List;
021:        import java.util.Map;
022:        import java.util.logging.Level;
023:        import java.text.MessageFormat;
024:
025:        import javax.faces.component.UIComponent;
026:        import javax.faces.context.FacesContext;
027:        import javax.faces.validator.ValidatorException;
028:        import javax.management.MBeanException;
029:        import javax.management.MBeanServerConnection;
030:        import javax.management.MalformedObjectNameException;
031:        import javax.management.ObjectName;
032:        import javax.management.remote.JMXConnector;
033:
034:        import com.sun.portal.admin.common.PSMBeanException;
035:        import com.sun.portal.admin.common.util.AdminClientUtil;
036:        import com.sun.portal.admin.console.common.PSBaseBean;
037:        import com.sun.portal.admin.console.common.SessionAttributeNames;
038:        import com.sun.portal.admin.console.sra.exceptions.DeserializeException;
039:        import com.sun.portal.admin.console.sra.exceptions.PersistBeanException;
040:        import com.sun.portal.admin.console.sra.persistance.IPersistantDataStore;
041:        import com.sun.portal.admin.console.sra.persistance.LDAPDataStoreImpl;
042:        import com.sun.portal.admin.console.sra.utils.Util;
043:        import com.sun.portal.admin.console.sra.utils.AllowDenyItem;
044:        import com.sun.portal.admin.console.sra.utils.AllowDenyModel;
045:        import com.sun.portal.admin.console.sra.validators.HostDomainNameValidator;
046:        import com.sun.portal.admin.console.sra.validators.UrlFormatValidator;
047:        import com.sun.web.ui.model.Option;
048:        import com.sun.data.provider.impl.ObjectListDataProvider;
049:
050:        public abstract class SraBaseBean extends PSBaseBean implements 
051:                ISraBean, ServiceNames, Serializable {
052:
053:            private static final Map ATTR_LEVELS_MAP = new HashMap() {
054:                public Object get(Object key) {
055:                    boolean[] values = (boolean[]) super .get(key);
056:                    if (values == null) {
057:                        PSBaseBean.log(Level.INFO, "Attribute name " + key
058:                                + " missing from the attribute level map");
059:                        return Boolean.FALSE;
060:                    } else
061:                        return Boolean.valueOf(values[getDnIndex()]);
062:                }
063:            };
064:
065:            private IPersistantDataStore _dataStore;
066:
067:            private String _serviceName;
068:
069:            protected Map _attributeNameValueMap;
070:
071:            protected String[] _attributeList;
072:
073:            protected String _sraProfileName;
074:
075:            private static Map OBJNAME_CACHE = new HashMap();
076:
077:            //    private static final String SELECTED_DN =
078:            // "#{AMLocationBarBean.currentLocationDN}";
079:
080:            private int DN_INDEX = 0;
081:
082:            protected Boolean displayError = Boolean.FALSE;
083:
084:            //am conflict resolution level
085:            private Option[] cosValues = null;
086:
087:            private void initialize() {
088:                _dataStore = new LDAPDataStoreImpl();
089:                initDN();
090:                cosValues = new Option[7];
091:                cosValues[0] = new Option("0", (String) getLocalizedString(
092:                        RB_NAME, "svcattr.amcos.value.highest"));
093:                cosValues[1] = new Option("1", (String) getLocalizedString(
094:                        RB_NAME, "svcattr.amcos.value.higher"));
095:                cosValues[2] = new Option("2", (String) getLocalizedString(
096:                        RB_NAME, "svcattr.amcos.value.high"));
097:                cosValues[3] = new Option("3", (String) getLocalizedString(
098:                        RB_NAME, "svcattr.amcos.value.medium"));
099:                cosValues[4] = new Option("4", (String) getLocalizedString(
100:                        RB_NAME, "svcattr.amcos.value.low"));
101:                cosValues[5] = new Option("5", (String) getLocalizedString(
102:                        RB_NAME, "svcattr.amcos.value.lower"));
103:                cosValues[6] = new Option("6", (String) getLocalizedString(
104:                        RB_NAME, "svcattr.amcos.value.lowest"));
105:                PSBaseBean.log(Level.FINEST, "SraBaseBean:initialize()");
106:            }
107:
108:            public void initDN() {
109:                DN_INDEX = getDnIndex();
110:            }
111:
112:            private void setBeanInRequest() {
113:                List beanList = (List) Util
114:                        .getRequestAttribute(SraBaseBean.class.getName());
115:                if (beanList == null) {
116:                    beanList = new ArrayList();
117:                    Util.setRequestAttribute(SraBaseBean.class.getName(),
118:                            beanList);
119:                }
120:                beanList.add(this );
121:            }
122:
123:            /**
124:             * @param currentDN
125:             * @return
126:             */
127:            private static int getDnIndex() {
128:                String currentDN = (String) getSessionAttribute(SessionAttributeNames.ATTR_CURRENT_LOCATION_DN);
129:                if (currentDN == null)
130:                    return 1;
131:
132:                PSBaseBean pb = new PSBaseBean();
133:                try {
134:                    if (pb.isGlobalDN(currentDN))
135:                        return 0;
136:                    else if (pb.isOrgDN(currentDN))
137:                        return 1;
138:                    else if (pb.isUserDN(currentDN))
139:                        return 2;
140:                    else
141:                        return 1;
142:                } finally {
143:                    pb = null;
144:                }
145:            }
146:
147:            public SraBaseBean() {
148:                _serviceName = new String();
149:                initialize();
150:                setBeanInRequest();
151:            }
152:
153:            public SraBaseBean(String service_name, String[] attrList) {
154:                this (service_name, "default", attrList);
155:            }
156:
157:            /*
158:             * constructor that the gateway will use since he is the only one who is
159:             * concerned with a profile
160:             */
161:            public SraBaseBean(String service_name, String sraProfileName,
162:                    String[] attrList) {
163:                _serviceName = service_name;
164:                _attributeList = attrList;
165:                _sraProfileName = sraProfileName;
166:                initialize();
167:                _dataStore = new LDAPDataStoreImpl();
168:                getDataFromStore();
169:                setBeanInRequest();
170:
171:            }
172:
173:            /*
174:             * This function will store all the attributes that have key in the
175:             * attributeNameValueMap
176:             */
177:            protected boolean storeDataToStore() {
178:                boolean ret = false;
179:
180:                try {
181:                    if (_serviceName.equalsIgnoreCase(GATEWAY_SVC))
182:                        _dataStore.serialize(_serviceName, _sraProfileName,
183:                                _attributeNameValueMap);
184:                    else {
185:                        // Based on the DN selected select only the attributes at this
186:                        // level and store only those
187:                        // else the AM throws an exception. Based on the private
188:                        // _attributeNameValueMap generate
189:                        // a new map.
190:                        // Gateway service is an exception since it doesn't have any
191:                        // levels.
192:
193:                        Map nameValues = currentLevelAttributeValueMap();
194:                        _dataStore.serialize(_serviceName, nameValues);
195:                    }
196:                } catch (PersistBeanException e) {
197:                    PSBaseBean.log(Level.SEVERE,
198:                            "SraBaseBean.storeDataToStore() : Exception", e);
199:                }
200:                return ret;
201:            }
202:
203:            /**
204:             * @return
205:             */
206:            private Map currentLevelAttributeValueMap() {
207:                HashMap nvMap = new HashMap();
208:                Iterator iter = _attributeNameValueMap.keySet().iterator();
209:
210:                while (iter.hasNext()) {
211:                    String attribName = (String) iter.next();
212:                    if (((Boolean) ATTR_LEVELS_MAP.get(attribName))
213:                            .booleanValue())
214:                        nvMap.put(attribName, _attributeNameValueMap
215:                                .get(attribName));
216:                }
217:                return nvMap;
218:            }
219:
220:            /*
221:             * This function will store the attribute name given here with its value
222:             * being fetched from the map
223:             */
224:
225:            protected boolean storeDataToStore(String attributeName) {
226:                boolean ret = false;
227:
228:                HashMap map = new HashMap();
229:                map.put(attributeName, _attributeNameValueMap
230:                        .get(attributeName));
231:
232:                try {
233:                    if (_serviceName.equalsIgnoreCase(GATEWAY_SVC))
234:                        _dataStore
235:                                .serialize(_serviceName, _sraProfileName, map);
236:                    else {
237:                        // If the attribute does not exist at the chosen DN then don't try to
238:                        // save it
239:                        // as it will anyway result in an exception.
240:                        if (!((Boolean) ATTR_LEVELS_MAP.get(attributeName))
241:                                .booleanValue())
242:                            return true;
243:                        _dataStore.serialize(_serviceName, map);
244:                    }
245:                } catch (PersistBeanException e) {
246:                    PSBaseBean.log(Level.SEVERE,
247:                            "SraBaseBean.storeDataToStore() : Exception", e);
248:                }
249:                return ret;
250:            }
251:
252:            /*
253:             * This function will store the attribute name given here with its value
254:             * being fetched from the map
255:             */
256:
257:            private boolean storeDataToStore(Map nameValues) {
258:                boolean ret = true;
259:
260:                try {
261:                    if (_serviceName.equalsIgnoreCase(GATEWAY_SVC))
262:                        _dataStore.serialize(_serviceName, _sraProfileName,
263:                                nameValues);
264:                    else
265:                        _dataStore.serialize(_serviceName, nameValues);
266:                } catch (PersistBeanException e) {
267:                    ret = false;
268:                    PSBaseBean.log(Level.SEVERE,
269:                            "SraBaseBean.storeDataToStore() : Exception", e);
270:                }
271:                return ret;
272:            }
273:
274:            /*
275:             * This will call the datastore and deserialize the given service name from
276:             * the datastore and return a populated object to the calling class. The
277:             * caller will reconstruct the bean from the returned object
278:             */
279:            protected Map getDataFromStore(String attributeName)
280:                    throws DeserializeException {
281:                String[] attrList = new String[1];
282:
283:                attrList[0] = attributeName;
284:
285:                if (_serviceName.equalsIgnoreCase(GATEWAY_SVC))
286:                    return _attributeNameValueMap = _dataStore.deserialize(
287:                            _serviceName, _sraProfileName, attrList);
288:                else
289:                    return _attributeNameValueMap = _dataStore.deserialize(
290:                            _serviceName, attrList);
291:            }
292:
293:            /*
294:             * This will call the datastore and deserialize the given service name from
295:             * the datastore and return a populated object to the calling class. The
296:             * caller will reconstruct the bean from the returned object
297:             */
298:            public Map getDataFromStore() {
299:                try {
300:                    if (_serviceName.equalsIgnoreCase(GATEWAY_SVC))
301:                        return _attributeNameValueMap = _dataStore.deserialize(
302:                                _serviceName, _sraProfileName, _attributeList);
303:                    else
304:                        return _attributeNameValueMap = _dataStore.deserialize(
305:                                _serviceName, _attributeList);
306:                } catch (DeserializeException e) {
307:                    PSBaseBean.log(Level.SEVERE,
308:                            "SraBaseBean.getDataFromStore() : Exception", e);
309:                    return _attributeNameValueMap = Collections.EMPTY_MAP;
310:                }
311:            }
312:
313:            protected String getStringValue(String name) {
314:                List l = (List) _attributeNameValueMap.get(name);
315:                if (l == null || l.isEmpty())
316:                    return "";
317:                return (String) l.get(0);
318:            }
319:
320:            protected String[] getStringArrayValue(String name) {
321:                List l = (List) _attributeNameValueMap.get(name);
322:                if (l == null || l.isEmpty())
323:                    return new String[0];
324:                return (String[]) l.toArray(new String[0]);
325:            }
326:
327:            protected int getIntValue(String name) {
328:                List l = (List) _attributeNameValueMap.get(name);
329:                if (l == null || l.isEmpty())
330:                    return -1;
331:                return Integer.parseInt((String) l.get(0));
332:            }
333:
334:            protected int getCosValueAsInt(String name) {
335:                List l = (List) _attributeNameValueMap.get(name);
336:                if (l == null || l.isEmpty())
337:                    return 0;
338:
339:                Object element = l.get(0);
340:                if (element instanceof  Integer)
341:                    return ((Integer) element).intValue();
342:                else if (element instanceof  String)
343:                    return Integer.parseInt((String) element);
344:                else
345:                    return 0;
346:            }
347:
348:            protected long getLongValue(String name) {
349:                List l = (List) _attributeNameValueMap.get(name);
350:                if (l == null || l.isEmpty())
351:                    return -1;
352:                return Long.parseLong((String) l.get(0));
353:            }
354:
355:            protected List getListValue(String name) {
356:                List l = (List) _attributeNameValueMap.get(name);
357:                if (l == null)
358:                    return new ArrayList();
359:                return l;
360:            }
361:
362:            protected boolean getBooleanValue(String name) {
363:                List l = (List) _attributeNameValueMap.get(name);
364:                if (l == null || l.isEmpty())
365:                    return false;
366:                String firstelement = (String) l.get(0);
367:                return firstelement.equalsIgnoreCase("true");
368:            }
369:
370:            /*
371:             * (non-Javadoc)
372:             *
373:             * @see com.sun.portal.admin.console.sra.ISraBean#getAttributeNameValueMap()
374:             */
375:            public Map getAttributeNameValueMap() {
376:                return _attributeNameValueMap;
377:            }
378:
379:            protected void updateAttributeNVMap(String key, String[] value) {
380:                _attributeNameValueMap.put(key, new ArrayList(Arrays
381:                        .asList((String[]) value)));
382:            }
383:
384:            protected void updateAttributeNVMap(String key, List value) {
385:                _attributeNameValueMap.put(key, value);
386:            }
387:
388:            protected void updateAttributeNVMap(String key, String value) {
389:                ArrayList list = new ArrayList();
390:                list.add(value);
391:                _attributeNameValueMap.put(key, list);
392:            }
393:
394:            public int getSraProxyPort(int type, String profileName,
395:                    String instanceHostName) throws SecurityException,
396:                    IOException {
397:                String methodName = "GetRewriterProxyPort";
398:                switch (type) {
399:                case SRA_INSTANCE_TYPE_NETLET_PROXY:
400:                    methodName = "GetNetletProxyPort";
401:                    break;
402:                }
403:                String port = (String) invokeRemoteMBean(instanceHostName,
404:                        AdminClientUtil.SRA_MBEAN, methodName,
405:                        new Object[] { profileName }, new String[] { STRING });
406:                return port != null ? Integer.parseInt(port) : -1;
407:            }
408:
409:            /*
410:             * Returns a String array with each element of the form
411:             * PROFILENAME:HOSTNAME|IPADDRESS
412:             */
413:            public List getSraInstances(int type) {
414:                String methodName = null;
415:                switch (type) {
416:                case SRA_INSTANCE_TYPE_GATEWAY:
417:                    methodName = "ListGatewayInstances";
418:                    break;
419:                case SRA_INSTANCE_TYPE_NETLET_PROXY:
420:                    methodName = "ListNLPInstances";
421:                    break;
422:                case SRA_INSTANCE_TYPE_REWRITER_PROXY:
423:                    methodName = "ListRWPInstances";
424:                    break;
425:                default:
426:                    return Collections.EMPTY_LIST;
427:                }
428:                return Arrays.asList((String[]) invokeLocalSraMbean(methodName,
429:                        new Object[] {}, new String[] {}));
430:            }
431:
432:            public Boolean isSraInstanceStarted(int type, String profileName,
433:                    String hostname, int portNumber) {
434:
435:                String typeName = Util.getProxyTypeName(type);
436:                if (typeName == null)
437:                    return Boolean.FALSE;
438:                return (Boolean) invokeRemoteMBean(hostname,
439:                        AdminClientUtil.SRA_MBEAN, "IsInstanceStarted",
440:                        new Object[] { typeName, profileName, hostname,
441:                                new Integer(portNumber) }, new String[] {
442:                                STRING, STRING, STRING, "java.lang.Integer" });
443:            }
444:
445:            public Boolean createNewSraProfile(String copyFrom,
446:                    String newProfileName) {
447:                return (Boolean) invokeLocalSraMbean("createNewProfile",
448:                        new Object[] { copyFrom, newProfileName },
449:                        new String[] { STRING, STRING });
450:            }
451:
452:            public Boolean deleteSraProfile(String profileName) {
453:                return (Boolean) invokeLocalSraMbean("deleteProfile",
454:                        new Object[] { profileName }, new String[] { STRING });
455:            }
456:
457:            public Boolean isSraInstanceStopped(int type, String profileName,
458:                    String hostname, int portNumber) {
459:                String typeName = Util.getProxyTypeName(type);
460:                if (typeName == null)
461:                    return Boolean.FALSE;
462:                return (Boolean) invokeLocalSraMbean("IsInstanceStopped",
463:                        new Object[] { typeName, profileName, hostname,
464:                                new Integer(portNumber) }, new String[] {
465:                                STRING, STRING, STRING, "java.lang.Integer" });
466:            }
467:
468:            public List getSraProfiles() {
469:                List l = (List) invokeLocalSraMbean("ListAllKnownProfiles",
470:                        new Object[] {}, new String[] {});
471:                return l == null ? new ArrayList() : l;
472:            }
473:
474:            private MBeanServerConnection getMBeanServerConnection(
475:                    String hostname) throws SecurityException, IOException {
476:                if (hostname == null)
477:                    return getMBeanServerConnection();
478:                else {
479:                    JMXConnector jmxconn = AdminClientUtil.getJMXConnector(
480:                            hostname, AdminClientUtil.DEFAULT_DOMAIN,
481:                            AMADMIN_USERNAME, AMADMIN_PASSWORD);
482:                    return jmxconn.getMBeanServerConnection();
483:                }
484:            }
485:
486:            protected Object invokeLocalSraMbean(String methodToInvoke,
487:                    Object[] params, String[] signature) {
488:                MBeanServerConnection conn;
489:                try {
490:                    conn = getMBeanServerConnection();
491:                    return invokeSraMbean(conn, methodToInvoke, params,
492:                            signature);
493:                } catch (Exception e) {
494:                    PSBaseBean.log(Level.SEVERE,
495:                            "SraBaseBean.invokeLocalSraMbean() : Error in invoking : "
496:                                    + methodToInvoke, e);
497:                }
498:                return null;
499:            }
500:
501:            protected Object invokeRemoteMBean(String cacaoHostname,
502:                    String mbeanName, String methodToInvoke, Object[] params,
503:                    String[] signature) {
504:                Object[] newParams = new Object[5];
505:                newParams[0] = cacaoHostname;
506:                newParams[1] = getObjectName(mbeanName);
507:                newParams[2] = methodToInvoke;
508:                newParams[3] = params;
509:                newParams[4] = signature;
510:
511:                String[] newSignature = new String[5];
512:                newSignature[0] = STRING;
513:                newSignature[1] = ObjectName.class.getName();
514:                newSignature[2] = STRING;
515:                newSignature[3] = Object[].class.getName();
516:                newSignature[4] = String[].class.getName();
517:
518:                return invokeLocalSraMbean("invokeRemoteOperation", newParams,
519:                        newSignature);
520:            }
521:
522:            private Object invokeSraMbean(MBeanServerConnection conn,
523:                    String methodToInvoke, Object[] params, String[] signature) {
524:                return invokeMBean(AdminClientUtil.SRA_MBEAN, methodToInvoke,
525:                        conn, params, signature);
526:            }
527:
528:            protected Object invokeMBean(String mbeanName,
529:                    String methodToInvoke, MBeanServerConnection conn,
530:                    Object[] params, String[] signature) {
531:                if (conn == null) {
532:                    conn = getMBeanServerConnection();
533:                }
534:                Object returnObject = null;
535:                try {
536:                    PSBaseBean.log(Level.FINEST,
537:                            "SraBaseBean.invokeSraMbean: Invoking mbean operation "
538:                                    + methodToInvoke);
539:                    if (conn != null) {
540:                        returnObject = conn.invoke(getObjectName(mbeanName),
541:                                methodToInvoke, params, signature);
542:                        PSBaseBean.log(Level.FINEST, "Executed method => "
543:                                + methodToInvoke + " with input params : "
544:                                + params);
545:                        PSBaseBean.log(Level.FINEST, "Return Value => "
546:                                + returnObject);
547:                    }
548:                } catch (MBeanException me) {
549:                    PSBaseBean.log(Level.FINEST, "SraBaseBean.invokeMBean()",
550:                            me);
551:                    if (me.getTargetException() instanceof  PSMBeanException) {
552:                        PSMBeanException pme = (PSMBeanException) me
553:                                .getTargetException();
554:                        displayAlert(pme.getTokens(), pme.getErrorKey(), pme
555:                                .getMessage(), "error");
556:                    }
557:                    if (methodToInvoke.equalsIgnoreCase("createNewProfile")
558:                            || methodToInvoke.equalsIgnoreCase("deleteProfile"))
559:                        return Boolean.FALSE;
560:                } catch (Exception e) {
561:                    PSBaseBean.log(Level.FINEST,
562:                            "SraBaseBean.invokeMBean(): Error in invoking : "
563:                                    + methodToInvoke, e);
564:                    return Collections.EMPTY_SET;
565:                }
566:                return returnObject;
567:            }
568:
569:            private ObjectName getObjectName(String mbeanName) {
570:                ObjectName result = (ObjectName) OBJNAME_CACHE.get(mbeanName);
571:                if (result == null) {
572:                    LinkedList path = new LinkedList();
573:                    path.addFirst(AdminClientUtil.DEFAULT_DOMAIN);
574:                    if (AdminClientUtil.SRA_MBEAN.equals(mbeanName)) {
575:                        path.addFirst("sra");
576:                    } else if (AdminClientUtil.SRA_MONITORING_MBEAN
577:                            .equals(mbeanName)) {
578:                        path.addFirst("sramonitoring");
579:                    } else if (AdminClientUtil.REWRITER_MBEAN.equals(mbeanName)) {
580:                        path.addFirst("rewriter");
581:                    }
582:                    try {
583:                        result = AdminClientUtil.getResourceMBeanObjectName(
584:                                AdminClientUtil.PORTAL_DOMAIN_MBEAN_TYPE + "."
585:                                        + mbeanName, path);
586:                    } catch (MalformedObjectNameException e) {
587:                        return null;
588:
589:                    }
590:                    OBJNAME_CACHE.put(mbeanName, result);
591:                }
592:                return result;
593:            }
594:
595:            public Map getRenderProperty() {
596:                return ATTR_LEVELS_MAP;
597:            }
598:
599:            public static void setPropertyVisibility(String attributeName,
600:                    boolean isGlobalLevel, boolean isOrgLevel,
601:                    boolean isUserLevel) {
602:                ATTR_LEVELS_MAP.put(attributeName, new boolean[] {
603:                        isGlobalLevel, isOrgLevel, isUserLevel });
604:
605:            }
606:
607:            public Boolean getDisplayError() {
608:                return displayError;
609:            }
610:
611:            public void setDisplayError(Boolean value) {
612:                displayError = value;
613:            }
614:
615:            public void displayAlert(String summary, String detail, String type) {
616:                String sm = getLocalizedString(RB_NAME, summary);
617:                setDisplayError(Boolean.TRUE);
618:                setAlertSummary(sm);
619:                setAlertDetail(detail);
620:                setAlertType(type);
621:                PSBaseBean.log(Level.FINEST, "SraBaseBean:displayAlert()");
622:                PSBaseBean.log(Level.FINEST, "summary = " + sm);
623:                PSBaseBean.log(Level.FINEST, "detail = " + detail);
624:            }
625:
626:            public void displayAlert(Object[] tokens, String summary,
627:                    String detail, String type) {
628:                String sm = getLocalizedString(RB_NAME, summary);
629:                if (tokens != null) {
630:                    String pattern = sm;
631:                    MessageFormat mf = new MessageFormat(pattern);
632:                    sm = mf.format(tokens);
633:                }
634:
635:                setDisplayError(Boolean.TRUE);
636:                setAlertSummary(sm);
637:                setAlertDetail(detail);
638:                setAlertType(type);
639:                PSBaseBean.log(Level.FINEST, "SraBaseBean:displayAlert()");
640:                PSBaseBean.log(Level.FINEST, "summary = " + sm);
641:                PSBaseBean.log(Level.FINEST, "detail = " + detail);
642:            }
643:
644:            protected abstract void initData();
645:
646:            {
647:            }
648:
649:            public boolean isServiceAssigned(String serviceName) {
650:                try {
651:                    MBeanServerConnection conn = getMBeanServerConnection();
652:                    if (conn != null) {
653:                        String methodToInvoke = "isServiceAssignedToOrg";
654:                        String dn = (String) getSessionAttribute(SessionAttributeNames.ATTR_CURRENT_LOCATION_DN);
655:                        Object params[] = { serviceName, dn };
656:                        String signature[] = { "java.lang.String",
657:                                "java.lang.String" };
658:
659:                        Object obj = invokeLocalSraMbean(methodToInvoke,
660:                                params, signature);
661:                        Boolean bool = (Boolean) obj;
662:                        PSBaseBean.log(Level.FINEST,
663:                                "Executed isServiceAssignedToOrg => " + bool);
664:
665:                        return bool.booleanValue();
666:                    }
667:                } catch (Exception e) {
668:                    PSBaseBean.log(Level.FINEST,
669:                            "Error in invoking isServiceAssignedToOrg ", e);
670:                }
671:
672:                return true;
673:            }
674:
675:            public void reset() {
676:                initDN();
677:                getDataFromStore();
678:                initData();
679:            }
680:
681:            public Option[] getCosValues() {
682:                return cosValues;
683:            }
684:
685:            public String getCosPriority() {
686:                return "" + getCosValueAsInt(COS_PRIORITY);
687:            }
688:
689:            public void setCosPriority(String value) {
690:                updateAttributeNVMap(COS_PRIORITY, value);
691:            }
692:
693:            public void validateHostName(FacesContext context,
694:                    UIComponent component, Object value)
695:                    throws ValidatorException {
696:                new HostDomainNameValidator().validate(context, component,
697:                        value);
698:            }
699:
700:            public void validateUrl(FacesContext context,
701:                    UIComponent component, Object value)
702:                    throws ValidatorException {
703:                new UrlFormatValidator().validate(context, component, value);
704:            }
705:
706:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.