Source Code Cross Referenced for CreateChannelBean.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: CreateChannelBean.java,v 1.28 2006/05/19 23:39:22 cathywu 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.Map;
016:        import java.util.Set;
017:        import java.util.Iterator;
018:        import java.util.LinkedList;
019:        import java.util.logging.Level;
020:
021:        import java.io.IOException;
022:
023:        import javax.management.ObjectName;
024:        import javax.management.InstanceNotFoundException;
025:        import javax.management.MBeanException;
026:        import javax.management.ReflectionException;
027:
028:        import javax.faces.context.FacesContext;
029:        import javax.faces.el.VariableResolver;
030:
031:        import com.sun.web.ui.model.Option;
032:
033:        import com.sun.web.ui.event.WizardEvent;
034:        import com.sun.web.ui.event.WizardEventListener;
035:
036:        import com.sun.portal.admin.common.util.AdminClientUtil;
037:        import com.sun.portal.admin.common.PSMBeanException;
038:        import com.sun.portal.admin.console.fabric.ListPortalsBean;
039:
040:        /**
041:         * @author cathywu
042:         */
043:        public class CreateChannelBean extends ChannelContainerBaseBean
044:                implements  WizardEventListener {
045:            private static final String PROVIDER = "Provider";
046:            private static final String PORTLET = "Portlet";
047:            private static final String REMOTE = "Remote";
048:            private static final String CONSUMER = "Consumer";
049:            private static final String CONFIGURED_PRODUCER_TYPE = AdminClientUtil.PORTAL_MBEAN_TYPE
050:                    + "." + CONSUMER + "." + "ConfiguredProducer";
051:
052:            private Option[] channelSelections = {
053:                    new Option(PROVIDER, "Provider"),
054:                    new Option(PORTLET, "Portlet"),
055:                    new Option(REMOTE, "Remote") };
056:            private String actionStatus = "";
057:            private String channelType;
058:            private String channelName;
059:            private String providerLabel;
060:            private Option[] providers;
061:            private String provider;
062:            private Option[] pProviders;
063:            private Option[] portlets;
064:            private Option[] containers;
065:            private String container;
066:            private Option[] producers;
067:            private Option[] remotePortlets;
068:            private String remotePortlet;
069:            private String selectContainerLabel = null;
070:            private Option[] contProviders;
071:            private String contProvider;
072:            private CreateContainerBean contBean;
073:            private String channelType_remotePortlet = "false";
074:            private String currentContainerLabel = null;
075:            private String currentContainer = null;
076:            private boolean containerSelected = false;
077:
078:            public CreateChannelBean() {
079:
080:                //setup initial screen
081:                if (rbMap != null) {
082:                    //initialize channel type selections
083:                    channelSelections[0].setLabel((String) rbMap
084:                            .get("createChannel.channelType.provider"));
085:                    channelSelections[0].setValue(PROVIDER);
086:                    channelSelections[1].setLabel((String) rbMap
087:                            .get("createChannel.channelType.portlet"));
088:                    channelSelections[1].setValue(PORTLET);
089:                    channelSelections[2].setLabel((String) rbMap
090:                            .get("createChannel.channelType.remote"));
091:                    channelSelections[2].setValue(REMOTE);
092:
093:                }
094:                setupTreeContainer();
095:
096:                contBean = new CreateContainerBean();
097:                if (channelOrContainer == null) {
098:                    setChannelOrContainer(CHANNEL);
099:                }
100:                channelType = (String) channelSelections[0].getValue();
101:            }
102:
103:            private void resetBean() {
104:                setChannelOrContainer(CHANNEL);
105:                setChannelType((String) channelSelections[0].getValue());
106:                setChannelName("");
107:                setDisplayError(new Boolean(false));
108:                setProvider("");
109:                contProvider = ("");
110:                setRemotePortlet("");
111:                channelType_remotePortlet = "";
112:            }
113:
114:            /**
115:             * Channel Type (step1_1)
116:             */
117:            public Object[] getChannelSelections() {
118:                if (getDisplayError() == Boolean.TRUE) {
119:                    setDisplayError(Boolean.FALSE);
120:                }
121:                return (Object[]) channelSelections;
122:            }
123:
124:            public void setChannelType(String value) {
125:                if (getDisplayError() == Boolean.TRUE) {
126:                    setDisplayError(Boolean.FALSE);
127:                }
128:
129:                channelType = value;
130:
131:                //Regenerate providers
132:                String cdn = (String) getCurrentDN();
133:                String cpid = (String) getSessionAttribute(ListPortalsBean.ATTR_SELECTED_PORTAL);
134:
135:                if (!dn.equals(cdn) || !cpid.equals(portalId)) {
136:                    dn = cdn;
137:                    portalId = cpid;
138:                }
139:            }
140:
141:            public String getChannelType() {
142:                if (getChannelOrContainer().equals(CHANNEL)) {
143:                    return channelType;
144:                } else {
145:                    return "";
146:                }
147:            }
148:
149:            public String getChannelType_remotePortlet() {
150:                return channelType_remotePortlet;
151:            }
152:
153:            /**
154:             * Provider page
155:             */
156:            public String getChannelName() {
157:                if (getDisplayError() == Boolean.TRUE) {
158:                    setDisplayError(Boolean.FALSE);
159:                }
160:                return channelName;
161:            }
162:
163:            public void setChannelName(String value) {
164:                channelName = value;
165:            }
166:
167:            public String getProviderLabel() {
168:                if (getChannelOrContainer().equals(CHANNEL)) {
169:                    if (getChannelType().equals(PROVIDER)) {
170:                        providerLabel = (String) rbMap
171:                                .get("createChannel.provider.label");
172:                    } else if (getChannelType().equals(PORTLET)) {
173:                        providerLabel = (String) rbMap
174:                                .get("createChannel.portlet.label");
175:                    } else if (getChannelType().equals(REMOTE)) {
176:                        providerLabel = (String) rbMap
177:                                .get("createChannel.producer.label");
178:                    }
179:                } else {
180:                    providerLabel = (String) rbMap
181:                            .get("createContainer.contProvider.label");
182:                }
183:
184:                setProviderLabel(providerLabel);
185:
186:                return providerLabel;
187:            }
188:
189:            public String getTypeLabel() {
190:                if (getChannelOrContainer().equals(CHANNEL)) {
191:                    return (String) rbMap
192:                            .get("createChannel.verify.channelType");
193:                } else {
194:                    return (String) rbMap.get("createChannel.verify.container");
195:                }
196:            }
197:
198:            public void setProviderLabel(String value) {
199:                providerLabel = value;
200:            }
201:
202:            public Option[] getProviders() {
203:                return providers;
204:            }
205:
206:            public String getProviderDisplayName() {
207:                return getDisplayName(getProvider(), getProviders());
208:            }
209:
210:            public String getProvider() {
211:                if (getDisplayError() == Boolean.TRUE) {
212:                    setDisplayError(Boolean.FALSE);
213:                }
214:
215:                return provider;
216:            }
217:
218:            public void setProvider(String val) {
219:                provider = val;
220:            }
221:
222:            public Option[] getRemotePortlets() {
223:                return remotePortlets;
224:            }
225:
226:            public String getRemotePortletDisplayName() {
227:                return getDisplayName(getRemotePortlet(), getRemotePortlets());
228:            }
229:
230:            public String getRemotePortlet() {
231:                if (getDisplayError() == Boolean.TRUE) {
232:                    setDisplayError(Boolean.FALSE);
233:                }
234:
235:                return remotePortlet;
236:            }
237:
238:            public void setRemotePortlet(String remotePortlet) {
239:                this .remotePortlet = remotePortlet;
240:            }
241:
242:            private Option[] setupProviders() {
243:                Object[] params = { dn };
244:                String[] signature = { "java.lang.String" };
245:                pProviders = null;
246:
247:                Set ps = null;
248:                try {
249:                    ps = (Set) invokeMethod("DisplayProfile",
250:                            "getExistingProviders", params, signature);
251:                } catch (Exception e) {
252:                    return pProviders;
253:                }
254:
255:                int size = ps.size();
256:                if (size != 0) {
257:                    pProviders = new Option[size];
258:                    int ind = 0;
259:                    for (Iterator i = ps.iterator(); i.hasNext();) {
260:                        String next = (String) i.next();
261:                        pProviders[ind] = new Option(next, next);
262:                        ind++;
263:                    }
264:                }
265:
266:                return pProviders;
267:            }
268:
269:            private Option[] getPProviders() {
270:                return pProviders;
271:            }
272:
273:            /**
274:             * Portlets page
275:             */
276:            private Option[] setupPortlets() {
277:                Object[] params = { dn };
278:                String[] signature = { "java.lang.String" };
279:                portlets = null;
280:
281:                Set ps = null;
282:                try {
283:                    ps = (Set) invokeMethod("PortletAdmin",
284:                            "getExistingPortlets", params, signature);
285:                } catch (Exception e) {
286:                    return portlets;
287:                }
288:
289:                int size = ps.size();
290:                if (size != 0) {
291:                    portlets = new Option[size];
292:                    int ind = 0;
293:                    for (Iterator i = ps.iterator(); i.hasNext();) {
294:                        String next = (String) i.next();
295:                        portlets[ind] = new Option(next, next);
296:                        ind++;
297:                    }
298:                }
299:
300:                return portlets;
301:            }
302:
303:            private Option[] getPortlets() {
304:                return portlets;
305:            }
306:
307:            private Option[] setupProducers() {
308:                Object[] params = { dn };
309:                String[] signature = { String.class.getName() };
310:                Map cps = null;
311:
312:                producers = null;
313:
314:                try {
315:                    cps = (Map) invokeMethod(CONSUMER,
316:                            "listConfiguredProducers", params, signature);
317:                } catch (Exception e) {
318:                    return producers;
319:                }
320:
321:                int size = (cps == null) ? 0 : cps.size();
322:
323:                if (size != 0) {
324:                    producers = new Option[size];
325:                    Set entrySet = cps.entrySet();
326:                    int index = 0;
327:
328:                    for (Iterator i = entrySet.iterator(); i.hasNext();) {
329:                        Map.Entry entry = (Map.Entry) i.next();
330:                        String id = (String) entry.getKey();
331:                        String name = (String) entry.getValue();
332:                        producers[index++] = new Option(id, name);
333:                    }
334:                }
335:
336:                return producers;
337:            }
338:
339:            private Option[] getProducers() {
340:                return producers;
341:            }
342:
343:            private void setupRemotePortlets() {
344:                LinkedList path = new LinkedList();
345:                path.addFirst(getDomain());
346:                path.addFirst(portalId);
347:                path.addFirst(CONSUMER);
348:                path.addFirst(getProvider());
349:                Object[] params = { dn };
350:                String[] signature = { String.class.getName() };
351:                Map rps = null;
352:
353:                remotePortlets = null;
354:
355:                try {
356:                    ObjectName objectName = AdminClientUtil
357:                            .getResourceMBeanObjectName(
358:                                    CONFIGURED_PRODUCER_TYPE, path);
359:
360:                    rps = (Map) getMBeanServerConnection().invoke(objectName,
361:                            "getPortlets", params, signature);
362:                } catch (Exception e) {
363:                    // TODO: handle exception            
364:                    log(
365:                            Level.SEVERE,
366:                            "Exception in CreateChannelBean.setupRemotePortlets()",
367:                            e);
368:                }
369:
370:                int size = rps.size();
371:
372:                if (size != 0) {
373:                    remotePortlets = new Option[size];
374:                    Set entrySet = rps.entrySet();
375:                    int index = 0;
376:
377:                    for (Iterator i = entrySet.iterator(); i.hasNext();) {
378:                        Map.Entry entry = (Map.Entry) i.next();
379:                        String handle = (String) entry.getKey();
380:                        String name = (String) entry.getValue();
381:                        remotePortlets[index++] = new Option(handle, name);
382:                    }
383:                    remotePortlet = (String) remotePortlets[0].getValue();
384:                }
385:            }
386:
387:            public boolean isContainerSelected() {
388:                if (getTreeContainer() != null) {
389:                    return true;
390:                } else {
391:                    return false;
392:                }
393:            }
394:
395:            public void setContainerSelected(boolean val) {
396:                containerSelected = val;
397:            }
398:
399:            public String getCurrentContainerLabel() {
400:                String ccl = null;
401:                if (getTreeContainer() != null) {
402:                    ccl = (String) rbMap
403:                            .get("createChannel.currentContainerLabel");
404:                } else {
405:                    ccl = (String) rbMap
406:                            .get("createChannel.selectContainerLabel.null");
407:                }
408:                setCurrentContainerLabel(ccl);
409:
410:                return ccl;
411:            }
412:
413:            public void setCurrentContainerLabel(String val) {
414:                currentContainerLabel = val;
415:            }
416:
417:            public String getCurrentContainer() {
418:                String cc = "";
419:                if (getTreeContainer() != null) {
420:                    cc = getTreeContainer();
421:                }
422:                setCurrentContainer(cc);
423:
424:                return cc;
425:            }
426:
427:            public void setCurrentContainer(String val) {
428:                currentContainer = val;
429:            }
430:
431:            // If treeContainer is null, show the selectContainer dropDown,
432:            // else don't show.
433:            public boolean getRenderDropDown() {
434:                if (getTreeContainer() == null) {
435:                    return true;
436:                } else {
437:                    return false;
438:                }
439:            }
440:
441:            private Option[] setupContainers() {
442:
443:                Object[] params = { dn, Boolean.TRUE };
444:                String[] signature = { "java.lang.String", "java.lang.Boolean" };
445:                Set cs = null;
446:
447:                containers = new Option[1];
448:                containers[0] = new Option("", "");
449:
450:                try {
451:                    cs = (Set) invokeMethod("DisplayProfile",
452:                            "getExistingContainers", params, signature);
453:                } catch (Exception e) {
454:                    return containers;
455:                }
456:
457:                int size = cs.size();
458:                if (size != 0) {
459:                    containers = new Option[size];
460:                    int ind = 0;
461:                    for (Iterator i = cs.iterator(); i.hasNext();) {
462:                        String next = (String) i.next();
463:                        containers[ind] = new Option(next, next);
464:                        ind++;
465:                    }
466:                }
467:
468:                return containers;
469:            }
470:
471:            /**
472:             * Implementation methods for StateHolder
473:             */
474:            public boolean handleEvent(WizardEvent event) {
475:
476:                switch (event.getNavigationEvent()) {
477:
478:                case WizardEvent.PREVIOUS:
479:                    break;
480:
481:                case WizardEvent.NEXT:
482:                    setDisplayError(new Boolean(false));
483:                    String id = event.getWizard().getCurrentStep().getId();
484:                    log(Level.FINEST, "CreateChannel.handleEvent(), event id: "
485:                            + id);
486:                    log(Level.FINEST,
487:                            "CreateChannel.handleEvent(), channel or container: "
488:                                    + channelOrContainer);
489:                    log(Level.FINEST,
490:                            "CreateChannel.handleEvent(), channeltype: "
491:                                    + channelType);
492:
493:                    if (id.equals("step1")) {
494:                        if (getChannelOrContainer().length() == 0) {
495:                            setupAlert(
496:                                    null,
497:                                    "error.createChannel.summary",
498:                                    "error.createChannel.empty.channelOrContainer",
499:                                    "error", null, null);
500:                            return false;
501:                        }
502:
503:                        if (getChannelOrContainer().equals(CONTAINER)) {
504:                            channelType_remotePortlet = "false";
505:                            providers = contBean.setupContProviders();
506:                            if (providers == null) {
507:                                String msgkey = "error.createContainer.empty.providers";
508:                                setupAlert(null, "error.createChannel.summary",
509:                                        msgkey, "error", null, null);
510:                                return false;
511:                            }
512:                        } else {
513:                            setChannelType(PROVIDER);
514:                        }
515:                    } else if (id.equals("step1_1")) {
516:                        if (getChannelOrContainer().equals(CHANNEL)) {
517:                            if (getChannelType().equals(PROVIDER)) {
518:                                providers = setupProviders();
519:                                channelType_remotePortlet = "false";
520:                            } else if (getChannelType().equals(PORTLET)) {
521:                                providers = setupPortlets();
522:                                channelType_remotePortlet = "false";
523:                            } else if (getChannelType().equals(REMOTE)) {
524:                                providers = setupProducers();
525:                                channelType_remotePortlet = "true";
526:                            }
527:                            if (providers == null) {
528:                                String msgkey = null;
529:                                if (getChannelType().equals(PROVIDER)) {
530:                                    msgkey = "error.createChannel.empty.providers";
531:                                } else if (getChannelType().equals(PORTLET)) {
532:                                    msgkey = "error.createChannel.empty.portlets";
533:                                } else if (getChannelType().equals(REMOTE)) {
534:                                    msgkey = "error.createChannel.empty.producers";
535:                                }
536:
537:                                setupAlert(null, "error.createChannel.summary",
538:                                        msgkey, "error", null, null);
539:                                return false;
540:                            }
541:                        }
542:                    } else if (id.equals("step2")) {
543:
544:                        containers = setupContainers();
545:                        if (getChannelType().equals(REMOTE)) {
546:                            setupRemotePortlets();
547:                            if (remotePortlets == null) {
548:                                String msgkey = "error.createChannel.empty.portlets";
549:                                setupAlert(null, "error.createChannel.summary",
550:                                        msgkey, "error", null, null);
551:                                return false;
552:                            }
553:                        }
554:                    }
555:
556:                    break;
557:                case WizardEvent.CANCEL:
558:                    resetBean();
559:                    break;
560:                case WizardEvent.CLOSE:
561:                    resetBean();
562:                    break;
563:                case WizardEvent.FINISH:
564:                    createChannel();
565:                    break;
566:                case WizardEvent.START:
567:                    //log(Level.FINEST,"CreateChannel.handleEvent(), START! ");
568:                case WizardEvent.COMPLETE:
569:                    resetBean();
570:                    break;
571:                default:
572:                    break;
573:                }
574:
575:                return true;
576:            }
577:
578:            /**
579:             * Implementation methods for StateHolder
580:             */
581:            public boolean isTransient() {
582:                return false;
583:            }
584:
585:            public void setTransient(boolean flag) {
586:            }
587:
588:            public Object saveState(FacesContext context) {
589:                return null;
590:            }
591:
592:            public void restoreState(FacesContext context, Object state) {
593:            }
594:
595:            /**
596:             * createChannel 
597:             */
598:            public String createChannel() {
599:
600:                // Get Current selected container name
601:                String selectedContainer = getTreeContainer();
602:                ObjectName on = null;
603:                String op = null;
604:                String createdChannel = getChannelName();
605:                boolean succeed = false;
606:
607:                if (selectedContainer != null) {
608:                    createdChannel = new String(selectedContainer
609:                            + EditPropertiesBean.CHANNEL_NAME_SEPARATOR_CHAR
610:                            + createdChannel);
611:                }
612:
613:                log(Level.FINE, "CreateChannelBean.createChannel(), channel: "
614:                        + createdChannel);
615:                //use CreateContainerBean to create a container
616:                if (getChannelOrContainer().equals(CONTAINER)) {
617:                    log(Level.FINE,
618:                            "CreateChannelBean.createChannel(), selectedContainer: "
619:                                    + selectedContainer);
620:                    log(Level.FINE,
621:                            "CreateChannelBean.createChannel(), provider: "
622:                                    + getProvider());
623:                    succeed = contBean.createContainer(this , selectedContainer,
624:                            createdChannel, getProvider());
625:                } else {
626:                    log(Level.FINE,
627:                            "CreateChannelBean.createChannel(), provider: "
628:                                    + getProvider());
629:                    log(Level.FINE,
630:                            "CreateChannelBean.createChannel(), channel type: "
631:                                    + getChannelType());
632:
633:                    Object[] params = new Object[3];
634:                    String[] signature = { "java.lang.String",
635:                            "java.lang.String", "java.lang.String" };
636:                    try {
637:                        if (getChannelType().equals(PROVIDER)) {
638:                            params[0] = dn;
639:                            params[1] = createdChannel;
640:                            params[2] = getProvider();
641:                            invokeMethod("DisplayProfile", "createChannel",
642:                                    params, signature);
643:                            succeed = true;
644:                        } else if (getChannelType().equals(PORTLET)) {
645:                            params[0] = dn;
646:                            params[1] = createdChannel;
647:                            params[2] = getProvider();
648:                            invokeMethod("PortletAdmin",
649:                                    "createPortletChannel", params, signature);
650:                            succeed = true;
651:                        } else if (getChannelType().equals(REMOTE)) {
652:                            params[0] = dn;
653:                            params[1] = createdChannel;
654:                            params[2] = getRemotePortlet();
655:                            LinkedList path = new LinkedList();
656:                            path.addFirst(getDomain());
657:                            path.addFirst(portalId);
658:                            path.addFirst(CONSUMER);
659:                            path.addFirst(getProvider());
660:
661:                            ObjectName objectName = AdminClientUtil
662:                                    .getResourceMBeanObjectName(
663:                                            CONFIGURED_PRODUCER_TYPE, path);
664:                            try {
665:                                getMBeanServerConnection().invoke(objectName,
666:                                        "createRemoteChannel", params,
667:                                        signature);
668:                                succeed = true;
669:                            } catch (MBeanException me) {
670:                                log(Level.SEVERE,
671:                                        "CreateChannelBean.createChannel(): Failed to create WSRP channel: "
672:                                                + createdChannel
673:                                                + " due to MBeanException ", me);
674:                                String alertDetailKey = null;
675:                                Object[] tokens = null;
676:                                String message = null;
677:
678:                                if (me.getCause() != null
679:                                        && me.getCause() instanceof  PSMBeanException) {
680:                                    alertDetailKey = ((PSMBeanException) me
681:                                            .getCause()).getErrorKey();
682:                                    tokens = ((PSMBeanException) me.getCause())
683:                                            .getTokens();
684:                                    message = composeLogMessage(((PSMBeanException) me
685:                                            .getCause()));
686:                                } else {
687:                                    message = composeLogMessage(me);
688:                                }
689:
690:                                if (alertDetailKey == null) {
691:                                    alertDetailKey = "error.createChannel.failed.checkLogs";
692:                                    tokens = new Object[] { createdChannel };
693:                                }
694:
695:                                setupAlert(tokens,
696:                                        "error.createChannel.summary",
697:                                        alertDetailKey, "error",
698:                                        "error.createChannel.failed.checkLogs",
699:                                        message);
700:                                return "error";
701:
702:                            } catch (Exception re) {
703:                                setupAlert(new Object[] { createdChannel },
704:                                        "error.createChannel.summary",
705:                                        "error.createChannel.failed.checkLogs",
706:                                        "error", null, composeLogMessage(re));
707:                                log(
708:                                        Level.SEVERE,
709:                                        "Exception in CreateChannelBean.createChannel()",
710:                                        re);
711:                                return "error";
712:                            }
713:                        } else {
714:                            setupAlert(null, "createChannel.summary",
715:                                    "createChannel.notYetImplemented",
716:                                    "information", null, null);
717:                            return "error";
718:                        }
719:                    } catch (MBeanException me) {
720:                        log(Level.SEVERE,
721:                                "CreateChannelBean.createChannel(): Failed to create channel "
722:                                        + createdChannel
723:                                        + " due to MBeanException ", me);
724:                        String alertDetailKey = null;
725:                        Object[] tokens = null;
726:                        String message = null;
727:
728:                        if (me.getCause() != null
729:                                && me.getCause() instanceof  PSMBeanException) {
730:                            alertDetailKey = ((PSMBeanException) me.getCause())
731:                                    .getErrorKey();
732:                            tokens = ((PSMBeanException) me.getCause())
733:                                    .getTokens();
734:                            message = composeLogMessage(((PSMBeanException) me
735:                                    .getCause()));
736:                        } else {
737:                            message = composeLogMessage(me);
738:                        }
739:
740:                        if (alertDetailKey == null) {
741:                            alertDetailKey = "error.createChannel.failed.checkLogs";
742:                            tokens = new Object[] { createdChannel };
743:                        }
744:
745:                        setupAlert(tokens, "error.createChannel.summary",
746:                                alertDetailKey, "error",
747:                                "error.createChannel.failed.checkLogs", message);
748:                        return "error";
749:                    } catch (Exception e) {
750:                        log(
751:                                Level.SEVERE,
752:                                "CreateChannelBean.createChannel(): Create channel failed",
753:                                e);
754:                        setupAlert(new Object[] { createdChannel },
755:                                "error.createChannel.summary",
756:                                "error.createChannel.failed.checkLogs",
757:                                "error", null, composeLogMessage(e));
758:                        return "error";
759:                    }
760:                }
761:
762:                setRegenerate(true);
763:
764:                if (succeed) {
765:
766:                    String retStr = doAddChannel(createdChannel);
767:                    if (retStr.equals("channelAdded")) {
768:                        //set the tree view selection on the newly created channel
769:                        setSessionAttribute(ATTR_SELECTED_TREE_CHANNEL,
770:                                createdChannel);
771:                        Object[] tokens = null;
772:                        if (selectedContainer != null) {
773:                            tokens = new Object[] { selectedContainer };
774:                        }
775:
776:                        setupAlert(tokens, "createChannel.summary",
777:                                "createChannel.completed.channelAdded",
778:                                "information", null, null);
779:                    } else if (retStr.equals("channelNotAdded")) {
780:                        //set the tree view selection on the newly created channel
781:                        setSessionAttribute(ATTR_SELECTED_TREE_CHANNEL,
782:                                createdChannel);
783:                        //set the tree view selection on the XML DP Tree view
784:                        setSessionAttribute(ATTR_SELECTED_TREE_CONTAINER,
785:                                TreeViewerBean.TYPE_PHYSICAL_TREE);
786:                        Object[] tokens = { (String) rbMap
787:                                .get("tasks.addRemove.channel") };
788:                        setupAlert(tokens, "createChannel.summary",
789:                                "createChannel.completed.channelNotAdded",
790:                                "information", null, null);
791:                    } else {
792:                        setupAlert(null, "error.createChannel.summary", retStr,
793:                                "error", null, null);
794:                    }
795:                }
796:
797:                setRegenerate(true);
798:
799:                return "done";
800:            }
801:
802:            private String doAddChannel(String createdChannel) {
803:
804:                FacesContext fc = FacesContext.getCurrentInstance();
805:                VariableResolver vr = fc.getApplication().getVariableResolver();
806:                Object obj = (AddChannelBean) vr.resolveVariable(fc,
807:                        "AddChannelBean");
808:                AddChannelBean acb = null;
809:
810:                if (obj == null) {
811:                    return "error.createChannel.failed.checkLogs.noToken";
812:                } else if ((obj instanceof  AddChannelBean)) {
813:                    acb = (AddChannelBean) obj;
814:                }
815:
816:                String container = getTreeContainer();
817:
818:                if (container != null) {
819:                    String[] selectedChannels = new String[1];
820:                    acb.setState(AddChannelBean.VISIBLE);
821:                    selectedChannels[0] = createdChannel;
822:
823:                    log(Level.FINE,
824:                            "CreateChannelBean.doAddChannel(), adding channel: "
825:                                    + selectedChannels[0] + " in " + container);
826:
827:                    acb.setSelectedChannels(selectedChannels);
828:                    acb.setContainer(container);
829:                    acb.add();
830:                    return "channelAdded";
831:                } else {
832:                    return "channelNotAdded";
833:                }
834:            }
835:
836:            private Object invokeMethod(String namePath, String operation,
837:                    Object[] params, String[] signature) throws MBeanException,
838:                    Exception {
839:
840:                Object returnVal = null;
841:                LinkedList path = new LinkedList();
842:                path.addFirst(getDomain());
843:                path.addFirst(portalId);
844:                path.addFirst(namePath);
845:
846:                log(Level.FINE, "CreateChannelBean.invokeMethod(), dn: " + dn);
847:                log(Level.FINE, "CreateChannelBean.invokeMethod(), portalId: "
848:                        + portalId);
849:                log(Level.FINE, "CreateChannelBean.invokeMethod(), operation: "
850:                        + operation);
851:
852:                try {
853:                    ObjectName on = AdminClientUtil.getResourceMBeanObjectName(
854:                            AdminClientUtil.PORTAL_MBEAN_TYPE + "." + namePath,
855:                            path);
856:                    returnVal = mbsc.invoke(on, operation, params, signature);
857:                } catch (MBeanException me) {
858:                    throw me;
859:                } catch (Exception e) {
860:                    throw e;
861:                }
862:
863:                return returnVal;
864:            }
865:
866:            private String getDisplayName(String value, Option[] optionArray) {
867:                for (int i = 0; i < optionArray.length; i++) {
868:                    Option option = optionArray[i];
869:
870:                    if (value.equals(option.getValue())) {
871:                        return option.getLabel();
872:                    }
873:                }
874:
875:                return value;
876:            }
877:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.