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


0001:        /**
0002:         *  $Id: AddressBookProvider.java,v 1.86 2005/09/21 10:40:04 dg154973 Exp $
0003:         *  Copyright 2002 Sun Microsystems, Inc. All rights reserved. Use of this
0004:         *  product is subject to license terms. Federal Acquisitions: Commercial
0005:         *  Software -- Government Users Subject to Standard License Terms and
0006:         *  Conditions. Sun, Sun Microsystems, the Sun logo, and iPlanet are trademarks
0007:         *  or registered trademarks of Sun Microsystems, Inc. in the United States and
0008:         *  other countries.
0009:         */package com.sun.portal.providers.ab;
0010:
0011:        import java.net.URL;
0012:        import java.net.URLEncoder;
0013:        import java.net.MalformedURLException;
0014:
0015:        import java.io.UnsupportedEncodingException;
0016:
0017:        import java.util.Enumeration;
0018:        import java.util.HashMap;
0019:        import java.util.Hashtable;
0020:        import java.util.Iterator;
0021:        import java.util.List;
0022:        import java.util.Map;
0023:        import java.util.Map.Entry;
0024:        import java.util.MissingResourceException;
0025:        import java.util.Properties;
0026:        import java.util.ResourceBundle;
0027:        import java.util.Vector;
0028:        import java.util.logging.Logger;
0029:        import java.util.logging.Level;
0030:        import java.util.logging.LogRecord;
0031:
0032:        import javax.servlet.http.HttpServletRequest;
0033:        import javax.servlet.http.HttpServletResponse;
0034:
0035:        import javax.mail.AuthenticationFailedException;
0036:        import javax.mail.MessagingException;
0037:
0038:        import com.sun.portal.providers.context.ProviderContext;
0039:        import com.sun.portal.providers.ProfileProviderAdapter;
0040:        import com.sun.portal.providers.ProviderAdapter;
0041:        import com.sun.portal.providers.ProviderException;
0042:        import com.sun.portal.providers.context.ProviderContextException;
0043:        import com.sun.portal.providers.ProviderEditUtility;
0044:        import com.sun.portal.desktop.encode.Encoder;
0045:        import com.sun.portal.desktop.encode.EncoderException;
0046:        import com.iplanet.sso.SSOToken;
0047:        import com.iplanet.sso.SSOException;
0048:        import com.sun.portal.log.common.PortalLogger;
0049:
0050:        import java.lang.reflect.Constructor;
0051:        import java.lang.reflect.InvocationTargetException;
0052:
0053:        //  JABAPI imports
0054:        import com.sun.addressbook.ABFilter;
0055:        import com.sun.addressbook.ABSearchTerm;
0056:        import com.sun.addressbook.ABStore;
0057:        import com.sun.addressbook.AddressBook;
0058:        import com.sun.addressbook.ABStoreException;
0059:        import com.sun.addressbook.Element;
0060:        import com.sun.addressbook.Group;
0061:
0062:        //  SSOAdapter imports
0063:        import com.sun.ssoadapter.SSOAdapter;
0064:        import com.sun.ssoadapter.SSOAdapterSession;
0065:        import com.sun.ssoadapter.SSOAdapterException;
0066:        import com.sun.ssoadapter.SSOAdapterFactory;
0067:
0068:        /**
0069:         *  Description of the Class
0070:         *
0071:         *@author     Administrator
0072:         *@created    April 7, 2003
0073:         */
0074:        public class AddressBookProvider extends ProfileProviderAdapter {
0075:
0076:            private final static int defaultNum = 5;
0077:            private final static int defaultMaxNum = 30;
0078:            private final static String componentId = "iwtAddressBookProvider";
0079:
0080:            private ProviderContext providerContext = null;
0081:            private ResourceBundle bundle = null;
0082:            protected SSOAdapterFactory adapterFactory = null;
0083:
0084:            // For coming back to the edit screen in case of error
0085:            private String container = null;
0086:            protected String editContainer = "";
0087:            protected String targetProvider = "";
0088:            protected String containerName = "";
0089:
0090:            // Attribute names in the DSAME's Addressbook service
0091:            private final static String sortByAttributeName = "sunPortalABSortBy";
0092:            private final static String sortOrderAttributeName = "sunPortalABSortOrder";
0093:
0094:            // Sort order values as stored in the DSAME's Addressbook service
0095:            private final static String sortOrderAscending = "Up";
0096:            private final static String sortOrderDescending = "Down";
0097:            private final static String sortOrderNone = "none";
0098:
0099:            protected HashMap appHandlers = null;
0100:            protected List pflist = null;
0101:
0102:            // flag to determine sso adapter configuration existence in init()
0103:            protected Boolean isPresentable = null;
0104:
0105:            // flag to determine presentability in init()
0106:            protected boolean isSSOConfigFound = true;
0107:
0108:            // user's charset
0109:            protected String charset = null;
0110:
0111:            // Create a logger for this class
0112:            private static Logger debugLogger = PortalLogger
0113:                    .getLogger(AddressBookProvider.class);
0114:
0115:            /**
0116:             *  Initialize the provider Check to see if <code>ssoAdapter</code> exists. If
0117:             *  not then set <code>isSSOConfigFound</code> to false disabling
0118:             *  editability for the user's Session.
0119:             *
0120:             *@param  name                   Description of the Parameter
0121:             *@param  request                Description of the Parameter
0122:             *@exception  ProviderException  Description of the Exception
0123:             */
0124:            public void init(String name, HttpServletRequest request)
0125:                    throws ProviderException {
0126:                super .init(name, request);
0127:                appHandlers = new HashMap();
0128:                bundle = getResourceBundle();
0129:                providerContext = getProviderContext();
0130:                adapterFactory = SSOAdapterFactory.getInstance();
0131:                try {
0132:                    pflist = getProviderContext()
0133:                            .getClientAndLocalePropertiesFilters();
0134:                    // check for ssoadapter configuration existence
0135:                    debugLogger
0136:                            .log(Level.FINER, "PSAC_CSPPA0001",
0137:                                    new Object[] {
0138:                                            getBestStringProperty("ssoAdapter",
0139:                                                    pflist),
0140:                                            getProviderContext().getLocale(),
0141:                                            getProviderContext().getUserID(),
0142:                                            getName() });
0143:                    SSOAdapter ssoAdapter = (SSOAdapter) adapterFactory
0144:                            .getSSOAdapter(getBestStringProperty("ssoAdapter",
0145:                                    pflist),
0146:                                    new SSOAdapterSession(request,
0147:                                            getProviderContext().getLocale(),
0148:                                            getProviderContext().getUserID(),
0149:                                            getName()));
0150:                    SSOToken token = ssoAdapter.getSSOToken();
0151:                    charset = token.getProperty("CharSet");
0152:                    debugLogger.log(Level.FINER, "PSAC_CSPPA0027", charset);
0153:                } catch (ProviderContextException pce) {
0154:                    debugLogger.log(Level.FINE, "PSAC_CSPPA0028", new Object[] {
0155:                            getName(), pce.getMessage() });
0156:                } catch (SSOAdapterException ssoe) {
0157:                    isSSOConfigFound = false;
0158:                    debugLogger.log(Level.FINE, "PSAC_CSPPA0029", new Object[] {
0159:                            getName(), ssoe.getMessage() });
0160:                } catch (SSOException sse) {
0161:                    debugLogger.log(Level.FINE, "PSAC_CSPPA0030", new Object[] {
0162:                            getName(), sse.getMessage() });
0163:                }
0164:
0165:                // pre-calculate presentability
0166:                // in the non-authless case in order to
0167:                // prevent re-calc'ing it each request
0168:                //
0169:                if (!getProviderContext().isAuthless(request)) {
0170:                    if (isPresentable(request)) {
0171:                        isPresentable = Boolean.TRUE;
0172:                    } else {
0173:                        isPresentable = Boolean.FALSE;
0174:                    }
0175:                }
0176:            }
0177:
0178:            /**
0179:             * Channel is presentable if
0180:             * 1) parent.isPresentable()
0181:             * 2) existence of <code>display.template</code>
0182:             * 3) existence of sso adapter template
0183:             *
0184:             * @return true or false
0185:             */
0186:            public boolean isPresentable(HttpServletRequest request) {
0187:                boolean ip = false;
0188:                boolean presentableVal = false;
0189:                try {
0190:                    getTemplate("display.template");
0191:                } catch (ProviderException pe) {
0192:                    debugLogger.info("PSAC_CSPPA0002");
0193:                    return false;
0194:                }
0195:
0196:                if (isPresentable != null) {
0197:                    ip = isPresentable.booleanValue();
0198:                    presentableVal = (ip && isSSOConfigFound);
0199:                } else {
0200:                    presentableVal = isSSOConfigFound;
0201:                }
0202:                debugLogger.log(Level.FINER, "PSAC_CSPPA0031", Boolean
0203:                        .toString(presentableVal));
0204:                return presentableVal;
0205:            }
0206:
0207:            /**
0208:             *  Generate the HTML that will be displayed in this content provider's area on
0209:             *  the desktop
0210:             *
0211:             *@param  request                Description of the Parameter
0212:             *@param  response               Description of the Parameter
0213:             *@return                        The content value
0214:             *@exception  ProviderException  Description of the Exception
0215:             */
0216:            public StringBuffer getContent(HttpServletRequest request,
0217:                    HttpServletResponse response) throws ProviderException {
0218:
0219:                SSOAdapter ssoAdapter = null;
0220:                Properties ssoProps = null;
0221:                ABStore store = null;
0222:                AddressBook ab = null;
0223:                try {
0224:                    ssoAdapter = (SSOAdapter) adapterFactory.getSSOAdapter(
0225:                            getBestStringProperty("ssoAdapter", pflist),
0226:                            new SSOAdapterSession(request, getProviderContext()
0227:                                    .getLocale(), getProviderContext()
0228:                                    .getUserID(), getName()));
0229:
0230:                    ssoProps = ssoAdapter.getProperties();
0231:                    store = (ABStore) ssoAdapter.getConnection();
0232:                    ab = store.openAddressBook();
0233:                } catch (Exception e) {
0234:                    debugLogger.log(Level.FINER, "PSAC_CSPPA0032", e);
0235:
0236:                    // sso adapter does not exist
0237:                    if (ssoAdapter == null) {
0238:                        debugLogger.finer("PSAC_CSPPA0011");
0239:                        return getErrorContent(bundle
0240:                                .getString("AddressBookProvider-ssoerror"));
0241:                    }
0242:
0243:                    // user level sso adapter does not exist
0244:                    if ((ssoAdapter != null)
0245:                            && (!ssoAdapter.getName().endsWith("_" + getName()))) {
0246:                        debugLogger.finer("PSAC_CSPPA0033");
0247:                        return getErrorContent(bundle
0248:                                .getString("AddressBookProvider-specifyConfig"));
0249:                    }
0250:
0251:                    String user_id = ssoProps.getProperty("uid");
0252:                    String password = ssoProps.getProperty("password");
0253:
0254:                    boolean user_id_unavailable = (user_id == null)
0255:                            || (user_id.equals(""));
0256:                    boolean password_unavailable = (password == null)
0257:                            || (password.equals(""));
0258:
0259:                    if ((user_id_unavailable) && (password_unavailable)) {
0260:                        debugLogger.finer("PSAC_CSPPA0034");
0261:                        return (getErrorContent(bundle
0262:                                .getString("AddressBookProvider-uid-password-err")));
0263:                    } else if (user_id_unavailable) {
0264:                        debugLogger.finer("PSAC_CSPPA0035");
0265:                        return (getErrorContent(bundle
0266:                                .getString("AddressBookProvider-uid-err")));
0267:                    } else if (password_unavailable) {
0268:                        debugLogger.finer("PSAC_CSPPA0036");
0269:                        return (getErrorContent(bundle
0270:                                .getString("AddressBookProvider-password-err")));
0271:                    } else {
0272:                        debugLogger.finer("PSAC_CSPPA0037");
0273:                        return (getErrorContent(bundle
0274:                                .getString("AddressBookProvider-ldaperr")));
0275:                    }
0276:                }
0277:
0278:                ABFilter filter = new ABFilter();
0279:
0280:                String sort_by = getBestStringProperty(sortByAttributeName,
0281:                        pflist);
0282:                if (sort_by.equals("Lastname")) {
0283:                    sort_by = ABFilter.LN;
0284:                } else if (sort_by.equals("Firstname")) {
0285:                    sort_by = ABFilter.FN;
0286:                } else if (sort_by.equals("Email")) {
0287:                    sort_by = ABFilter.EM;
0288:                } else if (sort_by.equals("Commonname")) {
0289:                    sort_by = ABFilter.CN;
0290:                } else {
0291:                    sort_by = ""; // default
0292:                }
0293:
0294:                if ((sort_by != null) && (!sort_by.equals(""))
0295:                        && (!sort_by.equals("none"))
0296:                        && (!sort_by.equals("NoSort"))) {
0297:                    filter.setSortBy(sort_by);
0298:                }
0299:
0300:                String sort_order_string = getBestStringProperty(
0301:                        sortOrderAttributeName, pflist);
0302:                int sort_order = ABFilter.NO_SORT;
0303:                if (sortOrderAscending.equals(sort_order_string)) {
0304:                    sort_order = ABFilter.ASCENDING;
0305:                } else if (sortOrderDescending.equals(sort_order_string)) {
0306:                    sort_order = ABFilter.DESCENDING;
0307:                }
0308:                filter.setSortOrder(sort_order);
0309:                filter.setSearchTerm(ab.newABSearchTerm("any", "*", true));
0310:
0311:                // Change the following elementType to ALL when groups need to be displayed
0312:                //  in AddressBookProvider
0313:                //filter.setElementType(Element.ENTRY);
0314:                filter.setElementType(Element.ALL);
0315:
0316:                Element[] elements = null;
0317:                try {
0318:                    elements = (Element[]) ab.fetch(filter);
0319:                } catch (Exception abse) {
0320:                    debugLogger.log(Level.INFO, "PSAC_CSPPA0038", abse);
0321:                    return (getErrorContent(bundle
0322:                            .getString("AddressBookProvider-ldaperr")));
0323:                }
0324:
0325:                Hashtable contentTags = new Hashtable();
0326:                try {
0327:                    ProviderEditUtility.setDefaultPresentation(getName(),
0328:                            getProviderContext(), contentTags);
0329:                } catch (ProviderContextException pce) {
0330:                    debugLogger.log(Level.INFO, "PSAC_CSPPA0003", pce);
0331:                }
0332:
0333:                if ((getBestBooleanProperty("displayEntries", true, pflist))
0334:                        && (elements != null)) {
0335:                    contentTags.put("ab-display-entries",
0336:                            getEntriesContent(elements));
0337:                } else {
0338:                    contentTags.put("ab-display-entries", new StringBuffer());
0339:                }
0340:
0341:                // Summary stuff
0342:                contentTags.put("ab-display-summary",
0343:                        getSummaryContent(elements));
0344:
0345:                String applicationURL = "";
0346:                AddressBookApplicationHelper appHelper = null;
0347:                String appHelperClass = "";
0348:                appHelperClass = getBestStringProperty("applicationHelperURL",
0349:                        pflist);
0350:
0351:                if (appHelperClass != null) {
0352:                    appHelper = getABAppHelper(ssoAdapter, appHelperClass, true);
0353:                    if (appHelper != null) {
0354:                        applicationURL = getApplicationStartURL(appHelper,
0355:                                request);
0356:                    } else {
0357:                        applicationURL = null;
0358:                    }
0359:                    if (applicationURL != null) {
0360:                        contentTags.put("ab-display-clientURL",
0361:                                getClientURLContent(applicationURL));
0362:                    } else {
0363:                        contentTags.put("ab-display-clientURL", " ");
0364:                    }
0365:                } else {
0366:                    contentTags.put("ab-display-clientURL", " ");
0367:                }
0368:
0369:                // connection management.  check ssoadapter for per request connection
0370:                // management property.  if true, then close connection to store.
0371:                //
0372:                String eprc = ssoProps.getProperty(
0373:                        "enablePerRequestConnection", "false");
0374:
0375:                if ((eprc != null) && (eprc.equals("true"))) {
0376:                    ssoAdapter.closeConnection();
0377:                }
0378:
0379:                return (getTemplate("display.template", contentTags));
0380:            }
0381:
0382:            /**
0383:             *  Get the result set converted to Stringbuffer, and also fill in the the
0384:             *  appropriate tags for displaying a single element
0385:             *
0386:             *@param  elements               Array containing the address book elements
0387:             *@return                        Stringbuffer containing the tags and their
0388:             *      values needed to get the elements in templates
0389:             *@exception  ProviderException  Description of the Exception
0390:             */
0391:            private StringBuffer getEntriesContent(Element[] elements)
0392:                    throws ProviderException {
0393:                StringBuffer entryList = new StringBuffer();
0394:                Hashtable entryListTags = new Hashtable();
0395:                try {
0396:                    ProviderEditUtility.setDefaultPresentation(getName(),
0397:                            getProviderContext(), entryListTags);
0398:                } catch (ProviderContextException pce) {
0399:                    debugLogger.log(Level.FINER, "PSAC_CSPPA0003", pce);
0400:                }
0401:                String font = getBestStringProperty("fontFace1", "Sans-serif",
0402:                        pflist);
0403:
0404:                if ((elements != null) && (elements.length > 0)) {
0405:                    debugLogger.log(Level.FINER, "PSAC_CSPPA0004", Integer
0406:                            .toString(elements.length));
0407:
0408:                    // Get the maximum number of elements that a user can set to display
0409:                    int max = getBestIntegerProperty("maxEntries",
0410:                            defaultMaxNum, pflist);
0411:
0412:                    // Get the number of elements to be displayed.
0413:                    int num = getBestIntegerProperty("numEntries", defaultNum,
0414:                            pflist);
0415:                    if (num > max) {
0416:                        num = max;
0417:                    }
0418:
0419:                    String cbgc = "";
0420:                    String entryWithoutEmailMsg = "";
0421:
0422:                    try {
0423:                        cbgc = bundle.getString("AddressBookProvider-cbgc");
0424:                        if (cbgc == null) {
0425:                            cbgc = "";
0426:                        }
0427:
0428:                        debugLogger.log(Level.FINER, "PSAC_CSPPA0005", cbgc);
0429:
0430:                        entryWithoutEmailMsg = bundle
0431:                                .getString("AddressBookProvider-entryWithoutEmail");
0432:                        if (entryWithoutEmailMsg == null) {
0433:                            entryWithoutEmailMsg = "";
0434:                        }
0435:                    } catch (MissingResourceException mre) {
0436:                        debugLogger.log(Level.FINER, "PSAC_CSPPA0003", mre);
0437:                    } catch (Exception e) {
0438:                        debugLogger.log(Level.FINER, "PSAC_CSPPA0003", e);
0439:                    }
0440:
0441:                    // for doing tag replacements for each AB element
0442:                    Hashtable entryTags = new Hashtable();
0443:                    int numEntriesToDisplay = (num < elements.length) ? num
0444:                            : elements.length;
0445:                    for (int count = 0; count < numEntriesToDisplay; count++) {
0446:                        Element element = elements[count];
0447:                        if (element == null) {
0448:                            continue;
0449:                        }
0450:                        // Fully defined since compilier unable to differentiate betwen this Entry class
0451:                        // and the Map.Entry class
0452:                        com.sun.addressbook.Entry entry = null;
0453:                        Group group = null;
0454:                        String firstName = null;
0455:                        String lastName = null;
0456:                        String commonName = null;
0457:                        String email = null;
0458:
0459:                        entryTags.put("ab-display-entry-cbgc", cbgc);
0460:
0461:                        if ((element.getElementType() == Element.ENTRY)
0462:                                || (element.getElementType() == Element.UNSPECIFIED)) {
0463:                            entry = (com.sun.addressbook.Entry) element;
0464:                            firstName = escape(entry.getFn());
0465:                            lastName = escape(entry.getLn());
0466:                            commonName = escape(entry.getCn());
0467:                            email = escape(entry.getEm());
0468:
0469:                            if (firstName != null) {
0470:                                entryTags.put("ab-display-entry-firstname",
0471:                                        firstName);
0472:                            }
0473:                            if (lastName != null) {
0474:                                entryTags.put("ab-display-entry-lastname",
0475:                                        lastName);
0476:                            }
0477:                            if (email != null) {
0478:                                entryTags.put("ab-display-entry-email", email);
0479:                                entryTags.put("ab-display-entry-email-link",
0480:                                        email);
0481:                            }
0482:                        } else if ((element.getElementType() == Element.ALL)
0483:                                || (element.getElementType() == Element.GROUP)) {
0484:                            group = (Group) element;
0485:                            commonName = escape(group.getCn());
0486:
0487:                            if (commonName != null) {
0488:                                entryTags.put("ab-display-entry-commonname",
0489:                                        commonName);
0490:                            }
0491:                        }
0492:
0493:                        // change this
0494:                        entryTags.put("iwtDesktop-fontFace1", font);
0495:                        try {
0496:                            ProviderEditUtility.setDefaultPresentation(
0497:                                    getName(), getProviderContext(), entryTags);
0498:                        } catch (ProviderContextException pce) {
0499:                            debugLogger.log(Level.INFO, "PSAC_CSPPA0003", pce);
0500:                        }
0501:                        entryList.append(getTemplate("display-entry.template",
0502:                                entryTags));
0503:
0504:                        // clear the tags table for reuse
0505:                        entryTags.clear();
0506:                    }
0507:                }
0508:                entryListTags.put("ab-display-entry-list", entryList);
0509:                entryListTags.put("iwtDesktop-fontFace1", font);
0510:
0511:                return (getTemplate("display-entries.template", entryListTags));
0512:            }
0513:
0514:            /**
0515:             *  Get the summary of the Address book provider
0516:             *
0517:             *@param  elements               Array containing the address book elements
0518:             *@return                        Stringbuffer containing the tags and their
0519:             *      values needed to get the summary in templates
0520:             *@exception  ProviderException  Description of the Exception
0521:             */
0522:            private StringBuffer getSummaryContent(Element[] elements)
0523:                    throws ProviderException {
0524:                int count = 0;
0525:
0526:                if (elements != null) {
0527:                    count = elements.length;
0528:                }
0529:
0530:                debugLogger.log(Level.FINER, "PSAC_CSPPA0006", Integer
0531:                        .toString(count));
0532:
0533:                Hashtable summaryTags = new Hashtable(1);
0534:                try {
0535:                    ProviderEditUtility.setDefaultPresentation(getName(),
0536:                            getProviderContext(), summaryTags);
0537:                } catch (ProviderContextException pce) {
0538:                    debugLogger.log(Level.FINER, "PSAC_CSPPA0003", pce);
0539:                }
0540:
0541:                summaryTags.put("ab-display-summary-entries", Integer
0542:                        .toString(count));
0543:                summaryTags.put("iwtDesktop-fontFace1", getBestStringProperty(
0544:                        "fontFace1", "Sans-serif", pflist));
0545:
0546:                return (getTemplate("display-summary.template", summaryTags));
0547:            }
0548:
0549:            /**
0550:             *  Get the Stringbuffer containing the single sign on url
0551:             *
0552:             *@param  applicationURL         URL to access the application
0553:             *@return                        Stringbuffer containing the application access
0554:             *      URL
0555:             *@exception  ProviderException  Description of the Exception
0556:             */
0557:            private StringBuffer getClientURLContent(String applicationURL)
0558:                    throws ProviderException {
0559:
0560:                debugLogger.log(Level.FINER, "PSAC_CSPPA0007", applicationURL);
0561:
0562:                Hashtable clientURLTags = new Hashtable();
0563:                clientURLTags
0564:                        .put("ab-display-clientURL-appURL", applicationURL);
0565:
0566:                return (getTemplate("display-clientURL.template", clientURLTags));
0567:            }
0568:
0569:            /**
0570:             *  Get the error page contents
0571:             *
0572:             *@param  msg                    String message to be displayed on the error
0573:             *      page
0574:             *@return                        Stringbuffer containing the tags and their
0575:             *      values needed to display the error page
0576:             *@exception  ProviderException  Description of the Exception
0577:             */
0578:            private StringBuffer getErrorContent(String msg)
0579:                    throws ProviderException {
0580:                Hashtable errorTags = new Hashtable();
0581:                errorTags.put("ab-display-error", msg);
0582:                errorTags.put("iwtDesktop-fontFace1", getBestStringProperty(
0583:                        "fontFace1", "Sans-serif", pflist));
0584:                return (getTemplate("display-error.template", errorTags));
0585:            }
0586:
0587:            /**
0588:             *  Generate the HTML that will be displayed to let the user set his/her
0589:             *  preferneces.
0590:             *
0591:             *@param  request                Description of the Parameter
0592:             *@param  response               Description of the Parameter
0593:             *@return                        The edit value
0594:             *@exception  ProviderException  Description of the Exception
0595:             */
0596:            public StringBuffer getEdit(HttpServletRequest request,
0597:                    HttpServletResponse response) throws ProviderException {
0598:
0599:                StringBuffer content = new StringBuffer();
0600:                SSOAdapter ssoAdapter = null;
0601:                Hashtable tagTable = new Hashtable();
0602:                editContainer = request.getParameter("provider");
0603:                targetProvider = request.getParameter("targetprovider");
0604:                containerName = request.getParameter("containerName");
0605:
0606:                debugLogger.log(Level.FINER, "PSAC_CSPPA0008", new Object[] {
0607:                        editContainer, targetProvider, containerName });
0608:
0609:                try {
0610:                    ssoAdapter = (SSOAdapter) adapterFactory.getSSOAdapter(
0611:                            getBestStringProperty("ssoAdapter", pflist),
0612:                            new SSOAdapterSession(request, getProviderContext()
0613:                                    .getLocale(), getProviderContext()
0614:                                    .getUserID(), getName()));
0615:                    ProviderEditUtility.setDefaultPresentation(getName(),
0616:                            getProviderContext(), tagTable);
0617:                } catch (ProviderContextException pce) {
0618:                    debugLogger.log(Level.FINER, "PSAC_CSPPA0009", pce);
0619:                } catch (Exception e) {
0620:                    debugLogger.log(Level.FINER, "PSAC_CSPPA0010", e);
0621:                }
0622:
0623:                if (ssoAdapter == null)
0624:                    debugLogger.finer("PSAC_CSPPA0011");
0625:
0626:                String appPref = ProviderEditUtility.getRequestParameter(
0627:                        "appPref", request);
0628:                if (!appPref.equals("")) {
0629:                    AddressBookApplicationHelper abah = getABAppHelper(
0630:                            ssoAdapter, appPref, false);
0631:                    content = abah.getAppPrefsEdit(this , request, response);
0632:                } else {
0633:
0634:                    String fontTag = getBestStringProperty("fontFace1",
0635:                            "Sans-serif", pflist);
0636:                    tagTable.put("iwtDesktop-fontFace1", fontTag);
0637:                    // Get the starting template
0638:                    content
0639:                            .append(getTemplate("edit-start.template", tagTable));
0640:
0641:                    // Get the SSOAdapter attributes
0642:                    try {
0643:                        content.append(ProviderEditUtility.getSSOAdapterPrefs(
0644:                                (ProviderAdapter) this , ssoAdapter));
0645:                    } catch (Exception e) {
0646:                        debugLogger.log(Level.FINER, "PSAC_CSPPA0012", e);
0647:                    }
0648:
0649:                    // Get ending template
0650:                    content.append(getTemplate("edit-end.template", tagTable));
0651:
0652:                    AddressBookApplicationHelper abah = null;
0653:                    Map appHelperClasses = getAppHandlerMap();
0654:                    if (appHelperClasses == null) {
0655:                        debugLogger.fine("PSAC_CSPPA0013");
0656:                    } else {
0657:                        // don't generate link if null
0658:                        Iterator iter = appHelperClasses.entrySet().iterator();
0659:                        while (iter.hasNext()) {
0660:                            Map.Entry appClass = (Map.Entry) iter.next();
0661:                            String appHelperClass = (String) appClass
0662:                                    .getValue();
0663:                            abah = getABAppHelper(ssoAdapter, appHelperClass,
0664:                                    true);
0665:                            String link = "";
0666:                            if (abah == null) {
0667:                                debugLogger.fine("PSAC_CSPPA0014");
0668:                            } else {
0669:                                link = abah.getAppHelperEditLink(request,
0670:                                        getProviderContext());
0671:                            }
0672:                            if ((link != null) || (!link.equals(""))) {
0673:                                content.append(link);
0674:                            } else {
0675:                                debugLogger.fine("PSAC_CSPPA0015");
0676:                            }
0677:
0678:                        }
0679:                    }
0680:
0681:                }
0682:
0683:                return content;
0684:
0685:            }
0686:
0687:            /**
0688:             *  Handle the submittal of the edit form.
0689:             *
0690:             *@param  req                    Description of the Parameter
0691:             *@param  res                    Description of the Parameter
0692:             *@return                        Description of the Return Value
0693:             *@exception  ProviderException  Description of the Exception
0694:             */
0695:            public URL processEdit(HttpServletRequest req,
0696:                    HttpServletResponse res) throws ProviderException {
0697:                SSOAdapter ssoAdapter = null;
0698:                URL returnURL = null;
0699:                editContainer = req.getParameter("provider");
0700:                targetProvider = req.getParameter("targetprovider");
0701:                containerName = req.getParameter("containerName");
0702:
0703:                try {
0704:                    ssoAdapter = (SSOAdapter) adapterFactory.getSSOAdapter(
0705:                            getBestStringProperty("ssoAdapter", pflist),
0706:                            new SSOAdapterSession(req, getProviderContext()
0707:                                    .getLocale(), getProviderContext()
0708:                                    .getUserID(), getName()));
0709:                } catch (SSOAdapterException ssoe) {
0710:                    debugLogger.log(Level.FINER, "PSAC_CSPPA0010", ssoe);
0711:                }
0712:
0713:                String appPref = ProviderEditUtility.getRequestParameter(
0714:                        "appPref", req);
0715:                debugLogger
0716:                        .log(Level.FINER, "PSAC_CSPPA0016", new Object[] {
0717:                                editContainer, targetProvider, containerName,
0718:                                appPref });
0719:
0720:                AddressBookApplicationHelper abah = null;
0721:                if (!appPref.equals("")) {
0722:                    abah = getABAppHelper(ssoAdapter, appPref, false);
0723:                    if (abah == null) {
0724:                        debugLogger.info("PSAC_CSPPA0017");
0725:                        returnURL = null;
0726:                    } else {
0727:                        returnURL = abah.processAppPrefsEdit(this , req, res);
0728:                        debugLogger.log(Level.FINER, "PSAC_CSPPA0018",
0729:                                returnURL);
0730:                    }
0731:                } else {
0732:
0733:                    //Set the SSOAdapter attributes
0734:                    ProviderEditUtility.editContainer = editContainer;
0735:                    ProviderEditUtility.container = containerName;
0736:                    SSOAdapter newAdapter = null;
0737:                    try {
0738:                        newAdapter = ProviderEditUtility.setSSOAdapterPrefs(
0739:                                (ProviderAdapter) this , ssoAdapter,
0740:                                adapterFactory, req);
0741:                        returnURL = ProviderEditUtility.getErrorURL();
0742:                        if (returnURL == null) {
0743:                            if (newAdapter != null) {
0744:                                debugLogger.finer("PSAC_CSPPA0019");
0745:                                appPref = getBestStringProperty(
0746:                                        "applicationHelperURL", pflist);
0747:                                abah = getABAppHelper(ssoAdapter, appPref,
0748:                                        false);
0749:                                abah.init(this , newAdapter);
0750:                            }
0751:                        }
0752:                    } catch (Exception e) {
0753:                        debugLogger.finer("PSAC_CSPPA0020");
0754:                    }
0755:
0756:                }
0757:                return returnURL;
0758:            }
0759:
0760:            /**
0761:             * Returns the DP property by attempting to retrieve client and localized properties first
0762:             * then it searches for non conditional definitions
0763:             *
0764:             * @param pflist                 List containg the client and locale filters
0765:             * @param key                    Display Preofile key
0766:             * @return                       Returns the best value for the DP key
0767:             */
0768:            public String getBestStringProperty(String key, String def,
0769:                    List pflist) {
0770:                ProviderContext pc = getProviderContext();
0771:                try {
0772:                    if (key != null) {
0773:                        if (pc
0774:                                .existsStringProperty(this .getName(), key,
0775:                                        pflist)) {
0776:                            return pc.getStringProperty(this .getName(), key,
0777:                                    pflist);
0778:                        } else if (pc.existsStringProperty(this .getName(), key)) {
0779:                            return pc.getStringProperty(this .getName(), key);
0780:                        }
0781:                    }
0782:                    return def;
0783:                } catch (ProviderContextException pce) {
0784:                    if (debugLogger.isLoggable(Level.FINE)) {
0785:                        LogRecord logRecord = new LogRecord(Level.FINE,
0786:                                "PSAC_CSPPA0021");
0787:                        logRecord.setLoggerName(debugLogger.getName());
0788:                        logRecord.setParameters(new Object[] { key });
0789:                        logRecord.setThrown(pce);
0790:                        debugLogger.log(logRecord);
0791:                    }
0792:                    return def;
0793:                }
0794:            }
0795:
0796:            public String getBestStringProperty(String key, List pflist) {
0797:                return getBestStringProperty(key, "", pflist);
0798:            }
0799:
0800:            /**
0801:             * Returns the DP property by attempting to retrieve client and localized properties first
0802:             * then it searches for non conditional definitions
0803:             *
0804:             * @param pflist                 List containg the client and locale filters
0805:             * @param key                    Display Preofile key
0806:             * @return                       Returns the best value for the DP key
0807:             */
0808:            public int getBestIntegerProperty(String key, int def, List pflist) {
0809:                ProviderContext pc = getProviderContext();
0810:                try {
0811:                    if (key != null) {
0812:                        if (pc.existsIntegerProperty(this .getName(), key,
0813:                                pflist)) {
0814:                            return pc.getIntegerProperty(this .getName(), key,
0815:                                    pflist);
0816:                        } else if (pc
0817:                                .existsIntegerProperty(this .getName(), key)) {
0818:                            return pc.getIntegerProperty(this .getName(), key);
0819:                        }
0820:                    }
0821:                    return def;
0822:                } catch (ProviderContextException pce) {
0823:                    if (debugLogger.isLoggable(Level.FINE)) {
0824:                        LogRecord logRecord = new LogRecord(Level.FINE,
0825:                                "PSAC_CSPPA0021");
0826:                        logRecord.setLoggerName(debugLogger.getName());
0827:                        logRecord.setParameters(new Object[] { key });
0828:                        logRecord.setThrown(pce);
0829:                        debugLogger.log(logRecord);
0830:                    }
0831:                    return def;
0832:                }
0833:            }
0834:
0835:            public int getBestIntegerProperty(String key, List pflist) {
0836:                return getBestIntegerProperty(key, -1, pflist);
0837:            }
0838:
0839:            /**
0840:             * Returns the DP property by attempting to retrieve client and localized properties first
0841:             * then it searches for non conditional definitions
0842:             *
0843:             * @param pflist                 List containg the client and locale filters
0844:             * @param key                    Display Preofile key
0845:             * @return                       Returns the best value for the DP key
0846:             */
0847:            public Map getBestCollectionProperty(String key, Map def,
0848:                    List pflist) {
0849:                ProviderContext pc = getProviderContext();
0850:                try {
0851:                    if (key != null) {
0852:                        if (pc.existsCollectionProperty(this .getName(), key,
0853:                                pflist)) {
0854:                            return pc.getCollectionProperty(this .getName(),
0855:                                    key, pflist);
0856:                        } else if (pc.existsCollectionProperty(this .getName(),
0857:                                key)) {
0858:                            return pc
0859:                                    .getCollectionProperty(this .getName(), key);
0860:                        }
0861:                    }
0862:                    return def;
0863:                } catch (ProviderContextException pce) {
0864:                    if (debugLogger.isLoggable(Level.FINE)) {
0865:                        LogRecord logRecord = new LogRecord(Level.FINE,
0866:                                "PSAC_CSPPA0021");
0867:                        logRecord.setLoggerName(debugLogger.getName());
0868:                        logRecord.setParameters(new Object[] { key });
0869:                        logRecord.setThrown(pce);
0870:                        debugLogger.log(logRecord);
0871:                    }
0872:                    return def;
0873:                }
0874:            }
0875:
0876:            public Map getBestCollectionProperty(String key, List pflist) {
0877:                return getBestCollectionProperty(key, null, pflist);
0878:            }
0879:
0880:            /**
0881:             * Returns the DP property by attempting to retrieve client and localized properties first
0882:             * then it searches for non conditional definitions
0883:             *
0884:             * @param pflist                 List containg the client and locale filters
0885:             * @param key                    Display Preofile key
0886:             * @return                       Returns the best value for the DP key
0887:             */
0888:            public boolean getBestBooleanProperty(String key, boolean def,
0889:                    List pflist) {
0890:                ProviderContext pc = getProviderContext();
0891:                try {
0892:                    if (key != null) {
0893:                        if (pc.existsBooleanProperty(this .getName(), key,
0894:                                pflist)) {
0895:                            return pc.getBooleanProperty(this .getName(), key,
0896:                                    pflist);
0897:                        } else if (pc
0898:                                .existsBooleanProperty(this .getName(), key)) {
0899:                            return pc.getBooleanProperty(this .getName(), key);
0900:                        }
0901:                    }
0902:                    return def;
0903:                } catch (ProviderContextException pce) {
0904:                    if (debugLogger.isLoggable(Level.FINE)) {
0905:                        LogRecord logRecord = new LogRecord(Level.FINE,
0906:                                "PSAC_CSPPA0021");
0907:                        logRecord.setLoggerName(debugLogger.getName());
0908:                        logRecord.setParameters(new Object[] { key });
0909:                        logRecord.setThrown(pce);
0910:                        debugLogger.log(logRecord);
0911:                    }
0912:                    return def;
0913:                }
0914:            }
0915:
0916:            public boolean getBestBooleanProperty(String key, List pflist) {
0917:                return getBestBooleanProperty(key, false, pflist);
0918:            }
0919:
0920:            protected Map getAppHandlerMap() {
0921:                Map appHelperClasses = null;
0922:                appHelperClasses = getBestCollectionProperty(
0923:                        "applicationHelperEdit", pflist);
0924:                return appHelperClasses;
0925:            }
0926:
0927:            /**
0928:             *  Gets the aBAppHelper attribute of the AddressBookProvider object
0929:             *
0930:             *@param  ssoAdapter  ssoAdapter for this channel
0931:             *@return             The aBAppHelper value
0932:             */
0933:            private AddressBookApplicationHelper getABAppHelper(
0934:                    SSOAdapter ssoAdapter, String applicationHelperName,
0935:                    boolean safe) {
0936:                AddressBookApplicationHelper abApplicationHelper = null;
0937:
0938:                if (ssoAdapter == null) {
0939:                    debugLogger.info("PSAC_CSPPA0011");
0940:                    return null;
0941:                }
0942:
0943:                if (applicationHelperName == null) {
0944:                    debugLogger.info("PSAC_CSPPA0022");
0945:                    return null;
0946:                }
0947:
0948:                //Verify that the applicationHelperName is a valid App Helper and not any old class
0949:                //This is done to prevent malicious users from instantiate any class they wish
0950:                boolean validClass = safe;
0951:                if (!safe) {
0952:                    Map validAppHelpers = getAppHandlerMap();
0953:                    if (validAppHelpers != null) {
0954:                        validClass = validAppHelpers
0955:                                .containsKey(applicationHelperName);
0956:                        debugLogger.log(Level.FINER, "PSAC_CSPPA0023", Boolean
0957:                                .toString(validClass));
0958:                    } else {
0959:                        validClass = false;
0960:                    }
0961:                }
0962:
0963:                // try to get the stored AppHandler
0964:                if (ProviderEditUtility.isAppHandlerSet(appHandlers,
0965:                        applicationHelperName)) {
0966:                    debugLogger.log(Level.FINER, "PSAC_CSPPA0024",
0967:                            applicationHelperName);
0968:                    abApplicationHelper = (AddressBookApplicationHelper) appHandlers
0969:                            .get(applicationHelperName);
0970:                    return abApplicationHelper;
0971:                } else if (validClass) {
0972:                    //Create the new AppHelper and store it
0973:
0974:                    try {
0975:                        Class applicationHelperClass = Class
0976:                                .forName(applicationHelperName);
0977:                        Class[] argConst = {};
0978:                        Constructor applicationHelperConst = applicationHelperClass
0979:                                .getConstructor(argConst);
0980:                        Object[] argConstObj = {};
0981:                        abApplicationHelper = (AddressBookApplicationHelper) applicationHelperConst
0982:                                .newInstance(argConstObj);
0983:
0984:                    } catch (ClassNotFoundException cnfe) {
0985:                        debugLogger.log(Level.INFO, "PSAC_CSPPA0003", cnfe);
0986:                    } catch (NoSuchMethodException nsme) {
0987:                        debugLogger.log(Level.INFO, "PSAC_CSPPA0003", nsme);
0988:                    } catch (InstantiationException ine) {
0989:                        debugLogger.log(Level.INFO, "PSAC_CSPPA0003", ine);
0990:                    } catch (IllegalAccessException iae) {
0991:                        debugLogger.log(Level.INFO, "PSAC_CSPPA0003", iae);
0992:                    } catch (InvocationTargetException ite) {
0993:                        debugLogger.log(Level.INFO, "PSAC_CSPPA0003", ite);
0994:                    }
0995:
0996:                    try {
0997:                        abApplicationHelper.init(this , ssoAdapter);
0998:                    } catch (Exception e) {
0999:                        if (debugLogger.isLoggable(Level.FINE)) {
1000:                            LogRecord logRecord = new LogRecord(Level.FINE,
1001:                                    "PSAC_CSPPA0025");
1002:                            logRecord.setLoggerName(debugLogger.getName());
1003:                            logRecord
1004:                                    .setParameters(new Object[] { applicationHelperName });
1005:                            logRecord.setThrown(e);
1006:                            debugLogger.log(logRecord);
1007:                        }
1008:                        return null;
1009:
1010:                    }
1011:
1012:                    // save application helper into the hashmap
1013:                    if (abApplicationHelper != null) {
1014:                        debugLogger.log(Level.FINER, "PSAC_CSPPA0026",
1015:                                applicationHelperName);
1016:                        appHandlers.put(applicationHelperName,
1017:                                abApplicationHelper);
1018:                        abApplicationHelper.setName(applicationHelperName);
1019:                        return abApplicationHelper;
1020:                    } else {
1021:                        return null;
1022:                    }
1023:                } else {
1024:                    return null;
1025:                }
1026:            }
1027:
1028:            /**
1029:             *  Retrieves the AddressBookApplicationHelper start URL
1030:             *
1031:             * @param abApplicationHelper  The AddressBookApplicationHelper object
1032:             * @param request              The HttpServletRequest object
1033:             * @return string representing the Application start URL
1034:             */
1035:            protected String getApplicationStartURL(
1036:                    AddressBookApplicationHelper abApplicationHelper,
1037:                    HttpServletRequest request) {
1038:                String applicationURLString = null;
1039:
1040:                if (abApplicationHelper != null) {
1041:                    applicationURLString = abApplicationHelper.getStartURL(
1042:                            this , request);
1043:
1044:                }
1045:
1046:                return applicationURLString;
1047:            }
1048:
1049:            /**
1050:             *  Return URL to main edit page with error message
1051:             *
1052:             *@param  request  Description of the Parameter
1053:             *@param  errMsg   Description of the Parameter
1054:             *@return          The editReturnURL value
1055:             */
1056:            private URL getEditReturnURL(HttpServletRequest request,
1057:                    String errMsg) {
1058:                StringBuffer urlBuffer = new StringBuffer(512);
1059:                errMsg = getProviderContext().encodeURLParameter(errMsg);
1060:                urlBuffer.append(getProviderContext().getDesktopURL(request));
1061:                urlBuffer.append("?action=edit");
1062:                urlBuffer.append("&provider=" + encode(editContainer));
1063:                urlBuffer.append("&targetprovider=" + getName());
1064:                urlBuffer.append("&containerName=" + encode(container));
1065:                urlBuffer.append("&error=" + errMsg);
1066:
1067:                String desktopURL = urlBuffer.toString();
1068:
1069:                URL url = null;
1070:                try {
1071:                    url = new URL(desktopURL);
1072:                } catch (MalformedURLException e) {
1073:                    debugLogger.log(Level.INFO, "PSAC_CSPPA0039", e);
1074:                }
1075:
1076:                return (url);
1077:            }
1078:
1079:            /**
1080:             * Does escaping of markup in a client aware fashion, example of markups
1081:             * include HTML, XML, WML, cHTML, .....
1082:             *
1083:             *@param  inContent  is the string input
1084:             *@return            String containing the escaped String
1085:             */
1086:            private String escape(String inContent) {
1087:
1088:                if (inContent == null) {
1089:                    return null;
1090:                }
1091:
1092:                try {
1093:                    return getProviderContext().escape(inContent);
1094:                } catch (ProviderContextException e) {
1095:                    debugLogger.log(Level.INFO, "PSAC_CSPPA0003", e);
1096:                    return inContent;
1097:                }
1098:            }
1099:
1100:            /**
1101:             *  Description of the Method
1102:             *
1103:             *@param  x  Description of the Parameter
1104:             */
1105:            /*
1106:            private void message(String x) {
1107:              if (providerContext.isDebugMessageEnabled()) {
1108:                providerContext.debugMessage("AddressBookProvider." + x);
1109:              }
1110:            }
1111:             */
1112:
1113:            /**
1114:             *  Description of the Method
1115:             *
1116:             *@param  x  Description of the Parameter
1117:             *@param  e  Description of the Parameter
1118:             */
1119:            /*
1120:            private void message(String x, Exception e) {
1121:              if (providerContext.isDebugMessageEnabled()) {
1122:                providerContext.debugMessage("AddressBookProvider." + x, e);
1123:              }
1124:            }
1125:             */
1126:
1127:            /**
1128:             *  Description of the Method
1129:             *
1130:             *@param  x  Description of the Parameter
1131:             */
1132:            /*
1133:            private void warning(String x) {
1134:              if (providerContext.isDebugWarningEnabled()) {
1135:                providerContext.debugWarning("AddressBookProvider." + x);
1136:              }
1137:            }
1138:             */
1139:
1140:            /**
1141:             *  Description of the Method
1142:             *
1143:             *@param  x  Description of the Parameter
1144:             *@param  e  Description of the Parameter
1145:             */
1146:            /*
1147:            private void warning(String x, Exception e) {
1148:              if (providerContext.isDebugWarningEnabled()) {
1149:                providerContext.debugWarning("AddressBookProvider." + x, e);
1150:              }
1151:            }
1152:             */
1153:
1154:            /**
1155:             *  Description of the Method
1156:             *
1157:             *@param  x  Description of the Parameter
1158:             */
1159:            /*
1160:            private void error(String x) {
1161:              if (providerContext.isDebugErrorEnabled()) {
1162:                providerContext.debugError("AddressBookProvider." + x);
1163:              }
1164:            }
1165:             */
1166:
1167:            /**
1168:             *  Description of the Method
1169:             *
1170:             *@param  x  Description of the Parameter
1171:             *@param  e  Description of the Parameter
1172:             */
1173:            /*
1174:            private void error(String x, Exception e) {
1175:              if (providerContext.isDebugErrorEnabled()) {
1176:                providerContext.debugError("AddressBookProvider." + x, e);
1177:              }
1178:            }
1179:             */
1180:
1181:            /**
1182:             * Wrapper class for encode.  Relies on class level charset attribute
1183:             *
1184:             * @param enc String to encode
1185:             * @return Encoded string contents if successful or unencoded string results if failed.
1186:             */
1187:
1188:            public String encode(String enc) {
1189:                String result = "";
1190:                try {
1191:                    result = URLEncoder.encode(enc, charset);
1192:                } catch (UnsupportedEncodingException uee) {
1193:                    debugLogger.log(Level.FINE, "PSAC_CSPPA0040", uee);
1194:                    return enc;
1195:                }
1196:                return result;
1197:            }
1198:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.