Source Code Cross Referenced for TabData.java in  » Portal » Open-Portal » com » sun » portal » providers » containers » jsp » tab » util » 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.providers.containers.jsp.tab.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002 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:         */
013:        package com.sun.portal.providers.containers.jsp.tab.util;
014:
015:        import java.util.List;
016:        import java.util.ArrayList;
017:
018:        import java.util.Map;
019:        import java.util.HashMap;
020:        import java.util.Iterator;
021:        import java.util.Enumeration;
022:        import java.util.Set;
023:        import java.util.ResourceBundle;
024:        import java.util.logging.Level;
025:        import java.util.logging.LogRecord;
026:        import java.util.logging.Logger;
027:
028:        import java.net.URL;
029:        import java.net.MalformedURLException;
030:
031:        import javax.servlet.http.HttpServletRequest;
032:
033:        import com.sun.portal.desktop.context.ContextException;
034:
035:        import com.sun.portal.providers.context.ContainerProviderContext;
036:        import com.sun.portal.providers.context.ProviderContextException;
037:        import com.sun.portal.providers.ProviderException;
038:        import com.sun.portal.providers.containers.jsp.tab.ModifiableTab;
039:        import com.sun.portal.providers.containers.jsp.tab.UnmodifiableTab;
040:        import com.sun.portal.log.common.PortalLogger;
041:
042:        public class TabData {
043:
044:            private ContainerProviderContext containerProvidercontext = null;
045:            private String channel = null;
046:            private String props_key = "TabProperties";
047:            private ResourceBundle bundle = null;
048:            private static Logger logger = PortalLogger
049:                    .getLogger(TabData.class);
050:
051:            public TabData(ContainerProviderContext cpc, String channel,
052:                    ResourceBundle bundle) {
053:                this .channel = channel;
054:                containerProvidercontext = cpc;
055:                this .bundle = bundle;
056:            }
057:
058:            public int getMaxTabs() throws TabException {
059:                try {
060:                    return containerProvidercontext.getIntegerProperty(channel,
061:                            "maxTabs");
062:                } catch (ProviderContextException pce) {
063:                    throw new TabException("TabData.getMaxTabs(): ", pce);
064:                }
065:            }
066:
067:            public List getSelectedTabs() throws TabException {
068:                List tabs = new ArrayList();
069:                List t = null;
070:                int size = 0;
071:                Map tabPropsMap = getTabPropsMap();
072:
073:                try {
074:                    t = containerProvidercontext.getSelectedChannels(channel);
075:                    size = t.size();
076:                } catch (ProviderContextException pce) {
077:                    throw new TabException("TabData.getSelectedTabs(): ", pce);
078:                }
079:                for (int i = 0; i < size; i++) {
080:                    String e = (String) t.get(i);
081:                    UnmodifiableTab tab = TabFactory.createUnmodifiable(e,
082:                            containerProvidercontext, channel, tabPropsMap);
083:                    if (tab.getDisplayname() != null) {
084:                        tabs.add(tab);
085:                    }
086:                }
087:                return tabs;
088:            }
089:
090:            public List getAvailableTabs() throws TabException {
091:                List tabs = new ArrayList();
092:                List t = null;
093:                int size = 0;
094:                Map tabPropsMap = getTabPropsMap();
095:
096:                try {
097:                    t = containerProvidercontext.getAvailableChannels(channel);
098:                    size = t.size();
099:                } catch (ProviderContextException pce) {
100:                    throw new TabException("TabData.getAvailableTabs(): ", pce);
101:                }
102:                for (int i = 0; i < size; i++) {
103:                    String e = (String) t.get(i);
104:                    UnmodifiableTab tab = TabFactory.createUnmodifiable(e,
105:                            containerProvidercontext, channel, tabPropsMap);
106:                    if (tab.getDisplayname() != null) {
107:                        tabs.add(tab);
108:                    }
109:                }
110:                return tabs;
111:            }
112:
113:            public UnmodifiableTab getStartTab() throws TabException {
114:                String name = getStartTabName();
115:                Map tabPropsMap = getTabPropsMap();
116:                UnmodifiableTab t = TabFactory.createUnmodifiable(name,
117:                        containerProvidercontext, channel, tabPropsMap);
118:                return t;
119:            }
120:
121:            public String getStartTabName() throws TabException {
122:                try {
123:                    return containerProvidercontext.getStringProperty(channel,
124:                            "startTab");
125:                } catch (ProviderContextException pce) {
126:                    throw new TabException("TabData.getStartTabName(): ", pce);
127:                }
128:            }
129:
130:            public UnmodifiableTab getMakeTab() throws TabException {
131:                String m = getMakeTabName();
132:                Map tabPropsMap = getTabPropsMap();
133:                UnmodifiableTab maketab = TabFactory.createUnmodifiable(m,
134:                        containerProvidercontext, channel, tabPropsMap);
135:                return maketab;
136:            }
137:
138:            public String getMakeTabName() throws TabException {
139:                try {
140:                    return containerProvidercontext.getStringProperty(channel,
141:                            "makeTabChannel");
142:                } catch (ProviderContextException pce) {
143:                    throw new TabException("TabData.getMakeTabName(): ", pce);
144:                }
145:            }
146:
147:            public String getMakeTabProviderName() throws TabException {
148:                try {
149:                    return containerProvidercontext.getStringProperty(channel,
150:                            "makeTabProvider");
151:                } catch (ProviderContextException pce) {
152:                    throw new TabException(
153:                            "TabData.getMakeTabProviderName(): ", pce);
154:                }
155:            }
156:
157:            public String getSelectedTabName() throws TabException {
158:                String name = null;
159:
160:                try {
161:                    String n = containerProvidercontext
162:                            .getClientProperty(channel + ".selectedTab");
163:                    if (n != null
164:                            && n.length() > 0
165:                            && containerProvidercontext.getAvailableChannels(
166:                                    channel).contains(n)) {
167:                        name = n;
168:
169:                    } else {
170:                        n = getStartTabName();
171:                        if (n != null
172:                                && n.length() > 0
173:                                && containerProvidercontext
174:                                        .getAvailableChannels(channel)
175:                                        .contains(n)) {
176:                            name = n;
177:                        } else {
178:                            if (containerProvidercontext.getAvailableChannels(
179:                                    channel).size() == 0) {
180:                                throw new TabException(
181:                                        "TabData.getSelectedName(): No channel available for selection");
182:                            }
183:                            n = (String) containerProvidercontext
184:                                    .getAvailableChannels(channel).get(0);
185:                            setStartTabName(n);
186:                            name = n;
187:                        }
188:                        setSelectedTabName(n);
189:                    }
190:                } catch (ProviderContextException pce) {
191:                    throw new TabException("TabData.getSelectedName(): ", pce);
192:                }
193:
194:                return name;
195:            }
196:
197:            public UnmodifiableTab getSelectedTab() throws TabException {
198:                String name = getSelectedTabName();
199:                Map tabPropsMap = getTabPropsMap();
200:                UnmodifiableTab selectedTab = TabFactory.createUnmodifiable(
201:                        name, containerProvidercontext, channel, tabPropsMap);
202:                return selectedTab;
203:            }
204:
205:            public UnmodifiableTab getTab(String name) throws TabException {
206:                Map tabPropsMap = getTabPropsMap();
207:
208:                UnmodifiableTab t = TabFactory.createUnmodifiable(name,
209:                        containerProvidercontext, channel, tabPropsMap);
210:                if (t == null) {
211:                    throw new TabException(
212:                            "TabData.getTab():couldn't get tab name=" + t);
213:                }
214:                return t;
215:            }
216:
217:            public void setTab(ModifiableTab t, boolean selected)
218:                    throws TabException {
219:                if (t == null) {
220:                    throw new TabException(
221:                            "TabData.setTab():tried to set null tab");
222:                }
223:                addSelectedTab(t);
224:                if (selected) {
225:                    setSelectedTabName(t.getName());
226:                }
227:            }
228:
229:            public void setStartTabName(String name) throws TabException {
230:                //
231:                // verify the start tab points to an actual tab
232:                //
233:                getTab(name);
234:                writeStartTabName(name);
235:            }
236:
237:            public void setSelectedTabName(String tabName) throws TabException {
238:                //
239:                // verify the selected tab points to an actual tab
240:                //
241:                try {
242:                    getTab(tabName);
243:                } catch (TabException te) {
244:                    throw new TabException(
245:                            "TabData.setSelectedTabName():attempt to set selected to non-existent tab");
246:                }
247:                writeSelectedTabName(tabName);
248:            }
249:
250:            private void writeStartTabName(String name) throws TabException {
251:                try {
252:                    containerProvidercontext.setStringProperty(channel,
253:                            "startTab", name);
254:                } catch (ProviderContextException pce) {
255:                    throw new TabException("TabData.writeStartTabName(): ", pce);
256:                }
257:            }
258:
259:            public void addSelectedTab(ModifiableTab t) throws TabException {
260:                try {
261:                    List selectedChannels = containerProvidercontext
262:                            .getSelectedChannels(channel);
263:                    if (!selectedChannels.contains(t.getName())) {
264:                        selectedChannels.add(t.getName());
265:                        containerProvidercontext.setSelectedChannels(channel,
266:                                selectedChannels);
267:                    }
268:                    if (containerProvidercontext.getProviderVersion(channel) <= 1) {
269:                        Map tabPropsMap = getTabPropsMap();
270:                        Map tabMap = (Map) tabPropsMap.get(t.getName());
271:                        tabMap = t.getTabMap();
272:                        containerProvidercontext.setCollectionProperty(channel,
273:                                props_key, tabPropsMap);
274:                    } else {
275:                        List pflist = containerProvidercontext
276:                                .getLocalePropertiesFilters();
277:                        containerProvidercontext.setStringProperty(t.getName(),
278:                                "title", t.getDisplayname(), pflist);
279:                        containerProvidercontext.setStringProperty(t.getName(),
280:                                "description", t.getDesc(), pflist);
281:                    }
282:                } catch (ProviderContextException pce) {
283:                    throw new TabException("TabData.addSelectedTab(): ", pce);
284:                }
285:            }
286:
287:            public void addTab(String name, String title) throws TabException {
288:                UnmodifiableTab tab = getTab(name);
289:                ModifiableTab newTab = TabFactory.createModifiable(tab,
290:                        containerProvidercontext, channel);
291:                newTab.setDisplayname(title);
292:                //
293:                // save the new tab in the tab list
294:                //
295:                setTab(newTab, true);
296:            }
297:
298:            public URL getTabURL(UnmodifiableTab tab, HttpServletRequest req)
299:                    throws TabException {
300:
301:                URL url;
302:
303:                boolean enableProcessUrl = false;
304:                try {
305:                    enableProcessUrl = containerProvidercontext
306:                            .getBooleanProperty(channel, "enableProcessEdit");
307:                } catch (ProviderContextException e) {
308:                    logger.log(Level.WARNING, "PSDT_CSPPCJTB0003", e);
309:                }
310:
311:                StringBuffer urlbuffer = new StringBuffer(
312:                        containerProvidercontext.getDesktopURL(req));
313:
314:                if (enableProcessUrl) {
315:                    urlbuffer.append("?action=process&provider=");
316:                    urlbuffer.append(channel);
317:                    urlbuffer.append("&").append(channel).append(
318:                            ".setSelected=");
319:                    urlbuffer.append(tab.getEncodedName());
320:                    urlbuffer.append("&last=false");
321:                } else {
322:                    urlbuffer.append("?");
323:                    urlbuffer.append(channel);
324:                    urlbuffer.append(".setSelected=");
325:                    urlbuffer.append(tab.getEncodedName());
326:                    urlbuffer.append("&last=false");
327:                }
328:
329:                try {
330:                    url = new URL(urlbuffer.toString());
331:                } catch (MalformedURLException me) {
332:                    throw new TabException(
333:                            "TabData.getTabURL():couldn't create the url", me);
334:                }
335:                return url;
336:            }
337:
338:            public URL removeRenameTab(HttpServletRequest req)
339:                    throws ProviderException {
340:                URL url = null;
341:                //
342:                // process remove/rename operations
343:                //
344:                UnmodifiableTab startTab = null;
345:                UnmodifiableTab selectedTab = null;
346:
347:                //
348:                // get the start tab name, so we can make sure and re-set it to the
349:                // selected tab if the remove it.  the user is not allowed to remove
350:                // the selected tab .
351:                //
352:                startTab = getStartTab();
353:
354:                //
355:                // get the selected tab.  if the user renames the selected tab, we must
356:                // make sure and change the selected tab in the session to the new value.
357:                //
358:                selectedTab = getSelectedTab();
359:
360:                String removeTag = channel + "_remove_";
361:                String renameTag = channel + "_rename_";
362:                String startTag = channel + ".setStart";
363:
364:                for (Enumeration e = req.getParameterNames(); e
365:                        .hasMoreElements();) {
366:                    String key = (String) e.nextElement();
367:                    String val = req.getParameter(key);
368:                    try {
369:                        if (key.startsWith(removeTag)) {
370:                            //
371:                            // remove
372:                            //
373:                            String tabName = key
374:                                    .substring(key.lastIndexOf("_") + 1);
375:                            if (val.equals("1")) {
376:                                if (getSelectedTabs().size() == 1) {
377:                                    String err = bundle
378:                                            .getString("deleteOnlyTab");
379:                                    throw new TabEditException(err);
380:                                }
381:                                removeTab(tabName);
382:                                try {
383:                                    StringBuffer urlbuffer = new StringBuffer(
384:                                            containerProvidercontext
385:                                                    .getDesktopURL(req));
386:                                    urlbuffer.append("?action=edit&provider=");
387:                                    urlbuffer.append(channel);
388:                                    url = new URL(urlbuffer.toString());
389:                                } catch (MalformedURLException me) {
390:                                    throw new TabException(
391:                                            "TabData.removeRenameTab():couldn't create the url",
392:                                            me);
393:                                }
394:                                return url;
395:                            }
396:                        } else if (key.startsWith(startTag)) {
397:                            //
398:                            // make start
399:                            //
400:                            if (!containerProvidercontext.getSelectedChannels(
401:                                    channel).contains(val)) {
402:                                continue;
403:                            }
404:                            if (!getStartTabName().equals(val)) {
405:                                setStartTabName(val);
406:                                setSelectedTabName(val);
407:                                try {
408:                                    StringBuffer urlbuffer = new StringBuffer(
409:                                            containerProvidercontext
410:                                                    .getDesktopURL(req));
411:                                    urlbuffer.append("?action=edit&provider=");
412:                                    urlbuffer.append(channel);
413:                                    url = new URL(urlbuffer.toString());
414:                                } catch (MalformedURLException me) {
415:                                    throw new TabException(
416:                                            "TabData.removeRenameTab():couldn't create the url",
417:                                            me);
418:                                }
419:                                return url;
420:                            }
421:                        } else if (key.startsWith(renameTag)
422:                                && val.length() != 0) {
423:                            //
424:                            // rename
425:                            //
426:                            String tabName = key
427:                                    .substring(key.lastIndexOf("_") + 1);
428:                            Map tabMap = getTabPropsMap();
429:                            if (!tabMap.containsKey(tabName)) {
430:                                //tab has been removed.
431:                                continue;
432:                            }
433:                            ModifiableTab mt = TabFactory.createModifiable(
434:                                    tabName, containerProvidercontext, channel,
435:                                    tabMap);
436:                            String tabTitle = mt.getDisplayname();
437:                            if (tabTitle.equals(val)) {
438:                                //
439:                                // no changes
440:                                //
441:                                continue;
442:                            }
443:                            if (!(val.length() > 0)) {
444:                                throw new TabException(
445:                                        "TabData.removeRenameTab():Tab names must be non-null!");
446:                            }
447:                            val = transformTabName(val);
448:                            mt.setDisplayname(val);
449:                            addSelectedTab(mt);
450:                            try {
451:                                StringBuffer urlbuffer = new StringBuffer(
452:                                        containerProvidercontext
453:                                                .getDesktopURL(req));
454:                                urlbuffer.append("?action=edit&provider=");
455:                                urlbuffer.append(channel);
456:                                url = new URL(urlbuffer.toString());
457:                            } catch (MalformedURLException me) {
458:                                throw new TabException(
459:                                        "TabData.removeRenameTab():couldn't create the url",
460:                                        me);
461:                            }
462:                            return url;
463:                        }
464:                    } catch (ProviderContextException pce) {
465:                        throw new TabException("TabData.removeRenameTab(): ",
466:                                pce);
467:                    }
468:                }
469:                return null;
470:            }
471:
472:            public void removeTab(String name) throws TabException {
473:                try {
474:                    List selectedChannels = containerProvidercontext
475:                            .getSelectedChannels(channel);
476:                    List availableChannels = containerProvidercontext
477:                            .getAvailableChannels(channel);
478:                    UnmodifiableTab tab = getTab(name);
479:                    String startTab = getStartTabName();
480:                    String selectedTab = getSelectedTabName();
481:                    if (selectedChannels.contains(name)) {
482:                        selectedChannels.remove(name);
483:                        containerProvidercontext.setSelectedChannels(channel,
484:                                selectedChannels);
485:                    } else {
486:                        throw new TabException(
487:                                "TabData.removeTab():couldn't remove tab, it didn't exist");
488:                    }
489:
490:                    // set the start and selected tab to the next available tab
491:                    // if the tab to be removed is both start tab and selected tab
492:                    if (startTab.equals(name) && selectedTab.equals(name)) {
493:                        String newTab = (String) selectedChannels.get(0);
494:                        setStartTabName(newTab);
495:                        setSelectedTabName(newTab);
496:                    } else {
497:                        if (startTab.equals(name)) {
498:                            setStartTabName(selectedTab);
499:                        }
500:                        if (selectedTab.equals(name)) {
501:                            setSelectedTabName(startTab);
502:                        }
503:                    }
504:
505:                    // remove it from the available channels list and the dp if user created.
506:                    if (!tab.isPredefined()) {
507:                        if (availableChannels.contains(name)) {
508:                            availableChannels.remove(name);
509:                            containerProvidercontext.setAvailableChannels(
510:                                    channel, availableChannels);
511:
512:                        }
513:                        // remove from dp.
514:                        containerProvidercontext.removeChannel(name);
515:                        //remove the tab properties
516:                        Map tabPropsMap = getTabPropsMap();
517:                        tabPropsMap.remove(name);
518:                        containerProvidercontext.setCollectionProperty(channel,
519:                                props_key, tabPropsMap);
520:                    }
521:                } catch (ProviderContextException pce) {
522:                    throw new TabException("TabData.removeTab(): ", pce);
523:                }
524:
525:            }
526:
527:            public void makeNewTab(HttpServletRequest req, Map results)
528:                    throws ProviderException {
529:                //
530:                // try to get the name of the page
531:                //
532:                String tabName = req.getParameter(channel + ".tabName");
533:                String tabDesc = req.getParameter(channel + ".tabDesc");
534:
535:                if (tabName != null && tabName.length() != 0) {
536:                    results.put("inputTabName", tabName);
537:                }
538:                if (tabDesc != null && tabDesc.length() != 0) {
539:                    results.put("inputDescName", tabDesc);
540:                }
541:
542:                if ((tabName == null) || (tabName.length() == 0)) {
543:                    //
544:                    // no error, they just didn't fill it out
545:                    //
546:
547:                    if (logger.isLoggable(Level.WARNING))
548:                        logger.log(Level.WARNING, "PSDT_CSPPCJTU0001");
549:                    String err = bundle.getString("tabNameNull");
550:                    throw new TabEditException(err);
551:                }
552:
553:                if ((tabDesc == null) || (tabDesc.length() == 0)) {
554:                    //
555:                    // no error, they just didn't fill it out
556:                    //
557:                    if (logger.isLoggable(Level.WARNING))
558:                        logger.log(Level.WARNING, "PSDT_CSPPCJTU0002");
559:                    String err = bundle.getString("tabDescNull");
560:                    throw new TabEditException(err);
561:                }
562:
563:                List availChannels = null;
564:                List selectedChannels = null;
565:                Map tabPropsMap = null;
566:                int channelNumber = 0;
567:
568:                try {
569:                    availChannels = containerProvidercontext
570:                            .getAvailableChannels(channel);
571:                    selectedChannels = containerProvidercontext
572:                            .getSelectedChannels(channel);
573:                    tabPropsMap = getTabPropsMap();
574:                    channelNumber = containerProvidercontext
575:                            .getIntegerProperty(channel, "channelNumber");
576:                } catch (ProviderContextException pce) {
577:                    throw new ProviderException("TabData.makeNewTab(): ", pce);
578:                }
579:
580:                if (selectedChannels.size() >= getMaxTabs()) {
581:                    String err = bundle.getString("maxTabs");
582:                    throw new TabEditException(err);
583:                }
584:
585:                if (logger.isLoggable(Level.FINER)) {
586:                    String[] param = { tabName, tabDesc };
587:                    logger.log(Level.FINER, "PSDT_CSPPCJTU0003", param);
588:                }
589:
590:                String makeTabProviderName = getMakeTabProviderName();
591:                String makeChannel = getMakeTabName();
592:                Map makeChannelMap = (Map) tabPropsMap.get(makeChannel);
593:                tabName = transformTabName(tabName);
594:                //
595:                // we have a name, so get the tab topic radio
596:                //
597:                String topic = null;
598:                try {
599:                    topic = req.getParameter(channel + ".tabTopic");
600:                } catch (Exception ex) {
601:                    if (logger.isLoggable(Level.SEVERE)) {
602:                        LogRecord rec = new LogRecord(Level.SEVERE,
603:                                "PSDT_CSPPCJTU0004");
604:                        rec.setLoggerName(logger.getName());
605:                        rec.setThrown(ex);
606:                        String[] param = { tabName };
607:                        rec.setParameters(param);
608:                    }
609:                }
610:
611:                if ((topic == null) || (topic.length() == 0)) {
612:                    //
613:                    // no topic selected. this should never happen, but if it does,
614:                    // just assume they clicked the make from scratch dealy
615:                    //
616:                    if (logger.isLoggable(Level.WARNING)) {
617:                        logger.log(Level.WARNING, "PSDT_CSPPCJTU0005");
618:                    }
619:                    topic = makeChannel;
620:                }
621:
622:                if (logger.isLoggable(Level.FINER))
623:                    logger.log(Level.FINER, "PSDT_CSPPCJTU0006", topic);
624:                //
625:                // we have the topic and the name.
626:                // check to see if its the special case of make my own tab.
627:                //
628:                boolean make = false;
629:
630:                if (topic.equals(makeChannel)) {
631:                    make = true;
632:                }
633:
634:                if (logger.isLoggable(Level.FINER))
635:                    logger.log(Level.FINER, "PSDT_CSPPCJTU0007", "" + make);
636:
637:                results.put("make", new Boolean(make));
638:                //
639:                // now, create a new Tab object based on the topic, rename it, and
640:                // add it to the list of tabs.
641:                //
642:                ModifiableTab newTab = null;
643:
644:                try {
645:                    if (!make) {
646:                        if (availChannels.contains(topic)
647:                                && !selectedChannels.contains(topic)
648:                                && containerProvidercontext
649:                                        .getProviderVersion(channel) <= 1) {
650:                            // add the tab that has been previously removed.
651:                            addTab(topic, tabName);
652:                        } else {
653:                            String providerName = containerProvidercontext
654:                                    .getProviderName(topic);
655:                            Map predefinedTabMap = (Map) tabPropsMap.get(topic);
656:                            //
657:                            // Create the channel based on the provider name and the parent channel
658:                            //
659:                            String channelName = channel
660:                                    + ContainerProviderContext.CHANNEL_NAME_SEPARATOR
661:                                    + makeChannel + channelNumber;
662:                            containerProvidercontext.createContainer(
663:                                    channelName, providerName);
664:
665:                            if (containerProvidercontext
666:                                    .getProviderVersion(channel) > 1) {
667:                                List pflist = containerProvidercontext
668:                                        .getLocalePropertiesFilters();
669:                                containerProvidercontext.setStringProperty(
670:                                        channelName, "title", tabName, pflist);
671:                                containerProvidercontext.setStringProperty(
672:                                        channelName, "description", tabDesc,
673:                                        pflist);
674:                            }
675:
676:                            // set the available and selected channels
677:                            containerProvidercontext.setAvailableChannels(
678:                                    channelName, containerProvidercontext
679:                                            .getAvailableChannels(topic));
680:                            containerProvidercontext.setSelectedChannels(
681:                                    channelName, containerProvidercontext
682:                                            .getSelectedChannels(topic));
683:
684:                            //set all the properties from the predefined tab
685:                            // "propertiesToCopy" when version < 1
686:                            if (containerProvidercontext
687:                                    .getProviderVersion(channel) <= 1) {
688:                                Map propertiesMap = containerProvidercontext
689:                                        .getCollectionProperty(channel,
690:                                                "propertiesToCopy");
691:                                setChannelProperties(topic, channelName,
692:                                        propertiesMap);
693:                            }
694:
695:                            //create the collection with tab properties.
696:                            Map tabMap = createTabPropsMap(predefinedTabMap);
697:                            tabPropsMap.put(channelName, tabMap);
698:                            containerProvidercontext.setCollectionProperty(
699:                                    channel, props_key, tabPropsMap);
700:
701:                            try {
702:                                newTab = TabFactory.createModifiable(
703:                                        channelName, containerProvidercontext,
704:                                        channel, tabPropsMap);
705:                            } catch (TabException te) {
706:                                throw new ProviderException(
707:                                        "couldn't create tab based on predefined tab",
708:                                        te);
709:                            }
710:
711:                            // Add the new channel to the available list.
712:                            availChannels.add(channelName);
713:                            containerProvidercontext.setAvailableChannels(
714:                                    channel, availChannels);
715:
716:                            channelNumber += 1;
717:                            containerProvidercontext.setIntegerProperty(
718:                                    channel, "channelNumber", channelNumber);
719:                        }
720:                    } else {
721:                        //
722:                        // here, we are making from scratch.
723:                        //
724:
725:                        //
726:                        // Create the channel based on the provider name and the parent channel
727:                        //
728:                        String channelName = channel
729:                                + ContainerProviderContext.CHANNEL_NAME_SEPARATOR
730:                                + makeChannel + channelNumber;
731:                        containerProvidercontext.createContainer(channelName,
732:                                makeTabProviderName);
733:
734:                        //create the collection with tab properties.
735:                        // set the available and selected channels
736:                        // the tabs list of channels gets copied from the default channel list.  this
737:                        // might seem strange ... we've said we're making from scratch
738:                        // but we're still filling in the channels.  this is so if the user
739:                        // does not fill out the content page (cancels or something) the
740:                        // tab still has some channels.  having no channels on a tab
741:                        // would result in an empty desktop.
742:
743:                        Map tabMap = createTabPropsMap(makeChannelMap);
744:                        if (containerProvidercontext
745:                                .getProviderVersion(channel) > 1) {
746:                            List pflist = containerProvidercontext
747:                                    .getLocalePropertiesFilters();
748:                            containerProvidercontext.setStringProperty(
749:                                    channelName, "title", tabName, pflist);
750:                            containerProvidercontext
751:                                    .setStringProperty(channelName,
752:                                            "description", tabDesc, pflist);
753:
754:                            containerProvidercontext.setAvailableChannels(
755:                                    channelName, containerProvidercontext
756:                                            .getAvailableChannels(makeChannel));
757:                            containerProvidercontext.setSelectedChannels(
758:                                    channelName, containerProvidercontext
759:                                            .getSelectedChannels(makeChannel));
760:                        } else {
761:                            tabMap.put("title", tabName);
762:                            tabMap.put("desc", tabDesc);
763:
764:                            Map defaultChannelMap = containerProvidercontext
765:                                    .getCollectionProperty(channel,
766:                                            "defaultChannelList");
767:                            Set keys = defaultChannelMap.keySet();
768:                            List defaultChannelList = new ArrayList(keys);
769:
770:                            containerProvidercontext.setAvailableChannels(
771:                                    channelName, defaultChannelList);
772:                            containerProvidercontext.setSelectedChannels(
773:                                    channelName, defaultChannelList);
774:
775:                        }
776:
777:                        tabPropsMap.put(channelName, tabMap);
778:                        containerProvidercontext.setCollectionProperty(channel,
779:                                props_key, tabPropsMap);
780:                        try {
781:                            newTab = TabFactory.createModifiable(channelName,
782:                                    containerProvidercontext, channel,
783:                                    tabPropsMap);
784:                        } catch (TabException te) {
785:                            throw new ProviderException(
786:                                    "couldn't copy make tab", te);
787:                        }
788:
789:                        // Add the new channel to the available list.
790:                        availChannels.add(channelName);
791:                        containerProvidercontext.setAvailableChannels(channel,
792:                                availChannels);
793:
794:                        channelNumber += 1;
795:                        containerProvidercontext.setIntegerProperty(channel,
796:                                "channelNumber", channelNumber);
797:
798:                    }
799:
800:                } catch (ProviderContextException pce) {
801:                    throw new ProviderException("TabData.makeRenameTab(): ",
802:                            pce);
803:                }
804:
805:                //
806:                // save the new tab in the tab list, if newTab has been created
807:                //
808:                if (newTab != null) {
809:                    setTab(newTab, true);
810:                    results.put("tab", newTab);
811:                }
812:
813:            }
814:
815:            private void setChannelProperties(String topic, String channelName,
816:                    Map propertiesMap) throws ProviderContextException {
817:                Set keys = propertiesMap.keySet();
818:                for (Iterator i = keys.iterator(); i.hasNext();) {
819:                    String key = (String) i.next();
820:                    Object value = containerProvidercontext.getProperty(topic,
821:                            key);
822:
823:                    if (value != null) {
824:                        //containerProvidercontext.debugError("TabData.makeNewTab(): property to copy was null for key=" + key);
825:                        containerProvidercontext.setProperty(channelName, key,
826:                                value);
827:                    }
828:                    if (key.equals("categories")) {
829:                        Map categoriesMap = containerProvidercontext
830:                                .getCollectionProperty(topic, "categories");
831:                        //containerProvidercontext.debugError("TabData.makeNewTab(): categoriesMap=" + categoriesMap);
832:                        Set categories = categoriesMap.keySet();
833:                        for (Iterator j = categories.iterator(); j.hasNext();) {
834:                            String category = (String) j.next();
835:                            //containerProvidercontext.debugError("TabData.makeNewTab(): category=" + category);
836:                            Object categoryValue = containerProvidercontext
837:                                    .getProperty(topic, category, null);
838:                            //containerProvidercontext.debugError("TabData.makeNewTab(): categoryValue=" + categoryValue);
839:                            if (categoryValue != null) {
840:                                containerProvidercontext.setProperty(
841:                                        channelName, category, categoryValue);
842:                            }
843:                        }
844:                    }
845:                }
846:            }
847:
848:            private String transformTabName(String tabName) {
849:                return tabName.replace('\"', '\'');
850:            }
851:
852:            private Map createTabPropsMap(Map predefinedMap) {
853:                Map tabMap = new HashMap();
854:                tabMap.put("removable", new Boolean("true"));
855:                //Check for null
856:                if (predefinedMap != null
857:                        && predefinedMap.get("renamable") != null) {
858:                    tabMap.put("renamable", (Boolean) predefinedMap
859:                            .get("renamable"));
860:                } else {
861:                    tabMap.put("renamable", new Boolean("true"));
862:                }
863:                tabMap.put("predefined", new Boolean("false"));
864:                return tabMap;
865:
866:            }
867:
868:            private void writeSelectedTabName(String name) {
869:                String key = channel + ".selectedTab";
870:                containerProvidercontext.setClientProperty(key, name);
871:            }
872:
873:            private Map getTabPropsMap() throws TabException {
874:                try {
875:                    return containerProvidercontext.getCollectionProperty(
876:                            channel, props_key);
877:                } catch (ProviderContextException pce) {
878:                    throw new TabException("TabData.getTabPropsMap(): channel "
879:                            + channel, pce);
880:                }
881:            }
882:
883:        }
ww__w___.j__ava2___s_.___co___m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.