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


0001:        /**
0002:         *  $Id: MailProvider.java,v 1.98 2005/09/21 10:48:05 dg154973 Exp $ Copyright 2002
0003:         *  Sun Microsystems, Inc. All rights reserved. Use of this product is subject
0004:         *  to license terms. Federal Acquisitions: Commercial Software -- Government
0005:         *  Users Subject to Standard License Terms and Conditions. Sun, Sun
0006:         *  Microsystems, the Sun logo, and iPlanet are trademarks or registered
0007:         *  trademarks of Sun Microsystems, Inc. in the United States and other
0008:         *  countries.
0009:         */package com.sun.portal.providers.mail;
0010:
0011:        import com.sun.portal.providers.context.ProviderContext;
0012:        import com.sun.portal.providers.context.Theme;
0013:        import com.sun.portal.providers.context.ProviderContextException;
0014:        import com.sun.portal.providers.ProviderEditUtility;
0015:        import com.sun.portal.providers.Provider;
0016:        import com.sun.portal.providers.ProviderException;
0017:        import com.sun.portal.providers.ProviderAdapter;
0018:        import com.sun.portal.providers.ProfileProviderAdapter;
0019:        import com.sun.portal.providers.ProviderEditUtility;
0020:        import com.sun.portal.providers.util.ProviderProperties;
0021:        import com.sun.portal.desktop.encode.Encoder;
0022:        import com.sun.portal.desktop.encode.EncoderException;
0023:        import com.sun.portal.log.common.PortalLogger;
0024:
0025:        import com.sun.ssoadapter.SSOAdapter;
0026:        import com.sun.ssoadapter.SSOAdapterSession;
0027:        import com.sun.ssoadapter.SSOAdapterException;
0028:        import com.sun.ssoadapter.SSOAdapterFactory;
0029:
0030:        import java.io.*;
0031:        import java.lang.*;
0032:        import java.net.*;
0033:        import java.text.DateFormat;
0034:        import java.util.*;
0035:        import java.util.TimeZone;
0036:        import java.util.logging.Logger;
0037:        import java.util.logging.Level;
0038:        import java.util.logging.LogRecord;
0039:
0040:        import java.lang.reflect.Constructor;
0041:        import java.lang.reflect.InvocationTargetException;
0042:
0043:        import javax.mail.*;
0044:        import javax.mail.internet.*;
0045:        import javax.mail.search.*;
0046:        import javax.servlet.http.HttpUtils;
0047:        import javax.servlet.http.HttpServletRequest;
0048:        import javax.servlet.http.HttpServletResponse;
0049:
0050:        /**
0051:         *  MailProvider displays mail configured by a portal user on his HTML desktop.
0052:         *  Note: This class is based on MailProvider originally shipped with Juneau
0053:         *  (iPS:MAP 3.0) release. Changes has been made to make it work with Sun ONE
0054:         *  Portal Server 6.0 and SunONE identity Server (dsame).
0055:         *
0056:         *@author     Bill York
0057:         *@created    April 16, 2003
0058:         */
0059:
0060:        public class MailProvider extends ProfileProviderAdapter {
0061:            private boolean genericHTML = true;
0062:            private HttpServletRequest req = null;
0063:            private ResourceBundle bundle = null;
0064:            protected HashMap appHandlers = null;
0065:            private Store store = null;
0066:
0067:            protected SSOAdapterFactory adapterFactory = null;
0068:            protected String editContainer = "";
0069:            protected String targetProvider = "";
0070:            protected String containerName = "";
0071:            // flag to determine sso adapter configuration existence in init()
0072:            protected boolean isSSOConfigFound = true;
0073:            protected List pflist = null;
0074:
0075:            // flag to determine presentability in init()
0076:            protected Boolean isPresentable = null;
0077:
0078:            Hashtable mailValuePairs = new Hashtable();
0079:
0080:            private final static int PREDEFINED_REPLIES_LENGTH = 9;
0081:
0082:            // Create a logger for this class
0083:            private static Logger debugLogger = PortalLogger
0084:                    .getLogger(MailProvider.class);
0085:
0086:            // static comparator to sort messages by date
0087:            final static Comparator DATE_ORDER = new Comparator() {
0088:                public int compare(Object o1, Object o2) {
0089:                    try {
0090:                        Message m1 = (Message) o1;
0091:                        Message m2 = (Message) o2;
0092:                        Date d1 = m1.getReceivedDate();
0093:                        Date d2 = m2.getReceivedDate();
0094:                        return d1.compareTo(d2);
0095:                    } catch (MessagingException e) {
0096:                        return 0;
0097:                    }
0098:                }
0099:            };
0100:
0101:            final static SearchTerm nonDeletedSearch = new FlagTerm(new Flags(
0102:                    Flags.Flag.DELETED), false);
0103:            final static SearchTerm unReadSearch = new AndTerm(
0104:                    new SearchTerm[] {
0105:                            new FlagTerm(new Flags(Flags.Flag.SEEN), false),
0106:                            nonDeletedSearch });
0107:
0108:            /**
0109:             *  Check to see if <code>ssoAdapter</code> exists. If not then set <code>isSSOConfigFound</code>
0110:             *  to false disabling editability for the user's Session.
0111:             *
0112:             *@param  n                      ???
0113:             *@param  request                servlet request
0114:             *@exception  ProviderException
0115:             */
0116:            public void init(String n, HttpServletRequest request)
0117:                    throws ProviderException {
0118:                super .init(n, request);
0119:                try {
0120:                    pflist = getProviderContext()
0121:                            .getClientAndLocalePropertiesFilters();
0122:                } catch (ProviderContextException pce) {
0123:                    debugLogger.fine("PSMC_CSPPM0005");
0124:                }
0125:                this .req = request;
0126:
0127:                appHandlers = new HashMap();
0128:                bundle = getResourceBundle();
0129:                adapterFactory = SSOAdapterFactory.getInstance();
0130:
0131:                try {
0132:
0133:                    // check for ssoadapter configuration existence
0134:                    SSOAdapter ssoAdapter = (SSOAdapter) adapterFactory
0135:                            .getSSOAdapter(getBestStringProperty("ssoAdapter",
0136:                                    pflist),
0137:                                    new SSOAdapterSession(request,
0138:                                            getProviderContext().getLocale(),
0139:                                            getProviderContext().getUserID(),
0140:                                            getName()));
0141:                } catch (SSOAdapterException ssoe) {
0142:                    isSSOConfigFound = false;
0143:                    debugLogger.log(Level.FINE, "PSMC_CSPPM0006", new Object[] {
0144:                            getName(), ssoe.getMessage() });
0145:                }
0146:
0147:                // pre-calculate presentability
0148:                // in the non-authless case in order to
0149:                // prevent re-calc'ing it each request
0150:                //
0151:                if (!getProviderContext().isAuthless(request)) {
0152:                    if (isPresentable(request)) {
0153:                        isPresentable = Boolean.TRUE;
0154:                    } else {
0155:                        isPresentable = Boolean.FALSE;
0156:                    }
0157:                }
0158:            }
0159:
0160:            /**
0161:             *  Overide super.getContent() PAPI method.  Display the contents on the main desktop
0162:             *
0163:             *@param  request                servlet request
0164:             *@param  response               servlet response
0165:             *@return                        The content value
0166:             *@exception  ProviderException
0167:             */
0168:            public StringBuffer getContent(HttpServletRequest request,
0169:                    HttpServletResponse response) throws ProviderException {
0170:
0171:                StringBuffer content = new StringBuffer();
0172:                Hashtable contentTags = new Hashtable();
0173:
0174:                // iwtDesktop-fontFace1
0175:                contentTags.put("iwtDesktop-fontFace1", getBestStringProperty(
0176:                        "fontFace1", "Sans-serif", pflist));
0177:
0178:                // get sso adapter
0179:                // open mailbox
0180:                SSOAdapter ssoAdapter = null;
0181:                //Store store = null;
0182:
0183:                try {
0184:                    ssoAdapter = (SSOAdapter) adapterFactory.getSSOAdapter(
0185:                            getBestStringProperty("ssoAdapter", pflist),
0186:                            new SSOAdapterSession(request, getProviderContext()
0187:                                    .getLocale(), getProviderContext()
0188:                                    .getUserID(), getName()));
0189:
0190:                    store = (javax.mail.Store) ssoAdapter.getConnection();
0191:                    ProviderEditUtility.setDefaultPresentation(getName(),
0192:                            getProviderContext(), contentTags);
0193:                } catch (SSOAdapterException ssoe) {
0194:                    debugLogger.log(Level.FINER, "PSMC_CSPPM0007", ssoe);
0195:                    String errMsg = bundle.getString("MailProvider-ssoerror");
0196:                    StringBuffer summary = getErrorContent(errMsg);
0197:                    contentTags.put("mail-display-summary", summary);
0198:                    return (getTemplate("display.template", contentTags));
0199:                } catch (Exception e) {
0200:                    debugLogger.finer("PSMC_CSPPM0008");
0201:                    String errMsg = bundle.getString("MailProvider-loginerr");
0202:                    StringBuffer summary = getErrorContent(errMsg);
0203:                    contentTags.put("mail-display-summary", summary);
0204:                    return (getTemplate("display.template", contentTags));
0205:                }
0206:
0207:                if ((ssoAdapter != null) && (store != null)) {
0208:                    Folder inbox = null;
0209:                    Message[] nonDeletedMessages = null;
0210:                    Message[] unReadMessages = null;
0211:
0212:                    try {
0213:                        inbox = store.getFolder("INBOX");
0214:                        inbox.open(Folder.READ_ONLY);
0215:                        nonDeletedMessages = inbox.search(nonDeletedSearch);
0216:                        unReadMessages = inbox.search(unReadSearch,
0217:                                nonDeletedMessages);
0218:                    } catch (Exception e) {
0219:                        debugLogger.finer("PSMC_CSPPM0008");
0220:                        String errMsg = bundle
0221:                                .getString("MailProvider-loginerr");
0222:                        StringBuffer summary = getErrorContent(errMsg);
0223:                        contentTags.put("mail-display-summary", summary);
0224:                        return (getTemplate("display.template", contentTags));
0225:                    }
0226:
0227:                    String applicationURL = "";
0228:                    MailApplicationHelper appHelper = null;
0229:                    String appHelperClass = "";
0230:                    appHelperClass = getBestStringProperty(
0231:                            "applicationHelperURL", pflist);
0232:
0233:                    if (appHelperClass != null) {
0234:                        appHelper = getMailAppHelper(ssoAdapter,
0235:                                appHelperClass, true);
0236:                        if (appHelper != null) {
0237:                            applicationURL = getApplicationStartURL(appHelper,
0238:                                    request);
0239:                        } else {
0240:                            applicationURL = null;
0241:                        }
0242:                        if (applicationURL != null) {
0243:                            contentTags.put("mail-display-clientURL",
0244:                                    getClientURLContent(applicationURL));
0245:                        } else {
0246:                            contentTags.put("mail-display-clientURL", "");
0247:                            debugLogger.fine("PSMC_CSPPM0009");
0248:                        }
0249:                    } else {
0250:                        contentTags.put("mail-display-clientURL", "");
0251:                    }
0252:
0253:                    // mail-display-summary      // mail-display-headers
0254:                    //
0255:                    if ((inbox != null) && (nonDeletedMessages != null)) {
0256:                        contentTags.put("mail-display-summary",
0257:                                getSummaryContent(nonDeletedMessages,
0258:                                        unReadMessages));
0259:
0260:                        boolean displayHeaders = getBestBooleanProperty(
0261:                                "displayHeaders", true, pflist);
0262:                        StringBuffer headers = new StringBuffer();
0263:
0264:                        if (displayHeaders) {
0265:                            try {
0266:                                headers = getHeadersContent(appHelper, request,
0267:                                        inbox, nonDeletedMessages,
0268:                                        unReadMessages);
0269:                            } catch (MessagingException e) {
0270:                                String msg = bundle
0271:                                        .getString("MailProvider-hdrerr");
0272:                                debugLogger.log(Level.FINER, "PSMC_CSPPM0010",
0273:                                        e);
0274:                                headers = getErrorContent(msg);
0275:                            }
0276:                        }
0277:                        contentTags.put("mail-display-headers", headers);
0278:                    }
0279:                    content
0280:                            .append(getTemplate("display.template", contentTags));
0281:
0282:                    // connection management.  check ssoadapter for per request connection
0283:                    // management property.  if true, then close connection to store.
0284:                    //
0285:                    Properties props = ssoAdapter.getProperties();
0286:
0287:                    if (props != null) {
0288:                        String eprc = props.getProperty(
0289:                                "enablePerRequestConnection", "true");
0290:
0291:                        if ((eprc != null) && (eprc.equals("true"))) {
0292:                            ssoAdapter.closeConnection();
0293:                        }
0294:                    }
0295:                } else {
0296:
0297:                    // user level sso adapter exists, but store is null
0298:                    //
0299:                    if ((ssoAdapter != null)
0300:                            && (ssoAdapter.getName().endsWith("_" + getName()))) {
0301:                        return getErrorContent(bundle
0302:                                .getString("MailProvider-loginerr"));
0303:                        // user level sso adapter does not exist
0304:                        //
0305:                    } else {
0306:                        return getErrorContent(bundle
0307:                                .getString("MailProvider-noConfig"));
0308:                    }
0309:
0310:                }
0311:
0312:                return (content);
0313:            }
0314:
0315:            /**
0316:             *
0317:             *  This method now acts like a proxy and calls the appropriate application helper so that it will generate the
0318:             *  getEdit page content.  It also displays the ssoAdapter merge properties that the end user needs to enter
0319:             *
0320:             *@param  request                servlet request
0321:             *@param  response               servlet response
0322:             *@return                        The edit value
0323:             *@exception  ProviderException
0324:             */
0325:            public StringBuffer getEdit(HttpServletRequest request,
0326:                    HttpServletResponse response) throws ProviderException {
0327:
0328:                StringBuffer content = new StringBuffer();
0329:                SSOAdapter ssoAdapter = null;
0330:                Hashtable tagTable = new Hashtable();
0331:
0332:                editContainer = request.getParameter("provider");
0333:                targetProvider = request.getParameter("targetprovider");
0334:                containerName = request.getParameter("containerName");
0335:                debugLogger.log(Level.FINER, "PSMC_CSPPM0011", new Object[] {
0336:                        editContainer, targetProvider, containerName });
0337:
0338:                try {
0339:                    ssoAdapter = (SSOAdapter) adapterFactory.getSSOAdapter(
0340:                            getBestStringProperty("ssoAdapter", pflist),
0341:                            new SSOAdapterSession(request, getProviderContext()
0342:                                    .getLocale(), getProviderContext()
0343:                                    .getUserID(), getName()));
0344:                    ProviderEditUtility.setDefaultPresentation(getName(),
0345:                            getProviderContext(), tagTable);
0346:                } catch (Exception e) {
0347:                    debugLogger.log(Level.FINER, "PSMC_CSPPM0012", e);
0348:                }
0349:
0350:                String appPref = ProviderEditUtility.getRequestParameter(
0351:                        "appPref", request);
0352:                if (!appPref.equals("")) {
0353:                    MailApplicationHelper mah = getMailAppHelper(ssoAdapter,
0354:                            appPref, false);
0355:                    content = mah.getAppPrefsEdit(this , request, response);
0356:                } else {
0357:
0358:                    String fontTag = getBestStringProperty("fontFace1",
0359:                            "Sans-serif", pflist);
0360:                    tagTable.put("iwtDesktop-fontFace1", fontTag);
0361:                    // Get the starting template
0362:                    content
0363:                            .append(getTemplate("edit-start.template", tagTable));
0364:
0365:                    // Get the SSOAdapter attributes
0366:                    ProviderEditUtility.editContainer = editContainer;
0367:                    ProviderEditUtility.container = containerName;
0368:                    try {
0369:                        content.append(ProviderEditUtility.getSSOAdapterPrefs(
0370:                                (ProviderAdapter) this , ssoAdapter));
0371:                    } catch (Exception e) {
0372:                        debugLogger.log(Level.FINE, "PSMC_CSPPM0013", e);
0373:                    }
0374:
0375:                    // Get ending template
0376:                    content.append(getTemplate("edit-end.template", tagTable));
0377:
0378:                    MailApplicationHelper mah = null;
0379:                    Map appHelperClasses = getAppHandlerMap();
0380:                    if (appHelperClasses == null) {
0381:                        debugLogger.info("PSMC_CSPPM0014");
0382:                    } else {
0383:                        Iterator iter = appHelperClasses.entrySet().iterator();
0384:                        while (iter.hasNext()) {
0385:                            Map.Entry appClass = (Map.Entry) iter.next();
0386:                            String appHelperClass = (String) appClass
0387:                                    .getValue();
0388:                            mah = getMailAppHelper(ssoAdapter, appHelperClass,
0389:                                    true);
0390:                            String link = "";
0391:                            if (mah == null) {
0392:                                debugLogger.fine("PSMC_CSPPM0015");
0393:                            } else {
0394:                                link = mah.getAppHelperEditLink(request,
0395:                                        getProviderContext());
0396:                            }
0397:                            if ((link != null) || (!link.equals(""))) {
0398:                                content.append(link);
0399:                            } else {
0400:                                debugLogger.fine("PSMC_CSPPM0016");
0401:                            }
0402:                        }
0403:                    }
0404:                }
0405:
0406:                return content;
0407:            }
0408:
0409:            /**
0410:             *  This method saves off the ssoAdapter and display profile attributes.  It relies on the ProviderEditUtility
0411:             *  to save off the ssoAdapter attributes and app helper to save off the DP attributes
0412:             *
0413:             *@param  req                    servlet request
0414:             *@param  res                    servlet response
0415:             *@return                        returns an URL for the Servldet to redirect to
0416:             *@exception  ProviderException
0417:             */
0418:            public URL processEdit(HttpServletRequest req,
0419:                    HttpServletResponse res) throws ProviderException {
0420:                SSOAdapter ssoAdapter = null;
0421:                URL returnURL = null;
0422:
0423:                try {
0424:                    ssoAdapter = (SSOAdapter) adapterFactory.getSSOAdapter(
0425:                            getBestStringProperty("ssoAdapter", pflist),
0426:                            new SSOAdapterSession(req, getProviderContext()
0427:                                    .getLocale(), getProviderContext()
0428:                                    .getUserID(), getName()));
0429:                } catch (SSOAdapterException ssoe) {
0430:                    debugLogger.log(Level.FINER, "PSMC_CSPPM0012", ssoe);
0431:                }
0432:
0433:                String appPref = ProviderEditUtility.getRequestParameter(
0434:                        "appPref", req);
0435:                debugLogger
0436:                        .log(Level.FINER, "PSMC_CSPPM0017", new Object[] {
0437:                                editContainer, targetProvider, containerName,
0438:                                appPref });
0439:
0440:                MailApplicationHelper mah = null;
0441:                if (!appPref.equals("")) {
0442:                    mah = getMailAppHelper(ssoAdapter, appPref, false);
0443:                    if (mah == null) {
0444:                        debugLogger.info("PSMC_CSPPM0018");
0445:                        returnURL = null;
0446:                    } else {
0447:                        returnURL = mah.processAppPrefsEdit(this , req, res);
0448:                        debugLogger.log(Level.FINER, "PSMC_CSPPM0019",
0449:                                returnURL);
0450:                    }
0451:                } else {
0452:
0453:                    //Set the SSOAdapter attributes
0454:                    SSOAdapter newAdapter = null;
0455:                    try {
0456:                        newAdapter = ProviderEditUtility.setSSOAdapterPrefs(
0457:                                (ProviderAdapter) this , ssoAdapter,
0458:                                adapterFactory, req);
0459:                        returnURL = ProviderEditUtility.getErrorURL();
0460:                        if (returnURL == null) {
0461:                            if (newAdapter != null) {
0462:                                debugLogger.finer("PSMC_CSPPM0020");
0463:                                appPref = getBestStringProperty(
0464:                                        "applicationHelperURL", pflist);
0465:                                mah = getMailAppHelper(ssoAdapter, appPref,
0466:                                        false);
0467:                                mah.init(this , newAdapter);
0468:                            }
0469:                        }
0470:                    } catch (Exception e) {
0471:                        debugLogger.log(Level.INFO, "PSMC_CSPPM0021", e);
0472:                        returnURL = ProviderEditUtility.getErrorURL();
0473:                        if (returnURL != null) {
0474:                            debugLogger.log(Level.FINE, "PSMC_CSPPM0019",
0475:                                    returnURL);
0476:                        }
0477:                    }
0478:
0479:                }
0480:                return returnURL;
0481:            }
0482:
0483:            /**
0484:             *  Gets the appHandlerMap attribute of the MailProvider object
0485:             *
0486:             *@return    The application helper map
0487:             */
0488:            protected Map getAppHandlerMap() {
0489:                Map appHelperClasses = null;
0490:                appHelperClasses = getBestCollectionProperty(
0491:                        "applicationHelperEdit", pflist);
0492:                return appHelperClasses;
0493:            }
0494:
0495:            /**
0496:             *  Gets the application helper that is needed
0497:             *
0498:             *@param  ssoAdapter             ssoAdapter for this channel
0499:             *@param  applicationHelperName  application helper name
0500:             *@param  safe                   if true doesn't check the app helper being asked to be retrieved against a list
0501:             *                               of other app helpers
0502:             *@return                        app helper object
0503:             */
0504:            private MailApplicationHelper getMailAppHelper(
0505:                    SSOAdapter ssoAdapter, String applicationHelperName,
0506:                    boolean safe) {
0507:                MailApplicationHelper abApplicationHelper = null;
0508:
0509:                if (ssoAdapter == null) {
0510:                    debugLogger.info("PSMC_CSPPM0022");
0511:                    return null;
0512:                } else {
0513:                    debugLogger.finer("PSMC_CSPPM0023");
0514:                }
0515:
0516:                if (applicationHelperName == null) {
0517:                    debugLogger.info("PSMC_CSPPM0024");
0518:                    return null;
0519:                }
0520:                debugLogger.log(Level.FINER, "PSMC_CSPPM0025",
0521:                        applicationHelperName);
0522:
0523:                //Verify that the applicationHelperName is a valid App Helper and not any old class
0524:                //This is done to prevent malicious users from instantiate any class they wish
0525:                boolean validClass = safe;
0526:                debugLogger.log(Level.FINER, "PSMC_CSPPM0026", Boolean
0527:                        .toString(validClass));
0528:                if (!safe) {
0529:                    Map validAppHelpers = getAppHandlerMap();
0530:                    if (validAppHelpers != null) {
0531:                        validClass = validAppHelpers
0532:                                .containsKey(applicationHelperName);
0533:                    } else {
0534:                        validClass = false;
0535:                    }
0536:                }
0537:                // try to get the stored AppHandler
0538:                if (debugLogger.isLoggable(Level.FINER)) {
0539:                    Set keys = appHandlers.keySet();
0540:                    Iterator iter = keys.iterator();
0541:                    StringBuffer validHelperKeys = new StringBuffer();
0542:                    while (iter.hasNext()) {
0543:                        validHelperKeys.append(iter.next());
0544:                        validHelperKeys.append(" ");
0545:                    }
0546:                    debugLogger.log(Level.FINER, "PSMC_CSPPM0027",
0547:                            validHelperKeys);
0548:                }
0549:                boolean appHandlerCached = ProviderEditUtility.isAppHandlerSet(
0550:                        appHandlers, applicationHelperName);
0551:                debugLogger.log(Level.FINER, "PSMC_CSPPM0028", Boolean
0552:                        .toString(appHandlerCached));
0553:
0554:                if (appHandlerCached) {
0555:                    debugLogger.log(Level.FINER, "PSMC_CSPPM0029",
0556:                            applicationHelperName);
0557:                    abApplicationHelper = (MailApplicationHelper) appHandlers
0558:                            .get(applicationHelperName);
0559:                    return abApplicationHelper;
0560:                } else if (validClass) {
0561:                    //Create the new AppHelper and store it
0562:                    debugLogger.log(Level.FINE, "PSMC_CSPPM0030",
0563:                            applicationHelperName);
0564:
0565:                    try {
0566:                        Class applicationHelperClass = Class
0567:                                .forName(applicationHelperName);
0568:                        Class[] argConst = {};
0569:                        Constructor applicationHelperConst = applicationHelperClass
0570:                                .getConstructor(argConst);
0571:                        Object[] argConstObj = {};
0572:                        abApplicationHelper = (MailApplicationHelper) applicationHelperConst
0573:                                .newInstance(argConstObj);
0574:                    } catch (ClassNotFoundException cnfe) {
0575:                        debugLogger.log(Level.INFO, "PSMC_CSPPM0031", cnfe);
0576:                    } catch (NoSuchMethodException nsme) {
0577:                        debugLogger.log(Level.INFO, "PSMC_CSPPM0031", nsme);
0578:                    } catch (InstantiationException ine) {
0579:                        debugLogger.log(Level.INFO, "PSMC_CSPPM0031", ine);
0580:                    } catch (IllegalAccessException iae) {
0581:                        debugLogger.log(Level.INFO, "PSMC_CSPPM0031", iae);
0582:                    } catch (InvocationTargetException ite) {
0583:                        debugLogger.log(Level.INFO, "PSMC_CSPPM0031", ite);
0584:                    }
0585:
0586:                    try {
0587:                        abApplicationHelper.init(this , ssoAdapter);
0588:                    } catch (Exception e) {
0589:                        if (debugLogger.isLoggable(Level.FINE)) {
0590:                            LogRecord logRecord = new LogRecord(Level.FINE,
0591:                                    "PSMC_CSPPM0032");
0592:                            logRecord
0593:                                    .setParameters(new Object[] { applicationHelperName });
0594:                            logRecord.setThrown(e);
0595:                            logRecord.setLoggerName(debugLogger.getName());
0596:                            debugLogger.log(logRecord);
0597:                        }
0598:                        return null;
0599:                    }
0600:
0601:                    // save application helper into the hashmap
0602:                    if (abApplicationHelper != null) {
0603:                        debugLogger.log(Level.FINER, "PSMC_CSPPM0033",
0604:                                applicationHelperName);
0605:                        appHandlers.put(applicationHelperName,
0606:                                abApplicationHelper);
0607:                        abApplicationHelper.setName(applicationHelperName);
0608:                        /*
0609:                        appHandlerCached = ProviderEditUtility.isAppHandlerSet(appHandlers, applicationHelperName);
0610:                        if (getProviderContext().isDebugMessageEnabled()){
0611:                          Set keys = appHandlers.keySet();
0612:                          Iterator iter = keys.iterator();
0613:                          while (iter.hasNext()){
0614:                          }
0615:                        }
0616:                         */
0617:                        return abApplicationHelper;
0618:                    } else {
0619:                        return null;
0620:                    }
0621:                } else {
0622:                    return null;
0623:                }
0624:            }
0625:
0626:            /**
0627:             *  Retrieves the MailApplicationHelper start URL
0628:             *
0629:             *@param  mailApplicationHelper  The MailApplicationHelper object
0630:             *@param  request                The HttpServletRequest object
0631:             *@return                        string representing the Application start URL
0632:             */
0633:            protected String getApplicationStartURL(
0634:                    MailApplicationHelper mailApplicationHelper,
0635:                    HttpServletRequest request) {
0636:                String applicationURLString = null;
0637:
0638:                if (mailApplicationHelper != null) {
0639:                    applicationURLString = mailApplicationHelper.getStartURL(
0640:                            this , request);
0641:                }
0642:
0643:                return applicationURLString;
0644:            }
0645:
0646:            /**
0647:             *  Gets the headersContent attribute of the MailProvider object
0648:             *
0649:             *@param  appHelper               application helper object
0650:             *@param  request                 servlet request
0651:             *@param  inbox                   current mail folder
0652:             *@param  nonDeletedMessages      array of non deleted messages
0653:             *@param  unReadMessages          array of non read messages
0654:             *@return                         The messages content
0655:             *@exception  ProviderException
0656:             *@exception  MessagingException
0657:             */
0658:            private StringBuffer getHeadersContent(
0659:                    MailApplicationHelper appHelper,
0660:                    HttpServletRequest request, Folder inbox,
0661:                    Message[] nonDeletedMessages, Message[] unReadMessages)
0662:                    throws ProviderException, MessagingException {
0663:                Hashtable tags = new Hashtable();
0664:                StringBuffer content = null;
0665:                String sso_uri = null;
0666:
0667:                try {
0668:                    ProviderEditUtility.setDefaultPresentation(getName(),
0669:                            getProviderContext(), tags);
0670:                } catch (ProviderContextException pce) {
0671:                    debugLogger.log(Level.INFO, "PSMC_CSPPM0031", pce);
0672:                }
0673:                // set up date formatting
0674:                Locale userLocale = getProviderContext().getLocale();
0675:                String userTZ = getStringAttribute("preferredtimezone");
0676:                DateFormat dateFormat = DateFormat.getDateTimeInstance(
0677:                        DateFormat.SHORT, DateFormat.SHORT, userLocale);
0678:
0679:                if (userTZ == null || userTZ.length() == 0) {
0680:                    userTZ = TimeZone.getDefault().getID();
0681:                }
0682:
0683:                TimeZone userTimeZone = TimeZone.getTimeZone(userTZ);
0684:
0685:                dateFormat.setTimeZone(userTimeZone);
0686:
0687:                tags.put("mail-display-headers-subject", bundle
0688:                        .getString("MailProvider-subj"));
0689:                tags.put("mail-display-headers-from", bundle
0690:                        .getString("MailProvider-from"));
0691:                tags.put("mail-display-headers-date", bundle
0692:                        .getString("MailProvider-date"));
0693:                tags.put("mail-display-headers-status", bundle
0694:                        .getString("MailProvider-stat"));
0695:                tags.put("iwtDesktop-fontFace1", getBestStringProperty(
0696:                        "fontFace1", "Sans-serif", pflist));
0697:
0698:                int max = getBestIntegerProperty("numberHeaders", 0, pflist);
0699:                int adminMaxNumberHeaders = getBestIntegerProperty(
0700:                        "maxNumberHeaders", 30, pflist);
0701:                debugLogger.log(Level.FINER, "PSMC_CSPPM0034", Integer
0702:                        .toString(adminMaxNumberHeaders));
0703:
0704:                // hard limit
0705:                if (max > adminMaxNumberHeaders) {
0706:                    max = adminMaxNumberHeaders;
0707:                }
0708:
0709:                // do table only if there's messages
0710:                if ((nonDeletedMessages.length == 0) || (max == 0)) {
0711:                    return (new StringBuffer());
0712:                }
0713:
0714:                // retrieve most recent non-deleted message subset
0715:                //
0716:                List messageSubSetList = new LinkedList();
0717:                int startIndex = 0;
0718:                int endIndex = nonDeletedMessages.length;
0719:
0720:                if (endIndex > max) {
0721:                    startIndex = endIndex - max;
0722:                }
0723:
0724:                for (int i = startIndex; i < endIndex; i++) {
0725:                    messageSubSetList.add(nonDeletedMessages[i]);
0726:                }
0727:
0728:                Collections.sort(messageSubSetList, MailProvider.DATE_ORDER);
0729:                Object sortedMsgs[] = messageSubSetList.toArray();
0730:
0731:                if (sortedMsgs.length == 0) {
0732:                    String errmsg = bundle.getString("MailProvider-nomsgerr");
0733:                    return getErrorContent(errmsg);
0734:                }
0735:
0736:                debugLogger.log(Level.FINER, "PSMC_CSPPM0035", Integer
0737:                        .toString(sortedMsgs.length));
0738:
0739:                Date date = null;
0740:                int displayed = max;
0741:                // # messages displayed
0742:                int count = 0;
0743:                // count in message array
0744:                // most recent at top or bottom
0745:                boolean top = getBestStringProperty("sortOrder", "top", pflist)
0746:                        .equalsIgnoreCase("top");
0747:                // sort table top-down or bottom-up
0748:                if (top) {
0749:                    count = sortedMsgs.length - 1;
0750:                } else {
0751:                    if (max > sortedMsgs.length) {
0752:                        count = 0;
0753:                    } else {
0754:                        count = sortedMsgs.length - max;
0755:                    }
0756:                }
0757:
0758:                String read = bundle.getString("MailProvider-read");
0759:                String unread = bundle.getString("MailProvider-unread");
0760:                String cbgc = bundle.getString("MailProvider-cbgc");
0761:                StringBuffer messageList = new StringBuffer();
0762:
0763:                while (displayed > 0) {
0764:                    Message msg = (Message) sortedMsgs[count];
0765:                    if (msg == null) {
0766:
0767:                        continue;
0768:                    }
0769:
0770:                    Hashtable msgTags = new Hashtable();
0771:                    try {
0772:                        ProviderEditUtility.setDefaultPresentation(getName(),
0773:                                getProviderContext(), msgTags);
0774:                    } catch (ProviderContextException pce) {
0775:                        debugLogger.log(Level.INFO, "PSMC_CSPPM0031", pce);
0776:                    }
0777:
0778:                    msgTags.put("mail-display-headers-message-cbgc", cbgc);
0779:                    msgTags.put("iwtDesktop-fontFace1", getBestStringProperty(
0780:                            "fontFace1", "Sans-serif", pflist));
0781:
0782:                    // construct subject.  if application helper getMessageURL returns a
0783:                    // non-null value then return a link for tag
0784:                    // "mail-display-headers-message-clientURL" otherwise return plain text
0785:                    //
0786:                    String subject = decodeWords(msg.getSubject());
0787:
0788:                    if (subject != null && subject.length() != 0) {
0789:                        subject = mungeAddress(subject);
0790:                    } else {
0791:                        subject = bundle.getString("MailProvider-nosubject");
0792:                    }
0793:
0794:                    try {
0795:                        sso_uri = appHelper.getMessageURL(this , request, msg);
0796:                    } catch (Exception e) {
0797:                        sso_uri = null;
0798:                    }
0799:
0800:                    if (sso_uri != null && sso_uri.length() != 0) {
0801:                        Hashtable linkTags = new Hashtable();
0802:                        try {
0803:                            ProviderEditUtility.setDefaultPresentation(
0804:                                    getName(), getProviderContext(), linkTags);
0805:                        } catch (ProviderContextException pce) {
0806:                            debugLogger.log(Level.INFO, "PSMC_CSPPM0031", pce);
0807:                        }
0808:                        linkTags.put("link", sso_uri);
0809:                        linkTags.put("name", subject);
0810:
0811:                        try {
0812:                            subject = getTemplate("url.template", linkTags)
0813:                                    .toString();
0814:                        } catch (ProviderException pe) {
0815:                            debugLogger.log(Level.FINER, "PSMC_CSPPM0036", pe);
0816:                        }
0817:
0818:                    } else {
0819:                        sso_uri = "";
0820:                    }
0821:
0822:                    msgTags.put("mail-display-headers-message-clientURL",
0823:                            sso_uri);
0824:                    msgTags
0825:                            .put("mail-display-headers-message-subject",
0826:                                    subject);
0827:
0828:                    // address/mailto section
0829:                    Address[] addrArray = msg.getFrom();
0830:                    String address;
0831:                    if (addrArray != null && addrArray.length > 0) {
0832:                        address = addrArray[0].toString();
0833:                    } else {
0834:                        address = "";
0835:                    }
0836:                    String name = address;
0837:                    // default if name doesn't exist
0838:
0839:                    try {
0840:                        if (address != null && address.length() != 0) {
0841:                            InternetAddress ia = new InternetAddress(address);
0842:
0843:                            address = ia.getAddress();
0844:                            name = ia.getPersonal();
0845:
0846:                            if (name == null || name.length() == 0) {
0847:                                if (address != null && address.length() != 0) {
0848:                                    name = mungeAddress(address);
0849:                                }
0850:                            }
0851:                        }
0852:                    } catch (AddressException e) {
0853:                        // ignore and use the "From" for displaying
0854:                    }
0855:
0856:                    msgTags.put("mail-display-headers-message-mailto", address);
0857:                    msgTags.put("mail-display-headers-message-name", name);
0858:
0859:                    // date
0860:                    date = msg.getReceivedDate();
0861:                    if (date == null) {
0862:                        msgTags.put("mail-display-headers-message-date", "-");
0863:                    } else {
0864:                        msgTags.put("mail-display-headers-message-date",
0865:                                dateFormat.format(date));
0866:                    }
0867:                    // status
0868:                    String mstat = unread;
0869:                    if (msg.getFlags().contains(Flags.Flag.SEEN)) {
0870:                        mstat = read;
0871:                    }
0872:                    msgTags.put("mail-display-headers-message-status", mstat);
0873:                    StringBuffer msgContent = getTemplate(
0874:                            "display-headers-message.template", msgTags);
0875:                    messageList.append(msgContent);
0876:
0877:                    // set message counter in array
0878:                    if (top) {
0879:                        count--;
0880:                    } else {
0881:                        count++;
0882:                    }
0883:                    if (count < 0 || count >= sortedMsgs.length) {
0884:                        break;
0885:                    }
0886:
0887:                    // set number of messages displayed
0888:                    displayed--;
0889:                }
0890:                tags.put("mail-display-headers-messageList", messageList);
0891:                content = getTemplate("display-headers.template", tags);
0892:                return (content);
0893:            }
0894:
0895:            /**
0896:             *  Description of the Method
0897:             *
0898:             *@param  addr  Description of the Parameter
0899:             *@return       Description of the Return Value
0900:             */
0901:            private String mungeAddress(String addr) {
0902:
0903:                if (addr == null) {
0904:                    return null;
0905:                }
0906:
0907:                try {
0908:                    return getProviderContext().escape(addr);
0909:                } catch (ProviderContextException e) {
0910:                    if (debugLogger.isLoggable(Level.INFO)) {
0911:                        LogRecord logRecord = new LogRecord(Level.INFO,
0912:                                "PSMC_CSPPM0037");
0913:                        logRecord.setParameters(new Object[] { getName() });
0914:                        logRecord.setThrown(e);
0915:                        logRecord.setLoggerName(debugLogger.getName());
0916:                        debugLogger.log(logRecord);
0917:                    }
0918:                    return addr;
0919:                }
0920:            }
0921:
0922:            /**
0923:             *  Gets the clientURLContent attribute of the MailProvider object
0924:             *
0925:             *@param  sso_uri                the application launch link
0926:             *@return                        The clientURLContent value
0927:             *@exception  ProviderException
0928:             */
0929:            private StringBuffer getClientURLContent(String sso_uri)
0930:                    throws ProviderException {
0931:                Hashtable clientURLTags = new Hashtable();
0932:                if (sso_uri != null && sso_uri.length() != 0) {
0933:                    clientURLTags.put("mail-display-clientURL-uri", sso_uri);
0934:                } else {
0935:                    clientURLTags.put("mail-display-clientURL-uri", "");
0936:                }
0937:                StringBuffer clientURL = new StringBuffer();
0938:                try {
0939:                    ProviderEditUtility.setDefaultPresentation(getName(),
0940:                            getProviderContext(), clientURLTags);
0941:                    clientURL = getTemplate("display-clientURL.template",
0942:                            clientURLTags);
0943:                } catch (ProviderContextException pce) {
0944:                    debugLogger.log(Level.INFO, "PSMC_CSPPM0031", pce);
0945:                }
0946:
0947:                return (clientURL);
0948:            }
0949:
0950:            /**
0951:             *  Gets the errorContent attribute of the MailProvider object
0952:             *
0953:             *@param  msg                    error message to display
0954:             *@return                        The errorContent value
0955:             *@exception  ProviderException
0956:             */
0957:            private StringBuffer getErrorContent(String msg)
0958:                    throws ProviderException {
0959:                Hashtable errorTags = new Hashtable();
0960:                errorTags.put("mail-display-error", msg);
0961:                try {
0962:                    ProviderEditUtility.setDefaultPresentation(getName(),
0963:                            getProviderContext(), errorTags);
0964:                } catch (ProviderContextException pce) {
0965:                    debugLogger.log(Level.INFO, "PSMC_CSPPM0031", pce);
0966:                }
0967:                StringBuffer error = getTemplate("display-error.template",
0968:                        errorTags);
0969:
0970:                return (error);
0971:            }
0972:
0973:            /**
0974:             *  Displays the summary of unread and total messages
0975:             *
0976:             *@param  nonDeletedMessages     non deleted message array
0977:             *@param  unReadMessages         unread message array
0978:             *@return                        The summaryContent value
0979:             *@exception  ProviderException
0980:             */
0981:            private StringBuffer getSummaryContent(
0982:                    Message[] nonDeletedMessages, Message[] unReadMessages)
0983:                    throws ProviderException {
0984:
0985:                int unread = unReadMessages.length;
0986:                int total = nonDeletedMessages.length;
0987:                StringBuffer summary = null;
0988:                Hashtable summaryTags = new Hashtable();
0989:
0990:                summaryTags.put("mail-display-summary-unread", Integer
0991:                        .toString(unread));
0992:                summaryTags.put("mail-display-summary-total", Integer
0993:                        .toString(total));
0994:                summaryTags.put("iwtDesktop-fontFace1", getBestStringProperty(
0995:                        "fontFace1", "Sans-serif", pflist));
0996:                try {
0997:                    ProviderEditUtility.setDefaultPresentation(getName(),
0998:                            getProviderContext(), summaryTags);
0999:                    summary = getTemplate("display-summary.template",
1000:                            summaryTags);
1001:                } catch (ProviderContextException pce) {
1002:                    debugLogger.log(Level.INFO, "PSMC_CSPPM0031", pce);
1003:                }
1004:
1005:                return (summary);
1006:            }
1007:
1008:            /**
1009:             *  Channel is presentable if 1) parent.isPresentable() 2) existence of <code>display.template</code>
1010:             *  3) existence of sso adapter template
1011:             *
1012:             *@param  request  servlet request
1013:             *@return          true or false
1014:             */
1015:            public boolean isPresentable(HttpServletRequest request) {
1016:                boolean ip = false;
1017:                try {
1018:                    getTemplate("display.template");
1019:                } catch (ProviderException pe) {
1020:                    debugLogger.log(Level.INFO, "PSMC_CSPPM0038", getName());
1021:                    return false;
1022:                }
1023:                if (isPresentable != null) {
1024:                    ip = isPresentable.booleanValue();
1025:                    return (ip && isSSOConfigFound);
1026:                } else {
1027:                    return isSSOConfigFound;
1028:                }
1029:            }
1030:
1031:            /**
1032:             *  Decodes a string
1033:             *
1034:             *@param  t  string to decode
1035:             *@return    decoded string
1036:             */
1037:            private String decodeWords(String t) {
1038:                int i = 0;
1039:                int j = 0;
1040:                StringBuffer str = new StringBuffer();
1041:                try {
1042:                    while ((i = t.indexOf("=?", j)) >= 0) {
1043:                        str.append(t.substring(0, i));
1044:                        t = MimeUtility.decodeText(t.substring(i, t.length()));
1045:                        j = 1;
1046:                    }
1047:
1048:                    str.append(t);
1049:                    return str.toString();
1050:                } catch (Exception e) {
1051:                }
1052:                return t;
1053:            }
1054:
1055:            /**
1056:             * Returns the DP property by attempting to retrieve client and localized properties first
1057:             * then it searches for non conditional definitions
1058:             *
1059:             * @param pflist                 List containg the client and locale filters
1060:             * @param key                    Display Preofile key
1061:             * @return                       Returns the best value for the DP key
1062:             */
1063:            public String getBestStringProperty(String key, String def,
1064:                    List pflist) {
1065:                ProviderContext pc = getProviderContext();
1066:                try {
1067:                    if (key != null) {
1068:                        if (pc
1069:                                .existsStringProperty(this .getName(), key,
1070:                                        pflist)) {
1071:                            return pc.getStringProperty(this .getName(), key,
1072:                                    pflist);
1073:                        } else if (pc.existsStringProperty(this .getName(), key)) {
1074:                            return pc.getStringProperty(this .getName(), key);
1075:                        }
1076:                    }
1077:                    return def;
1078:                } catch (ProviderContextException pce) {
1079:                    debugLogger.log(Level.FINE, "PSMC_CSPPM0039", key);
1080:                    return def;
1081:                }
1082:            }
1083:
1084:            public String getBestStringProperty(String key, List pflist) {
1085:                return getBestStringProperty(key, "", pflist);
1086:            }
1087:
1088:            /**
1089:             * Returns the DP property by attempting to retrieve client and localized properties first
1090:             * then it searches for non conditional definitions
1091:             *
1092:             * @param pflist                 List containg the client and locale filters
1093:             * @param key                    Display Preofile key
1094:             * @return                       Returns the best value for the DP key
1095:             */
1096:            public int getBestIntegerProperty(String key, int def, List pflist) {
1097:                ProviderContext pc = getProviderContext();
1098:                try {
1099:                    if (key != null) {
1100:                        if (pc.existsIntegerProperty(this .getName(), key,
1101:                                pflist)) {
1102:                            return pc.getIntegerProperty(this .getName(), key,
1103:                                    pflist);
1104:                        } else if (pc
1105:                                .existsIntegerProperty(this .getName(), key)) {
1106:                            return pc.getIntegerProperty(this .getName(), key);
1107:                        }
1108:                    }
1109:                    return def;
1110:                } catch (ProviderContextException pce) {
1111:                    debugLogger.log(Level.FINE, "PSMC_CSPPM0039", key);
1112:                    return def;
1113:                }
1114:            }
1115:
1116:            public int getBestIntegerProperty(String key, List pflist) {
1117:                return getBestIntegerProperty(key, 0, pflist);
1118:            }
1119:
1120:            /**
1121:             * Returns the DP property by attempting to retrieve client and localized properties first
1122:             * then it searches for non conditional definitions
1123:             *
1124:             * @param pflist                 List containg the client and locale filters
1125:             * @param key                    Display Preofile key
1126:             * @return                       Returns the best value for the DP key
1127:             */
1128:            public Map getBestCollectionProperty(String key, Map def,
1129:                    List pflist) {
1130:                ProviderContext pc = getProviderContext();
1131:                try {
1132:                    if (key != null) {
1133:                        if (pc.existsCollectionProperty(this .getName(), key,
1134:                                pflist)) {
1135:                            return pc.getCollectionProperty(this .getName(),
1136:                                    key, pflist);
1137:                        } else if (pc.existsCollectionProperty(this .getName(),
1138:                                key)) {
1139:                            return pc
1140:                                    .getCollectionProperty(this .getName(), key);
1141:                        }
1142:                    }
1143:                    return def;
1144:                } catch (ProviderContextException pce) {
1145:                    debugLogger.log(Level.FINE, "PSMC_CSPPM0039", key);
1146:                    return def;
1147:                }
1148:            }
1149:
1150:            public Map getBestCollectionProperty(String key, List pflist) {
1151:                return getBestCollectionProperty(key, null, pflist);
1152:            }
1153:
1154:            /**
1155:             * Returns the DP property by attempting to retrieve client and localized properties first
1156:             * then it searches for non conditional definitions
1157:             *
1158:             * @param pflist                 List containg the client and locale filters
1159:             * @param key                    Display Preofile key
1160:             * @return                       Returns the best value for the DP key
1161:             */
1162:            public boolean getBestBooleanProperty(String key, boolean def,
1163:                    List pflist) {
1164:                ProviderContext pc = getProviderContext();
1165:                try {
1166:                    if (key != null) {
1167:                        if (pc.existsBooleanProperty(this .getName(), key,
1168:                                pflist)) {
1169:                            return pc.getBooleanProperty(this .getName(), key,
1170:                                    pflist);
1171:                        } else if (pc
1172:                                .existsBooleanProperty(this .getName(), key)) {
1173:                            return pc.getBooleanProperty(this .getName(), key);
1174:                        }
1175:                    }
1176:                    return def;
1177:                } catch (ProviderContextException pce) {
1178:                    debugLogger.log(Level.FINE, "PSMC_CSPPM0039", key);
1179:                    return def;
1180:                }
1181:            }
1182:
1183:            public boolean getBestBooleanProperty(String key, List pflist) {
1184:                return getBestBooleanProperty(key, false, pflist);
1185:            }
1186:
1187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.