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


001:        /*
002:         * ProviderCommands.java Sun Microsystems
003:         *
004:         * Copyright 2001 Sun Microsystems, Inc.  All rights reserved.
005:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms.
006:         */
007:
008:        package com.sun.portal.providers.util;
009:
010:        import java.util.Map;
011:        import java.util.ResourceBundle;
012:        import java.util.Hashtable;
013:        import java.util.logging.Logger;
014:        import java.util.logging.Level;
015:        import java.util.logging.LogRecord;
016:
017:        import java.net.URL;
018:        import java.net.URLEncoder;
019:
020:        import javax.servlet.http.HttpServletRequest;
021:
022:        import com.sun.portal.providers.Provider;
023:        import com.sun.portal.providers.ProviderException;
024:        import com.sun.portal.providers.context.ProviderContext;
025:        import com.sun.portal.providers.context.ProviderContextException;
026:
027:        import com.sun.portal.log.common.PortalLogger;
028:
029:        /*
030:         * buiding commands for channels
031:         * 
032:         * TBD (cw): all of these commands are not functional for now. Resource 
033:         * bundles are not integrated in the environment now, and any other 
034:         * action besides content is not supported in the desktop servlet. Need
035:         * to come back and fix this when things are ready.
036:         * 
037:         */
038:        public class ProviderCommands implements  ProviderProperties {
039:            private static final int DEFAULT_COMMAND_SIZE = 512;
040:            private static final int DEFAULT_URL_SIZE = 128;
041:            private static final String DESKTOP_IMAGES = "/desktop/images/";
042:            private static Logger logger = PortalLogger
043:                    .getLogger(ProviderCommands.class);
044:
045:            private ProviderCommands() {
046:                //private constructor
047:            }
048:
049:            public static Hashtable getProviderCommands(Provider provider,
050:                    String container, ProviderContext pc,
051:                    HttpServletRequest req, ResourceBundle bundle,
052:                    String desktopURL, String sContext,
053:                    Map channelsIsDetachable, Map channelsIsDetached,
054:                    Map channelsIsMinimizable, Map channelsIsMaximizable,
055:                    String maximizedChannel, Map channelsIsMinimized,
056:                    Map channelsIsRemovable, boolean dIsDetachable,
057:                    boolean dIsDetached, boolean dIsMinimizable,
058:                    boolean dIsMaximizable, boolean dIsMinimized,
059:                    boolean dIsRemovable, String normalizeImage,
060:                    String maximizeImage, String minimizeImage,
061:                    String helpImage, String editImage, String removeImage,
062:                    String attachImage, String detachImage)
063:                    throws ProviderException {
064:
065:                String providerName = provider.getName();
066:
067:                boolean isDetached = PropertyUtil.getBooleanValueFromMap(
068:                        channelsIsDetached, providerName, dIsDetached);
069:
070:                Hashtable tagTable = new Hashtable();
071:                tagTable.put("providerName", provider.getTitle());
072:
073:                // Even if one of the commands failed, we still want to show the rest.
074:                // Log the error and keep going.
075:
076:                //
077:                // encode names to be used in URL generation
078:                //
079:                String providerNameUE = URLEncoder.encode(providerName);
080:                String containerUE = URLEncoder.encode(container);
081:
082:                try {
083:                    genMinimize(provider, container, containerUE, pc, sContext,
084:                            bundle, desktopURL, isDetached, providerName,
085:                            providerNameUE, channelsIsMinimizable,
086:                            channelsIsMinimized, dIsMinimizable, dIsMinimized,
087:                            normalizeImage, minimizeImage, tagTable);
088:                } catch (ProviderException pe) {
089:                    if (logger.isLoggable(Level.INFO)) {
090:                        LogRecord record = new LogRecord(Level.INFO,
091:                                "PSDT_CSPPU0001");
092:                        record.setLoggerName(logger.getName());
093:                        record.setParameters(new Object[] { "genMinize",
094:                                providerName, provider.getClass() });
095:                        record.setThrown(pe);
096:                        logger.log(record);
097:                    }
098:                }
099:
100:                try {
101:                    genMaximize(provider, container, containerUE, pc, sContext,
102:                            bundle, desktopURL, isDetached, providerName,
103:                            providerNameUE, channelsIsMaximizable,
104:                            maximizedChannel, dIsMaximizable, normalizeImage,
105:                            maximizeImage, tagTable);
106:                } catch (ProviderException pe) {
107:                    if (logger.isLoggable(Level.INFO)) {
108:                        LogRecord record = new LogRecord(Level.INFO,
109:                                "PSDT_CSPPU0001");
110:                        record.setLoggerName(logger.getName());
111:                        record.setParameters(new Object[] { "genMaximize",
112:                                providerName, provider.getClass() });
113:                        record.setThrown(pe);
114:                        logger.log(record);
115:                    }
116:                }
117:
118:                try {
119:                    genHelp(req, provider, container, containerUE, pc,
120:                            sContext, bundle, desktopURL, providerName,
121:                            providerNameUE, helpImage, tagTable);
122:                } catch (ProviderException pe) {
123:                    if (logger.isLoggable(Level.INFO)) {
124:                        LogRecord record = new LogRecord(Level.INFO,
125:                                "PSDT_CSPPU0001");
126:                        record.setLoggerName(logger.getName());
127:                        record.setParameters(new Object[] { "genHelp",
128:                                providerName, provider.getClass() });
129:                        record.setThrown(pe);
130:                        logger.log(record);
131:                    }
132:                }
133:
134:                try {
135:                    genEdit(provider, container, containerUE, pc, sContext,
136:                            bundle, desktopURL, isDetached, providerName,
137:                            providerNameUE, editImage, tagTable);
138:                } catch (ProviderException pe) {
139:                    if (logger.isLoggable(Level.INFO)) {
140:                        LogRecord record = new LogRecord(Level.INFO,
141:                                "PSDT_CSPPU0001");
142:                        record.setLoggerName(logger.getName());
143:                        record.setParameters(new Object[] { "genEdit",
144:                                providerName, provider.getClass() });
145:                        record.setThrown(pe);
146:                        logger.log(record);
147:                    }
148:                }
149:
150:                try {
151:                    genDetach(provider, container, containerUE, pc, sContext,
152:                            bundle, desktopURL, isDetached, providerName,
153:                            providerNameUE, channelsIsDetachable,
154:                            dIsDetachable, maximizedChannel, attachImage,
155:                            detachImage, tagTable);
156:                } catch (ProviderException pe) {
157:                    if (logger.isLoggable(Level.INFO)) {
158:                        LogRecord record = new LogRecord(Level.INFO,
159:                                "PSDT_CSPPU0001");
160:                        record.setLoggerName(logger.getName());
161:                        record.setParameters(new Object[] { "genDetach",
162:                                providerName, provider.getClass() });
163:                        record.setThrown(pe);
164:                        logger.log(record);
165:                    }
166:                }
167:
168:                try {
169:                    genRemove(provider, container, containerUE, pc, sContext,
170:                            bundle, desktopURL, isDetached, providerName,
171:                            providerNameUE, channelsIsRemovable, dIsRemovable,
172:                            removeImage, tagTable);
173:                } catch (ProviderException pe) {
174:                    if (logger.isLoggable(Level.INFO)) {
175:                        LogRecord record = new LogRecord(Level.INFO,
176:                                "PSDT_CSPPU0001");
177:                        record.setLoggerName(logger.getName());
178:                        record.setParameters(new Object[] { "genRemove",
179:                                providerName, provider.getClass() });
180:                        record.setThrown(pe);
181:                        logger.log(record);
182:                    }
183:                }
184:
185:                return tagTable;
186:            }
187:
188:            private static void genMinimize(Provider provider,
189:                    String frontContainerName, String frontContainerNameUE,
190:                    ProviderContext providerContext, String sContext,
191:                    ResourceBundle bundle, String desktopURL,
192:                    boolean isDetached, String providerName,
193:                    String providerNameUE, Map channelsIsMinimizable,
194:                    Map channelsIsMinimized, boolean dIsMinimizable,
195:                    boolean dIsMinimized, String normalizeImage,
196:                    String minimizeImage, Hashtable tagTable)
197:                    throws ProviderException {
198:
199:                // get properties for specific provider
200:                boolean minimized = PropertyUtil.getBooleanValueFromMap(
201:                        channelsIsMinimized, providerName, dIsMinimized);
202:                boolean minimizable = PropertyUtil.getBooleanValueFromMap(
203:                        channelsIsMinimizable, providerName, dIsMinimizable);
204:
205:                StringBuffer minMaximizeCommand = new StringBuffer(
206:                        DEFAULT_COMMAND_SIZE);
207:
208:                if (minimizable && !isDetached) {
209:                    try {
210:                        StringBuffer minMaximizeURL = new StringBuffer(
211:                                DEFAULT_URL_SIZE);
212:                        if (minimized) {
213:                            String maximizeTag = bundle.getString("maximize");
214:                            String maximizeIcon = sContext
215:                                    + bundle.getString("maximizeIcon");
216:
217:                            tagTable.put("minMaximizeIcon", maximizeIcon);
218:                            tagTable.put("minMaximizeText", maximizeTag);
219:                            minMaximizeURL.append(desktopURL).append(
220:                                    "?action=process&provider=").append(
221:                                    frontContainerNameUE).append("&").append(
222:                                    frontContainerNameUE).append(
223:                                    ".channelAction=maximize&").append(
224:                                    frontContainerNameUE).append(
225:                                    ".targetProvider=").append(providerNameUE);
226:
227:                            tagTable.put("minMaximizeURL", minMaximizeURL);
228:                            if (normalizeImage != null) {
229:                                tagTable.put("s_normalizeImage", sContext
230:                                        + DESKTOP_IMAGES + normalizeImage);
231:                            }
232:                            minMaximizeCommand = providerContext.getTemplate(
233:                                    frontContainerName,
234:                                    "normalizeCommand.template", tagTable);
235:                        } else {
236:                            String minimizeTag = bundle.getString("minimize");
237:                            String minimizeIcon = sContext
238:                                    + bundle.getString("minimizeIcon");
239:
240:                            tagTable.put("minMaximizeIcon", minimizeIcon);
241:                            tagTable.put("minMaximizeText", minimizeTag);
242:                            if (minimizeImage != null) {
243:                                tagTable.put("s_minimizeImage", sContext
244:                                        + DESKTOP_IMAGES + minimizeImage);
245:                            }
246:                            minMaximizeURL.append(desktopURL).append(
247:                                    "?action=process&provider=").append(
248:                                    frontContainerNameUE).append("&").append(
249:                                    frontContainerNameUE).append(
250:                                    ".channelAction=minimize&").append(
251:                                    frontContainerNameUE).append(
252:                                    ".targetProvider=").append(providerNameUE);
253:
254:                            tagTable.put("minMaximizeURL", minMaximizeURL);
255:                            minMaximizeCommand = providerContext.getTemplate(
256:                                    frontContainerName,
257:                                    "minimizeCommand.template", tagTable);
258:                        }
259:                        minMaximizeCommand.setLength(minMaximizeCommand
260:                                .length() - 1);
261:                        tagTable.put("minMaximizeCommand", minMaximizeCommand
262:                                .toString());
263:                    } catch (ProviderContextException pce) {
264:                        throw new ProviderException(
265:                                "ProviderCommands.genMinimized(): ", pce);
266:                    }
267:                    //tagTable.put("minMaximizeCommand", minMaximizeCommand.toString());
268:                } else {
269:                    tagTable.put("minMaximizeCommand", "");
270:                }
271:
272:            }
273:
274:            private static void genMaximize(Provider provider,
275:                    String frontContainerName, String frontContainerNameUE,
276:                    ProviderContext providerContext, String sContext,
277:                    ResourceBundle bundle, String desktopURL,
278:                    boolean isDetached, String providerName,
279:                    String providerNameUE, Map channelsIsMaximizable,
280:                    String maximizedChannel, boolean dIsMaximizable,
281:                    String normalizeImage, String maximizeImage,
282:                    Hashtable tagTable) throws ProviderException {
283:
284:                // get properties for specific provider
285:                boolean maximized = providerName
286:                        .equalsIgnoreCase(maximizedChannel);
287:                boolean maximizable = PropertyUtil.getBooleanValueFromMap(
288:                        channelsIsMaximizable, providerName, dIsMaximizable);
289:
290:                StringBuffer maximizeCommand = new StringBuffer(
291:                        DEFAULT_COMMAND_SIZE);
292:
293:                if (maximizable && !isDetached) {
294:                    StringBuffer maximizeURL = new StringBuffer(
295:                            DEFAULT_URL_SIZE);
296:                    try {
297:                        if (!maximized) {
298:                            String maximizeTag = bundle
299:                                    .getString("truemaximize");
300:
301:                            tagTable.put("maximizeText", maximizeTag);
302:                            maximizeURL.append(desktopURL).append(
303:                                    "?action=process&provider=").append(
304:                                    frontContainerNameUE).append("&").append(
305:                                    frontContainerNameUE).append(
306:                                    ".channelAction=truemaximize&").append(
307:                                    frontContainerNameUE).append(
308:                                    ".targetProvider=").append(providerNameUE);
309:
310:                            tagTable.put("maximizeURL", maximizeURL);
311:                            if (maximizeImage != null) {
312:                                tagTable.put("s_maximizeImage", sContext
313:                                        + DESKTOP_IMAGES + maximizeImage);
314:                            }
315:                            maximizeCommand = providerContext.getTemplate(
316:                                    frontContainerName,
317:                                    "MaximizeCommand.template", tagTable);
318:                        } else {
319:                            String maximizeTag = bundle.getString("maximize");
320:
321:                            tagTable.put("minMaximizeText", maximizeTag);
322:                            maximizeURL.append(desktopURL).append(
323:                                    "?action=process&provider=").append(
324:                                    frontContainerNameUE).append("&").append(
325:                                    frontContainerNameUE).append(
326:                                    ".channelAction=maximize&").append(
327:                                    frontContainerNameUE).append(
328:                                    ".targetProvider=").append(providerNameUE);
329:
330:                            tagTable.put("minMaximizeURL", maximizeURL);
331:                            if (normalizeImage != null) {
332:                                tagTable.put("s_normalizeImage", sContext
333:                                        + DESKTOP_IMAGES + normalizeImage);
334:                            }
335:                            maximizeCommand = providerContext.getTemplate(
336:                                    frontContainerName,
337:                                    "normalizeCommand.template", tagTable);
338:                        }
339:                        maximizeCommand.setLength(maximizeCommand.length() - 1);
340:                        tagTable.put("maximizeCommand", maximizeCommand
341:                                .toString());
342:                    } catch (ProviderContextException pce) {
343:                        throw new ProviderException(
344:                                "ProviderCommands.genMinimized(): ", pce);
345:                    }
346:                } else {
347:                    tagTable.put("maximizeCommand", "");
348:                }
349:
350:            }
351:
352:            private static void genHelp(HttpServletRequest req,
353:                    Provider provider, String frontContainerName,
354:                    String frontContainerNameUE,
355:                    ProviderContext providerContext, String sContext,
356:                    ResourceBundle bundle, String desktopURL,
357:                    String providerName, String providerNameUE,
358:                    String helpImage, Hashtable tagTable)
359:                    throws ProviderException {
360:
361:                StringBuffer helpLink = new StringBuffer(DEFAULT_COMMAND_SIZE);
362:                URL helpURL = null;
363:
364:                try {
365:                    helpURL = provider.getHelp(req);
366:                } catch (Throwable e) {
367:                    if (logger.isLoggable(Level.INFO)) {
368:                        LogRecord record = new LogRecord(Level.INFO,
369:                                "PSDT_CSPPU0002");
370:                        record.setLoggerName(logger.getName());
371:                        record.setParameters(new Object[] { providerName });
372:                        record.setThrown(e);
373:                        logger.log(record);
374:                    }
375:                }
376:
377:                if (helpURL == null) {
378:                    tagTable.put("helpCommand", "");
379:                } else {
380:                    String helpTag = bundle.getString("help");
381:                    String helpIcon = sContext + bundle.getString("helpIcon");
382:                    String helpURLStr = helpURL.toString();
383:                    StringBuffer url = new StringBuffer(helpURLStr);
384:                    int queryStrIndex = helpURLStr.indexOf("?");
385:                    if (queryStrIndex != -1) {
386:                        url.insert(queryStrIndex + 1, "containerName="
387:                                + frontContainerNameUE + "&");
388:                    }
389:
390:                    tagTable.put(HELP_LINK, url.toString());
391:                    tagTable.put(HELP_TAG, helpTag);
392:                    tagTable.put(HELP_ICON, helpIcon);
393:                    if (helpImage != null) {
394:                        tagTable.put("s_helpImage", sContext + DESKTOP_IMAGES
395:                                + helpImage);
396:                    }
397:
398:                    try {
399:                        helpLink = providerContext.getTemplate(
400:                                frontContainerName, "helpHref.template",
401:                                tagTable);
402:                    } catch (ProviderContextException pce) {
403:                        throw new ProviderException(
404:                                "ProviderCommands.genHelp(): ", pce);
405:                    }
406:                    helpLink.setLength(helpLink.length() - 1);
407:                    tagTable.put("helpCommand", helpLink.toString());
408:                }
409:            }
410:
411:            private static void genEdit(Provider provider,
412:                    String frontContainerName, String frontContainerNameUE,
413:                    ProviderContext providerContext, String sContext,
414:                    ResourceBundle bundle, String desktopURL,
415:                    boolean isDetached, String providerName,
416:                    String providerNameUE, String editImage, Hashtable tagTable)
417:                    throws ProviderException {
418:
419:                // get properties from container property
420:                StringBuffer editCommand = new StringBuffer(
421:                        DEFAULT_COMMAND_SIZE);
422:
423:                if (provider.isEditable()) {
424:                    String editTag = bundle.getString("edit");
425:                    String editIcon = sContext + bundle.getString("editIcon");
426:                    tagTable.put("editTag", editTag);
427:                    tagTable.put("editIcon", editIcon);
428:                    if (editImage != null) {
429:                        tagTable.put("s_editImage", sContext + DESKTOP_IMAGES
430:                                + editImage);
431:                    }
432:                    StringBuffer editURL = new StringBuffer(DEFAULT_URL_SIZE);
433:
434:                    try {
435:                        String editContainerUE = URLEncoder
436:                                .encode(providerContext
437:                                        .getStringProperty(frontContainerName,
438:                                                EDIT_CONTAINER_NAME));
439:                        if (!isDetached) {
440:                            editURL.append(desktopURL).append("?action=edit&")
441:                                    .append("provider=")
442:                                    .append(editContainerUE).append(
443:                                            "&targetprovider=").append(
444:                                            providerNameUE).append("&").append(
445:                                            "containerName=").append(
446:                                            frontContainerNameUE);
447:                            tagTable.put("editURL", editURL);
448:                            editCommand = providerContext.getTemplate(
449:                                    frontContainerName, "editCommand.template",
450:                                    tagTable);
451:
452:                        } else {
453:                            editURL.append("dt").append("?action=edit&")
454:                                    .append("provider=")
455:                                    .append(editContainerUE).append(
456:                                            "&targetprovider=").append(
457:                                            providerNameUE).append("&").append(
458:                                            "containerName=").append(
459:                                            frontContainerNameUE);
460:                            tagTable.put("editURL", editURL);
461:                            editCommand = providerContext.getTemplate(
462:                                    frontContainerName,
463:                                    "detachEditCommand.template", tagTable);
464:                        }
465:                    } catch (ProviderContextException pce) {
466:                        throw new ProviderException(
467:                                "ProviderCommands.genEdit(): ", pce);
468:                    }
469:                    editCommand.setLength(editCommand.length() - 1);
470:                    tagTable.put("editCommand", editCommand.toString());
471:                } else {
472:                    tagTable.put("editCommand", "");
473:                }
474:
475:            }
476:
477:            private static void genDetach(Provider provider,
478:                    String frontContainerName, String frontContainerNameUE,
479:                    ProviderContext providerContext, String sContext,
480:                    ResourceBundle bundle, String desktopURL,
481:                    boolean isDetached, String providerName,
482:                    String providerNameUE, Map channelsIsDetachable,
483:                    boolean dIsDetachable, String maximizedChannel,
484:                    String attachImage, String detachImage, Hashtable tagTable)
485:                    throws ProviderException {
486:
487:                // get properties for specific provider
488:                boolean maximized = providerName
489:                        .equalsIgnoreCase(maximizedChannel);
490:                boolean isDetachable = PropertyUtil.getBooleanValueFromMap(
491:                        channelsIsDetachable, providerName, dIsDetachable);
492:                StringBuffer detachAttachCommand = new StringBuffer(
493:                        DEFAULT_COMMAND_SIZE);
494:                if (isDetachable && !maximized) {
495:                    StringBuffer detachURL = new StringBuffer(DEFAULT_URL_SIZE);
496:                    String icon = null;
497:                    String action = null;
498:                    String alt = null;
499:
500:                    try {
501:                        if (!isDetached) {
502:                            icon = sContext + bundle.getString("detachIcon");
503:                            alt = bundle.getString("detach");
504:                            detachURL.append(desktopURL).append(
505:                                    "?action=process&provider=").append(
506:                                    frontContainerNameUE).append("&").append(
507:                                    frontContainerNameUE).append(
508:                                    ".channelAction=detach&").append(
509:                                    frontContainerNameUE).append(
510:                                    ".targetProvider=").append(providerNameUE);
511:
512:                            tagTable.put("detachAttachIcon", icon);
513:                            tagTable.put("detachAttachText", alt);
514:                            tagTable.put("detachAttachURL", detachURL);
515:                            if (detachImage != null) {
516:                                tagTable.put("s_detachImage", sContext
517:                                        + DESKTOP_IMAGES + detachImage);
518:                            }
519:                            detachAttachCommand = providerContext.getTemplate(
520:                                    frontContainerName,
521:                                    "detachCommand.template", tagTable);
522:                        } else {
523:                            icon = sContext + bundle.getString("attachIcon");
524:                            alt = bundle.getString("attach");
525:
526:                            detachURL.append("dt").append(
527:                                    "?action=process&provider=").append(
528:                                    frontContainerNameUE).append("&").append(
529:                                    frontContainerNameUE).append(
530:                                    ".channelAction=attach&").append(
531:                                    frontContainerNameUE).append(
532:                                    ".targetProvider=").append(providerNameUE);
533:
534:                            tagTable.put("detachAttachIcon", icon);
535:                            tagTable.put("detachAttachText", alt);
536:                            tagTable.put("detachAttachURL", detachURL);
537:                            if (attachImage != null) {
538:                                tagTable.put("s_attachImage", sContext
539:                                        + DESKTOP_IMAGES + attachImage);
540:                            }
541:                            detachAttachCommand = providerContext.getTemplate(
542:                                    frontContainerName,
543:                                    "AtachCommand.template", tagTable);
544:                        }
545:                    } catch (ProviderContextException pce) {
546:                        throw new ProviderException(
547:                                "ProviderCommands.genDetach(): ", pce);
548:                    }
549:                    detachAttachCommand
550:                            .setLength(detachAttachCommand.length() - 1);
551:                    tagTable.put("detachAtachCommand", detachAttachCommand
552:                            .toString());
553:                } else {
554:                    tagTable.put("detachAtachCommand", "");
555:                }
556:
557:            }
558:
559:            private static void genRemove(Provider provider,
560:                    String frontContainerName, String frontContainerNameUE,
561:                    ProviderContext providerContext, String sContext,
562:                    ResourceBundle bundle, String desktopURL,
563:                    boolean isDetached, String providerName,
564:                    String providerNameUE, Map channelsIsRemovable,
565:                    boolean dIsRemovable, String removeImage, Hashtable tagTable)
566:                    throws ProviderException {
567:
568:                // get properties for specific provider
569:                boolean isRemovable = PropertyUtil.getBooleanValueFromMap(
570:                        channelsIsRemovable, providerName, dIsRemovable);
571:
572:                StringBuffer removeCommand = new StringBuffer(
573:                        DEFAULT_COMMAND_SIZE);
574:                if (isRemovable) {
575:                    String removeTag = bundle.getString("remove");
576:                    String removeIcon = sContext
577:                            + bundle.getString("removeIcon");
578:                    StringBuffer removeURL = new StringBuffer(DEFAULT_URL_SIZE);
579:                    tagTable.put("removeTag", removeTag);
580:                    tagTable.put("removeIcon", removeIcon);
581:                    if (removeImage != null) {
582:                        tagTable.put("s_removeImage", sContext + DESKTOP_IMAGES
583:                                + removeImage);
584:                    }
585:
586:                    try {
587:                        if (!isDetached) {
588:                            removeURL.append(desktopURL).append(
589:                                    "?action=process&provider=").append(
590:                                    frontContainerNameUE).append("&").append(
591:                                    frontContainerNameUE).append(
592:                                    ".channelAction=remove&").append(
593:                                    frontContainerNameUE).append(
594:                                    ".targetProvider=").append(providerNameUE);
595:                            tagTable.put("removeURL", removeURL);
596:                            removeCommand = providerContext.getTemplate(
597:                                    frontContainerName,
598:                                    "removeCommand.template", tagTable);
599:                        } else {
600:                            removeURL.append("dt").append(
601:                                    "?action=process&provider=").append(
602:                                    frontContainerNameUE).append("&").append(
603:                                    frontContainerNameUE).append(
604:                                    ".channelAction=remove&").append(
605:                                    frontContainerNameUE).append(
606:                                    ".targetProvider=").append(providerNameUE);
607:                            tagTable.put("removeURL", removeURL);
608:                            removeCommand = providerContext.getTemplate(
609:                                    frontContainerName,
610:                                    "detachRemoveCommand.template", tagTable);
611:                        }
612:                        removeCommand.setLength(removeCommand.length() - 1);
613:                        tagTable.put("removeCommand", removeCommand.toString());
614:                    } catch (ProviderContextException pce) {
615:                        throw new ProviderException(
616:                                "ProviderCommands.genRemove(): ", pce);
617:                    }
618:                } else {
619:                    tagTable.put("removeCommand", "");
620:                }
621:            }
622:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.