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


001:        package com.sun.portal.providers;
002:
003:        import java.util.*;
004:        import java.util.logging.Level;
005:        import java.util.logging.LogRecord;
006:        import java.util.logging.Logger;
007:        import java.io.*;
008:        import javax.servlet.http.*;
009:        import com.sun.portal.providers.*;
010:        import com.sun.portal.providers.util.ProviderProperties;
011:        import com.sun.portal.providers.context.*;
012:        import com.sun.ssoadapter.SSOAdapterLogger;
013:        import com.sun.ssoadapter.SSOAdapter;
014:        import com.sun.ssoadapter.SSOAdapterFactory;
015:        import com.sun.ssoadapter.SSOAdapterException;
016:        import com.sun.ssoadapter.SSOAdapterSession;
017:        import java.net.*;
018:
019:        /**
020:         *  Provides access to common methods for use by the communication channels.
021:         *  Most of\ these methods will handle the SSOAdapter
022:         *
023:         *@author     Bill York
024:         *@created    April 15, 2003
025:         */
026:        public class ProviderEditUtility {
027:            private static Properties adapterProperties = new Properties();
028:            private static URL errorURL = null;
029:            private static String charset = null;
030:            /**
031:             *  Current edit container
032:             */
033:            public static String editContainer = null;
034:            /**
035:             *  Current container
036:             */
037:            public static String container = null;
038:
039:            private static Logger logger = SSOAdapterLogger
040:                    .getLogger(ProviderEditUtility.class);
041:
042:            public static String getCharSet() {
043:                return charset;
044:            }
045:
046:            public static void setCharSet(String cs) {
047:                charset = cs;
048:            }
049:
050:            /**
051:             *  Gets the SSOAdapterPrefs attribute of the ProviderEditUtility object. This
052:             *  creates the first edit page you see with the host, port, and all other
053:             *  connection related attributes.
054:             *
055:             *@param  prov           A reference to the provider
056:             *@param  ssoa           The current SSOAdapter used by the provider class
057:             *@return                The editable SSOAdapter attributes
058:             *@exception  Exception  Description of the Exception
059:             */
060:            public static StringBuffer getSSOAdapterPrefs(ProviderAdapter prov,
061:                    SSOAdapter ssoa) throws Exception {
062:                Map ssoEditMap = null;
063:                ProviderContext pc = prov.getProviderContext();
064:                StringBuffer content = new StringBuffer();
065:
066:                Properties adapterProps = ssoa.getProperties();
067:                if (adapterProps != null) {
068:                    setSSOAdapterProperties(adapterProps);
069:                } else {
070:                    throw new Exception(
071:                            "ProviderEditUtility::getSSOAdapterPrefs: Unable to retrieve the SSOAdapter properties");
072:                }
073:
074:                List pflist = null;
075:                try {
076:                    pflist = pc.getClientAndLocalePropertiesFilters();
077:                    ssoEditMap = pc.getCollectionProperty(prov.getName(),
078:                            "ssoEditAttributes", pflist);
079:                } catch (ProviderContextException pce) {
080:                    ssoEditMap = pc.getCollectionProperty(prov.getName(),
081:                            "ssoEditAttributes");
082:                }
083:                if (logger.isLoggable(Level.WARNING)) {
084:                    String[] param = { "ssoEditMap size",
085:                            Integer.toString(ssoEditMap.size()) };
086:                    logger.log(Level.WARNING, "PSSA_CSPP0001", param);
087:                }
088:
089:                if (ssoEditMap != null) {
090:                    Set entries = ssoEditMap.entrySet();
091:                    Iterator iter = entries.iterator();
092:                    while (iter.hasNext()) {
093:                        Map.Entry entry = (Map.Entry) iter.next();
094:                        String key = (String) entry.getKey();
095:                        String val = (String) entry.getValue();
096:                        StringTokenizer tok = new StringTokenizer(val, "|");
097:                        while (tok.hasMoreElements()) {
098:                            String type = tok.nextToken();
099:                            String header = tok.nextToken();
100:                            String editContent = createEditContent(type,
101:                                    header, key, prov.getName(), pc, false)
102:                                    .toString();
103:                            content.append(editContent);
104:                        }
105:                    }
106:                }
107:                return content;
108:            }
109:
110:            /**
111:             *  Gets the errorURL attribute of the ProviderEditUtility class
112:             *
113:             *@return    The errorURL value
114:             */
115:            public static URL getErrorURL() {
116:                return ProviderEditUtility.errorURL;
117:            }
118:
119:            /**
120:             *  This method sets the errorURL in an error condition by building up an URL
121:             *
122:             *@param  prov  current provider Adapter. Used to retrieve key properties
123:             *@param  ssoe  Exception to retrieve message from
124:             *@param  req   servlet request
125:             */
126:
127:            private static void setErrorURL(ProviderAdapter prov,
128:                    SSOAdapterException ssoe, HttpServletRequest req) {
129:                URL url = null;
130:                ProviderContext pc = prov.getProviderContext();
131:                //String editContainer = (String) req.getAttribute("provider");
132:                //String container     = (String) req.getAttribute("containerName");
133:                if (logger.isLoggable(Level.FINEST)) {
134:                    logger.log(Level.FINEST, "PSSA_CSPP0002", editContainer);
135:                    logger.log(Level.FINEST, "PSSA_CSPP0003", container);
136:                }
137:
138:                ResourceBundle bundle = null;
139:                try {
140:                    bundle = prov.getResourceBundle();
141:                } catch (ProviderException pe) {
142:
143:                    if (logger.isLoggable(Level.SEVERE)) {
144:                        LogRecord rec = new LogRecord(Level.SEVERE,
145:                                "PSSA_CSPP0004");
146:                        rec.setThrown(pe);
147:                        String[] param = { prov.getName() };
148:                        rec.setParameters(param);
149:                        rec.setLoggerName(logger.getName());
150:                        logger.log(rec);
151:                    }
152:                }
153:
154:                if (ssoe.isInvalid()) {
155:                    String editURL = pc.getDesktopURL(req);
156:                    editURL += "?action=edit";
157:                    editURL += "&provider="
158:                            + pc.encodeURLParameter(editContainer);
159:                    editURL += "&targetprovider="
160:                            + pc.encodeURLParameter(prov.getName());
161:                    editURL += "&containerName="
162:                            + pc.encodeURLParameter(container);
163:                    String ssoErrMsg = ssoe.getMessage();
164:                    editURL += "&error=" + pc.encodeURLParameter(ssoErrMsg);
165:
166:                    try {
167:                        url = new URL(editURL);
168:                    } catch (Exception e) {
169:                        if (logger.isLoggable(Level.WARNING)) {
170:                            LogRecord rec = new LogRecord(Level.WARNING,
171:                                    "PSSA_CSPP0005");
172:                            rec.setThrown(e);
173:                            String[] param = { editURL };
174:                            rec.setParameters(param);
175:                            rec.setLoggerName(logger.getName());
176:                            logger.log(rec);
177:                        }
178:                        ProviderEditUtility.errorURL = null;
179:                    }
180:                    ProviderEditUtility.errorURL = url;
181:                }
182:            }
183:
184:            /**
185:             *  This method is used in an non error condition to set the errorURL to null
186:             */
187:            private static void setErrorURL() {
188:                ProviderEditUtility.errorURL = null;
189:            }
190:
191:            /**
192:             *  This method sets default presentation values based on a providers theme.
193:             *
194:             *@param  tagTable                      The tagTable that you want to set
195:             *      default values in
196:             *@param  provName                      provider name
197:             *@param  pc                            current provider context
198:             *@return                               The hashtable with the following
199:             *      values set bgColor Background Color borderWidth Border width for a
200:             *      table titlebarColor Color for a table section borderColor Color for a
201:             *      table border fontFace Font style fontColor Font color
202:             *@exception  ProviderContextException  Description of the Exception
203:             */
204:
205:            public static Hashtable setDefaultPresentation(String provName,
206:                    ProviderContext pc, Hashtable tagTable)
207:                    throws ProviderContextException {
208:                String attr = "";
209:                attr = Theme.getAttribute(provName, pc,
210:                        ProviderProperties.BG_COLOR);
211:                if (logger.isLoggable(Level.FINEST)) {
212:                    String[] param = { "bgcolor", attr };
213:                    logger.log(Level.FINEST, "PSSA_CSPP0006", param);
214:                }
215:                if (!((attr == null) || (attr.equals("")))) {
216:                    tagTable.put("bgColor", attr);
217:                } else {
218:                    tagTable.put("bgColor", "#FFFFFF");
219:                }
220:
221:                attr = Theme.getAttribute(provName, pc,
222:                        ProviderProperties.BORDER_WIDTH);
223:                if (logger.isLoggable(Level.FINEST)) {
224:                    String[] param = { "borderWidth", attr };
225:                    logger.log(Level.FINEST, "PSSA_CSPP0006", param);
226:                }
227:
228:                if (!((attr == null) || (attr.equals("")))) {
229:                    tagTable.put("borderWidth", attr);
230:                } else {
231:                    tagTable.put("borderWidth", "0");
232:                }
233:
234:                attr = Theme.getAttribute(provName, pc,
235:                        ProviderProperties.FONT_FACE);
236:                if (logger.isLoggable(Level.FINEST)) {
237:                    String[] param = { "fontFace", attr };
238:                    logger.log(Level.FINEST, "PSSA_CSPP0006", param);
239:                }
240:
241:                if (!((attr == null) || (attr.equals("")))) {
242:                    tagTable.put("fontFace", attr);
243:
244:                } else {
245:                    tagTable.put("fontFace", "Sans-serif");
246:                }
247:
248:                attr = Theme.getAttribute(provName, pc,
249:                        ProviderProperties.TITLE_BAR_COLOR);
250:                if (logger.isLoggable(Level.FINEST)) {
251:                    String[] param = { "titlebarColor", attr };
252:                    logger.log(Level.FINEST, "PSSA_CSPP0006", param);
253:                }
254:
255:                if (!((attr == null) || (attr.equals("")))) {
256:                    tagTable.put("titlebarColor", attr);
257:                } else {
258:                    tagTable.put("titlebarcolor", "Sans-serif");
259:                }
260:
261:                if (logger.isLoggable(Level.FINEST)) {
262:                    String[] param = { "borderColor", attr };
263:                    logger.log(Level.FINEST, "PSSA_CSPP0006", param);
264:                }
265:
266:                attr = Theme.getAttribute(provName, pc,
267:                        ProviderProperties.BORDER_COLOR);
268:                if (!((attr == null) || (attr.equals("")))) {
269:                    tagTable.put("borderColor", attr);
270:                } else {
271:                    tagTable.put("borderColor", "#666699");
272:                }
273:
274:                attr = Theme.getAttribute(provName, pc,
275:                        ProviderProperties.FONT_COLOR);
276:                if (logger.isLoggable(Level.FINEST)) {
277:                    String[] param = { "fontcolor", attr };
278:                    logger.log(Level.FINEST, "PSSA_CSPP0006", param);
279:                }
280:
281:                if (!((attr == null) || (attr.equals("")))) {
282:                    tagTable.put("fontColor", attr);
283:                } else {
284:                    tagTable.put("fontColor", "#000000");
285:                }
286:
287:                attr = Theme.getAttribute(provName, pc,
288:                        ProviderProperties.CHANNELS_BACKGROUND_COLOR);
289:                if (logger.isLoggable(Level.FINEST)) {
290:                    String[] param = { "channelBgColor", attr };
291:                    logger.log(Level.FINEST, "PSSA_CSPP0006", param);
292:                }
293:
294:                if (!((attr == null) || (attr.equals("")))) {
295:                    tagTable.put("channelBgColor", attr);
296:                } else {
297:                    tagTable.put("channelBgColor", "#FFFFFF");
298:                }
299:                return tagTable;
300:            }
301:
302:            /**
303:             *  Sets the SSOAdapterPrefs attribute of the ProviderAdapter object
304:             *
305:             *@param  prov            A reference to the provider
306:             *@param  request         The HttpServletRequest from the provider provider
307:             *@param  ssoAdapter      The current SSOAdapter used by the provider class
308:             *@param  adapterFactory  The new sSOAdapterPrefs value
309:             *@return                 returns the new SSOAdapter after saving the
310:             *      attributes.
311:             *@exception  Exception   Description of the Exception
312:             */
313:            public static SSOAdapter setSSOAdapterPrefs(ProviderAdapter prov,
314:                    SSOAdapter ssoAdapter, SSOAdapterFactory adapterFactory,
315:                    HttpServletRequest request) throws Exception {
316:
317:                Map ssoEditMap = null;
318:                ProviderContext pc = prov.getProviderContext();
319:                URL url = null;
320:                Properties props = new Properties();
321:
322:                Properties adapterProps = ssoAdapter.getProperties();
323:                if (adapterProps != null) {
324:                    setSSOAdapterProperties(adapterProps);
325:                } else {
326:                    throw new Exception(
327:                            "ProviderEditUtility::getSSOAdapterPrefs: Unable to retrieve the SSOAdapter properties");
328:                }
329:
330:                List pflist = null;
331:
332:                try {
333:                    pflist = pc.getClientAndLocalePropertiesFilters();
334:                    ssoEditMap = pc.getCollectionProperty(prov.getName(),
335:                            "ssoEditAttributes", pflist);
336:                } catch (ProviderContextException pce) {
337:                    Logger sLogger = SSOAdapterLogger
338:                            .getLogger(ProviderEditUtility.class);
339:                    sLogger.log(Level.INFO, "PSSA_CSPP0006", pce);
340:                    ssoEditMap = pc.getCollectionProperty(prov.getName(),
341:                            "ssoEditAttributes");
342:                }
343:
344:                if (ssoEditMap != null) {
345:                    Set entries = ssoEditMap.entrySet();
346:                    Iterator iter = entries.iterator();
347:                    while (iter.hasNext()) {
348:                        // get values from DP
349:                        Map.Entry entry = (Map.Entry) iter.next();
350:                        String key = (String) entry.getKey();
351:                        String value = ProviderEditUtility.getRequestParameter(
352:                                key, request);
353:                        String mapValue = (String) entry.getValue();
354:                        StringTokenizer tok = new StringTokenizer(mapValue, "|");
355:                        String type = null;
356:                        if (tok.hasMoreElements()) {
357:                            type = tok.nextToken();
358:                        }
359:                        if (type != null && type.equals("password")) {
360:                            if (!value.equals("********")) {
361:                                props.setProperty(key, value);
362:                            }
363:                        } else {
364:                            props.setProperty(key, value);
365:                        }
366:                        if (logger.isLoggable(Level.FINEST)) {
367:                            String[] param = { key, value };
368:                            logger.log(Level.FINEST, "PSSA_CSPP0006", param);
369:                        }
370:                    }
371:                }
372:
373:                props.setProperty("channelName", prov.getName());
374:                props.setProperty("validate", "true");
375:
376:                SSOAdapter ssoa = null;
377:                String editContainer = "";
378:                String container = "";
379:                String queryString = "";
380:                ResourceBundle bundle = null;
381:                try {
382:                    bundle = prov.getResourceBundle();
383:                } catch (ProviderException pe) {
384:                    if (logger.isLoggable(Level.SEVERE))
385:                        logger.log(Level.SEVERE, "PSSA_CSPP0007", pe);
386:                }
387:
388:                if (request == null) {
389:                    if (logger.isLoggable(Level.FINE))
390:                        logger.log(Level.FINE, "PSSA_CSPP0008");
391:                }
392:                try {
393:                    ssoa = (SSOAdapter) adapterFactory.setSSOAdapter(
394:                            ssoAdapter, props, new SSOAdapterSession(request,
395:                                    pc.getLocale(), null, prov.getName()));
396:                    setErrorURL();
397:                } catch (SSOAdapterException ssoe) {
398:                    setErrorURL(prov, ssoe, request);
399:                    if (logger.isLoggable(Level.SEVERE))
400:                        logger.log(Level.SEVERE, "PSSA_CSPP0009", ssoe);
401:                } catch (Exception e) {
402:                    if (logger.isLoggable(Level.SEVERE))
403:                        logger.log(Level.SEVERE, "PSSA_CSPP0009", e);
404:                }
405:
406:                // set ssoAdapter property to new SSOAdapter name if applicable
407:                if (ssoa != null) {
408:                    String ssoaName = ssoa.getName();
409:                    try {
410:                        if (!pc.getStringProperty(prov.getName(), "ssoAdapter")
411:                                .equals(ssoaName)) {
412:                            pc.setStringProperty(prov.getName(), "ssoAdapter",
413:                                    ssoaName);
414:                        }
415:                    } catch (ProviderContextException pce) {
416:                        if (logger.isLoggable(Level.SEVERE))
417:                            logger.log(Level.SEVERE, "PSSA_CSPP0011", pce);
418:                    }
419:                }
420:
421:                return ssoa;
422:            }
423:
424:            /**
425:             *  Gets the SSOProperty attribute of the MessengerExpressHelper object
426:             *
427:             *@param  key  Key to use to retrieve value
428:             *@return      The sSOProperty value
429:             */
430:            public static String getSSOProperty(String key) {
431:                Properties adapterProperties = getSSOAdapterProperties();
432:                String tmp = adapterProperties.getProperty(key);
433:                if (tmp == null) {
434:                    tmp = "";
435:                }
436:                return tmp;
437:            }
438:
439:            /**
440:             *  Gets the requestParameter attribute of the ProviderEditUtility class
441:             *
442:             *@param  key  key to retrieve value
443:             *@param  req  request to look for values in
444:             *@return      The requestParameter value
445:             */
446:            public static String getRequestParameter(String key,
447:                    HttpServletRequest req) {
448:                String tmp = (String) req.getParameter(key);
449:                if (tmp == null) {
450:                    tmp = "";
451:                }
452:                return tmp;
453:            }
454:
455:            /**
456:             *  Sets the sSOAdapterProperties attribute of the ProviderEditUtility class
457:             *
458:             *@param  props  The new sSOAdapterProperties value
459:             */
460:            public static void setSSOAdapterProperties(Properties props) {
461:                adapterProperties = props;
462:            }
463:
464:            /**
465:             *  Gets the appHandlerSet attribute of the ProviderEditUtility class
466:             *
467:             *@param  appHandlers  app helper map
468:             *@param  appValue     app helper to retrieve
469:             *@return              The appHandlerSet value
470:             */
471:            public static boolean isAppHandlerSet(HashMap appHandlers,
472:                    String appValue) {
473:                if ((appHandlers == null) || (appHandlers.isEmpty())
474:                        || (appValue == null) || (appValue.equals(""))) {
475:                    return false;
476:                }
477:
478:                Map appMap = (Map) appHandlers;
479:
480:                Set handlers = appMap.entrySet();
481:                Iterator appHandlerSet = handlers.iterator();
482:                while (appHandlerSet.hasNext()) {
483:                    Map.Entry appHandler = (Map.Entry) appHandlerSet.next();
484:                    String key = (String) appHandler.getKey();
485:                    if (key.equals(appValue)) {
486:                        return true;
487:                    }
488:                }
489:                return false;
490:            }
491:
492:            /**
493:             *  Gets the sSOAdapterProperties attribute of the ProviderEditUtility class
494:             *
495:             *@return    The sSOAdapterProperties value
496:             */
497:            public static Properties getSSOAdapterProperties() {
498:                return adapterProperties;
499:            }
500:
501:            /**
502:             *  This is the main method used by the application preference editing. It
503:             *  uses the display profile attributes dpEditAttributes and ssoEditAttributes
504:             *  to edit what is displayed.
505:             *
506:             *@param  type    type of parameter string, check, select, or password
507:             *@param  header  header to display
508:             *@param  key     key to create HTML item for
509:             *@param  pName   provider name
510:             *@param  pc      current provider context
511:             *@param  useDP   Defines if this is for the display profile or for the
512:             *      ssoAdapter
513:             *@return         Description of the Return Value
514:             */
515:            public static StringBuffer createEditContent(String type,
516:                    String header, String key, String pName,
517:                    ProviderContext pc, boolean useDP) {
518:                Hashtable tagTable = new Hashtable();
519:                StringBuffer content = new StringBuffer();
520:                List pflist = null;
521:                try {
522:                    setDefaultPresentation(pName, pc, tagTable);
523:                    tagTable.put("iwtDesktop-fontFace1", pc.getStringProperty(
524:                            pName, "fontFace1", "Sans-serif"));
525:                    pflist = pc.getClientAndLocalePropertiesFilters();
526:                } catch (ProviderContextException pce) {
527:                    if (logger.isLoggable(Level.SEVERE))
528:                        logger.log(Level.SEVERE, "PSSA_CSPP0010", pce);
529:                }
530:
531:                if (type.equals("string")) {
532:                    tagTable.put("header", header);
533:                    tagTable.put("attName", key);
534:                    try {
535:                        if (useDP) {
536:                            if (pc.existsStringProperty(pName, key, pflist)) {
537:                                tagTable.put("attValue", pc.getStringProperty(
538:                                        pName, key, "", pflist));
539:                            } else if (pc.existsStringProperty(pName, key)) {
540:                                tagTable.put("attValue", pc.getStringProperty(
541:                                        pName, key, ""));
542:                            } else {
543:                                tagTable.put("attValue", "");
544:                            }
545:                        } else {
546:                            tagTable.put("attValue", getSSOProperty(key));
547:                        }
548:                        String id = "id" + key;
549:                        tagTable.put("resourceName", id);
550:                        content.append(pc.getTemplate(pName,
551:                                "edit-string.template", tagTable));
552:                    } catch (ProviderContextException pce) {
553:                        if (logger.isLoggable(Level.SEVERE))
554:                            logger.log(Level.SEVERE, "PSSA_CSPP0010", pce);
555:                    }
556:
557:                } else if (type.equals("select")) {
558:                    Map selectMap = null;
559:                    String selectedValue = "";
560:                    try {
561:                        if (useDP) {
562:                            //selectedValue = pc.getStringProperty(pName, key, "");
563:                            if (pc.existsStringProperty(pName, key, pflist)) {
564:                                selectedValue = pc.getStringProperty(pName,
565:                                        key, "", pflist);
566:                            } else if (pc.existsStringProperty(pName, key)) {
567:                                selectedValue = pc.getStringProperty(pName,
568:                                        key, "");
569:                            } else {
570:                                selectedValue = "";
571:                            }
572:                        } else {
573:                            selectedValue = getSSOProperty(key);
574:                        }
575:                        try {
576:                            selectMap = pc.getCollectionProperty(pName, key
577:                                    + "SelectOptions", pflist);
578:                        } catch (ProviderContextException pce) {
579:                            selectMap = pc.getCollectionProperty(pName, key
580:                                    + "SelectOptions");
581:                        }
582:
583:                    } catch (ProviderContextException pce) {
584:                        if (logger.isLoggable(Level.SEVERE))
585:                            logger.log(Level.SEVERE, "PSSA_CSPP0010", pce);
586:                    }
587:
588:                    Set selEntries = selectMap.entrySet();
589:                    Iterator selIter = selEntries.iterator();
590:                    StringBuffer options = new StringBuffer();
591:                    while (selIter.hasNext()) {
592:                        // get values from DP
593:                        Map.Entry selEntry = (Map.Entry) selIter.next();
594:                        String selKey = (String) selEntry.getKey();
595:                        String selValue = (String) selEntry.getValue();
596:                        tagTable.put("attValue", selKey);
597:                        tagTable.put("string", selValue);
598:                        if (selKey.equals(selectedValue)) {
599:                            tagTable.put("selected", "SELECTED");
600:                        } else {
601:                            tagTable.put("selected", "");
602:                        }
603:                        try {
604:                            options.append(pc.getTemplate(pName,
605:                                    "edit-selectoption.template", tagTable));
606:                        } catch (ProviderContextException pce) {
607:                            if (logger.isLoggable(Level.SEVERE))
608:                                logger.log(Level.SEVERE, "PSSA_CSPP0010", pce);
609:                        }
610:                    }
611:                    tagTable.put("header", header);
612:                    tagTable.put("attName", key);
613:                    tagTable.put("options", options.toString());
614:                    String id = "id" + key;
615:                    tagTable.put("resourceName", id);
616:                    try {
617:                        content.append(pc.getTemplate(pName,
618:                                "edit-select.template", tagTable));
619:                    } catch (ProviderContextException pce) {
620:                        if (logger.isLoggable(Level.SEVERE))
621:                            logger.log(Level.SEVERE, "PSSA_CSPP0010", pce);
622:                    }
623:
624:                } else if (type.equals("check")) {
625:                    tagTable.put("header", header);
626:                    tagTable.put("attName", key);
627:                    String selected = "";
628:                    boolean isSelected = false;
629:                    try {
630:                        if (useDP) {
631:                            //isSelected = pc.getBooleanProperty(pName, key);
632:                            if (pc.existsBooleanProperty(pName, key, pflist)) {
633:                                isSelected = pc.getBooleanProperty(pName, key,
634:                                        pflist);
635:                            } else if (pc.existsStringProperty(pName, key)) {
636:                                isSelected = pc.getBooleanProperty(pName, key);
637:                            } else {
638:                                isSelected = Boolean.getBoolean("false");
639:                            }
640:                        } else {
641:                            Boolean bool = new Boolean(getSSOProperty(key));
642:                            isSelected = bool.booleanValue();
643:                        }
644:                        if (isSelected) {
645:                            selected = "CHECKED";
646:                        } else {
647:                            selected = "";
648:                        }
649:                        tagTable.put("attSelected", selected);
650:                        String id = "id" + key;
651:                        tagTable.put("resourceName", id);
652:                        content.append(pc.getTemplate(pName,
653:                                "edit-checkbox.template", tagTable));
654:                    } catch (ProviderContextException pce) {
655:                        if (logger.isLoggable(Level.SEVERE))
656:                            logger.log(Level.SEVERE, "PSSA_CSPP0010", pce);
657:                    }
658:
659:                } else if (type.equals("password")) {
660:                    tagTable.put("header", header);
661:                    tagTable.put("attName", key);
662:                    String pwd = "";
663:                    try {
664:                        if (useDP) {
665:                            if (pc.existsStringProperty(pName, key, pflist)) {
666:                                pwd = pc.getStringProperty(pName, key, "",
667:                                        pflist);
668:                            } else if (pc.existsStringProperty(pName, key)) {
669:                                pwd = pc.getStringProperty(pName, key, "");
670:                            } else {
671:                                pwd = "";
672:                            }
673:                        } else {
674:                            pwd = getSSOProperty(key);
675:                        }
676:                        if ((pwd == null) || (pwd.trim().length() == 0)) {
677:                            tagTable.put("attValue", "");
678:                        } else {
679:                            tagTable.put("attValue", "********");
680:                        }
681:                        String id = "id" + key;
682:                        tagTable.put("resourceName", id);
683:                        content.append(pc.getTemplate(pName,
684:                                "edit-password.template", tagTable));
685:                    } catch (ProviderContextException pce) {
686:                        if (logger.isLoggable(Level.SEVERE))
687:                            logger.log(Level.SEVERE, "PSSA_CSPP0010", pce);
688:                    }
689:                } else if (type.equals("int")) {
690:                    tagTable.put("header", header);
691:                    tagTable.put("attName", key);
692:                    try {
693:                        if (useDP) {
694:                            if (pc.existsIntegerProperty(pName, key, pflist)) {
695:                                tagTable.put("attValue", Integer
696:                                        .toString(pc.getIntegerProperty(pName,
697:                                                key, pflist)));
698:                            } else if (pc.existsIntegerProperty(pName, key)) {
699:                                tagTable.put("attValue", Integer.toString(pc
700:                                        .getIntegerProperty(pName, key)));
701:                            } else {
702:                                tagTable.put("attValue", "");
703:                            }
704:                        } else {
705:                            tagTable.put("attValue", getSSOProperty(key));
706:                        }
707:                        String id = "id" + key;
708:                        tagTable.put("resourceName", id);
709:                        content.append(pc.getTemplate(pName,
710:                                "edit-string.template", tagTable));
711:                    } catch (ProviderContextException pce) {
712:                        if (logger.isLoggable(Level.SEVERE))
713:                            logger.log(Level.SEVERE, "PSSA_CSPP0010", pce);
714:                    }
715:
716:                }
717:                return content;
718:            }
719:
720:            /**
721:             *  Gets the empty attribute of the ProviderEditUtility object
722:             *
723:             *@param  line  String to check
724:             *@return       The empty value
725:             */
726:            public static boolean isEmpty(String line) {
727:                if ((line == null) || (line.length() <= 0)) {
728:                    return true;
729:                } else {
730:                    return false;
731:                }
732:            }
733:
734:            /**
735:             * Wrapper class for encode.  Relies on class level charset attribute
736:             *
737:             * @param enc String to encode
738:             * @return Encoded string contents if successful or unencoded string results if failed.
739:             */
740:
741:            public static String encode(String enc, String charset) {
742:                String result = "";
743:                try {
744:                    result = URLEncoder.encode(enc, charset);
745:                } catch (UnsupportedEncodingException uee) {
746:                    if (logger.isLoggable(Level.SEVERE)) {
747:                        LogRecord rec = new LogRecord(Level.SEVERE,
748:                                "PSSA_CSPP0012");
749:                        rec.setThrown(uee);
750:                        String[] param = { enc, charset };
751:                        rec.setParameters(param);
752:                        rec.setLoggerName(logger.getName());
753:                        logger.log(rec);
754:                    }
755:                    return enc;
756:                }
757:                return result;
758:            }
759:
760:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.