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


0001:        /**
0002:         * $Id: MailViews.java,v 1.19 2005/09/21 10:49:08 dg154973 Exp $
0003:         * Copyright 2003 Sun Microsystems, Inc. All
0004:         * rights reserved. Use of this product is subject
0005:         * to license terms. Federal Acquisitions:
0006:         * Commercial Software -- Government Users
0007:         * Subject to Standard License Terms andx1
0008:         * Conditions.
0009:         *
0010:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
0011:         * are trademarks or registered trademarks of Sun Microsystems,
0012:         * Inc. in the United States and other countries.
0013:         */package com.sun.portal.wireless.providers.mail;
0014:
0015:        import java.net.*;
0016:        import java.io.*;
0017:        import java.util.*;
0018:        import java.util.logging.Level;
0019:        import java.util.logging.LogRecord;
0020:        import java.util.logging.Logger;
0021:
0022:        import javax.servlet.http.HttpServletRequest;
0023:        import javax.servlet.http.HttpServletResponse;
0024:        import javax.servlet.http.HttpUtils;
0025:
0026:        import com.sun.ssoadapter.config.ClientAwareUserContext;
0027:        import com.sun.ssoadapter.config.ConfigContext;
0028:        import com.sun.ssoadapter.config.PSClientAwareContextFactory;
0029:        import com.sun.ssoadapter.config.SAALException;
0030:        import com.sun.ssoadapter.config.DSAMEConnection;
0031:
0032:        import com.sun.ssoadapter.config.Configuration;
0033:        import com.sun.ssoadapter.config.ConfigurationFactory;
0034:        import com.sun.ssoadapter.config.ConfigurationException;
0035:
0036:        import com.sun.ssoadapter.SSOAdapterSession;
0037:
0038:        import com.sun.portal.log.common.PortalLogger;
0039:        import com.sun.portal.providers.ProfileProviderAdapter;
0040:        import com.sun.portal.providers.ProviderException;
0041:        import com.sun.portal.providers.containers.ContainerProviderAdapter;
0042:        import com.sun.portal.providers.context.ProviderContext;
0043:        import com.sun.portal.providers.context.ProviderContextException;
0044:        import com.sun.portal.providers.mail.MailProvider;
0045:        import com.sun.portal.providers.mail.MailApplicationHelper;
0046:
0047:        import com.sun.portal.wireless.util.AppConfigConstants;
0048:        import com.sun.portal.wireless.providers.util.ProviderUtility;
0049:
0050:        /**
0051:         * MailViews provides a  means for mail users to select client specific
0052:         * views of mail messages. Each <b>view</b> consists of one or all of the user 
0053:         * defined <b>rules</b>. See Views section of ContentProvider SDS for more details.
0054:         *
0055:         */
0056:
0057:        public class MailViews implements  DeviceSelectConstants {
0058:
0059:            private static final String VIEWCLIENTATTR = AppConfigConstants.MAIL_APP_VIEW_CLIENTS_LIST;
0060:
0061:            private String caller = null;
0062:            private String client = null;
0063:            private String errMsg = null;
0064:            private String containerName = null;
0065:            private String desktopURL = null;
0066:            private String editContainer = null;
0067:            private String page = null;
0068:            private String providerName = null;
0069:            private Map serviceMap = null;
0070:            private ResourceBundle bundle = null;
0071:            private ResourceBundle deviceBundle = null;
0072:            private StringBuffer edit = new StringBuffer(0);
0073:            private ClientAwareUserContext mailViewUserContext = null;
0074:            private ConfigurationFactory rulesFactory = null;
0075:            private ConfigurationFactory viewsFactory = null;
0076:            private MailApplicationHelper appHelper = null;
0077:            private MailProvider provider = null;
0078:            private DSAMEConnection dsameConn = null;
0079:
0080:            private static Logger logger = PortalLogger
0081:                    .getLogger(MailViews.class);
0082:
0083:            public void init(MailProvider mprov, String container,
0084:                    String editContainer, MailApplicationHelper mAppHelper,
0085:                    HttpServletRequest request) throws ProviderException {
0086:                provider = mprov;
0087:                appHelper = mAppHelper;
0088:                containerName = container;
0089:                this .editContainer = editContainer;
0090:
0091:                PSClientAwareContextFactory mapFac = null;
0092:                serviceMap = new HashMap();
0093:                serviceMap.put("serviceName",
0094:                        AppConfigConstants.MAIL_APP_SERVICE_NAME);
0095:                try {
0096:                    mapFac = PSClientAwareContextFactory.getInstance();
0097:                    mailViewUserContext = mapFac
0098:                            .getClientAwareUserContext(new SSOAdapterSession(
0099:                                    request));
0100:                } catch (IllegalStateException ie) {
0101:                    logger.log(Level.INFO, "", ie);
0102:                    return;
0103:                } catch (SAALException se) {
0104:                    logger.log(Level.INFO, "", se);
0105:                    return;
0106:                }
0107:
0108:                // Get connection to DSAME
0109:                dsameConn = new DSAMEConnection(new SSOAdapterSession(request));
0110:
0111:                // Get factories...
0112:                rulesFactory = ConfigurationFactory.getInstance(
0113:                        AppConfigConstants.MAIL_APP_SERVICE_NAME,
0114:                        AppConfigConstants.MAIL_APP_RULE_LIST);
0115:                viewsFactory = ConfigurationFactory.getInstance(
0116:                        AppConfigConstants.MAIL_APP_SERVICE_NAME,
0117:                        AppConfigConstants.MAIL_APP_VIEW_LIST);
0118:
0119:                // Get the base resource bundle
0120:                if (bundle == null) {
0121:                    bundle = provider.getResourceBundle(PROPERTIES_BASE);
0122:                }
0123:
0124:                // Get the client name resource bundle
0125:                if (deviceBundle == null) {
0126:                    deviceBundle = provider.getResourceBundle(PROPERTIES_DEV);
0127:                }
0128:            }
0129:
0130:            /**
0131:             * Overide super.getEdit() PAPI method.
0132:             */
0133:
0134:            public StringBuffer getEdit(HttpServletRequest request,
0135:                    HttpServletResponse response) throws ProviderException {
0136:
0137:                logger.entering(this .getClass().getName(), "getEdit");
0138:
0139:                boolean isErr = false;
0140:                String errMsg = request.getParameter("err");
0141:                if (logger.isLoggable(Level.FINEST)) {
0142:                    String[] param = { "errMsg", errMsg };
0143:                    logger.log(Level.FINEST, "PSMA_CSPWPM0001", param);
0144:                }
0145:
0146:                if (errMsg != null) {
0147:                    return getErrorMessage(request, errMsg, request
0148:                            .getParameter("page"));
0149:                }
0150:
0151:                client = request.getParameter("client");
0152:                page = request.getParameter("page");
0153:
0154:                if (editContainer == null) {
0155:                    editContainer = request.getParameter("provider");
0156:                }
0157:
0158:                String viewMode = request.getParameter("viewmode");
0159:                Enumeration availableRules = null;
0160:                Enumeration availableViews = null;
0161:
0162:                if (viewMode.equals("Device")) {
0163:                    try {
0164:                        availableViews = viewsFactory
0165:                                .getConfigurationNames(new SSOAdapterSession(
0166:                                        request));
0167:                        if (availableViews.hasMoreElements()) {
0168:                            edit = getDeviceViews(request);
0169:                        } else {
0170:                            errMsg = "MailViews-NoViews";
0171:                            return getErrorMessage(request, errMsg, "NoViews");
0172:                        }
0173:                    } catch (Throwable t) {
0174:                        logger.log(Level.INFO, "", t);
0175:                        edit = new StringBuffer(t.toString());
0176:                    }
0177:                    return edit;
0178:                } else if (viewMode.equals("Rules")) {
0179:                    edit = getRules(request);
0180:                    return edit;
0181:                } else if (viewMode.equals("Views")) {
0182:                    availableRules = rulesFactory
0183:                            .getConfigurationNames(new SSOAdapterSession(
0184:                                    request));
0185:                    if (availableRules.hasMoreElements()) {
0186:                        edit = getViews(request);
0187:                    } else {
0188:                        errMsg = "MailViews-NoRules";
0189:                        return getErrorMessage(request, errMsg, "NoRules");
0190:                    }
0191:                    return edit;
0192:                }
0193:
0194:                if ((page) != null) {
0195:                    if (page.equalsIgnoreCase("AddRule")) {
0196:                        edit = getRuleConfig(request);
0197:                    }
0198:                    if (page.equalsIgnoreCase("EditRule")) {
0199:                        String selectedRule = request.getParameter("order");
0200:                        if (logger.isLoggable(Level.FINEST)) {
0201:                            String[] param = { "selectedRule", selectedRule };
0202:                            logger.log(Level.FINEST, "PSMA_CSPWPM0001", param);
0203:                        }
0204:
0205:                        if ((selectedRule != null)
0206:                                && (!selectedRule.equals(""))
0207:                                && (!selectedRule.equals("null"))) {
0208:                            edit = getRuleConfig(request, selectedRule);
0209:                        } else {
0210:                            errMsg = "MailViews-NoRuleValue";
0211:                            return getErrorMessage(request, errMsg,
0212:                                    "RulesError");
0213:                        }
0214:                    }
0215:
0216:                    if (page.equalsIgnoreCase("AddView")) {
0217:                        edit = getViewConfig(request);
0218:                    }
0219:                    if (page.equalsIgnoreCase("EditView")) {
0220:                        String selectedView = request.getParameter("order");
0221:                        if (logger.isLoggable(Level.FINEST)) {
0222:                            String[] param = { "selectedView", selectedView };
0223:                            logger.log(Level.FINEST, "PSMA_CSPWPM0001", param);
0224:                        }
0225:
0226:                        if ((selectedView != null)
0227:                                && (!selectedView.equals(""))
0228:                                && (!selectedView.equals("null"))) {
0229:                            edit = getViewConfig(request, selectedView);
0230:                        } else {
0231:                            errMsg = "MailViews-NoViewValue";
0232:                            return getErrorMessage(request, errMsg,
0233:                                    "ViewsError");
0234:                        }
0235:                    }
0236:                    return edit;
0237:                } else {
0238:                    // if no page parameter
0239:                    if ((client == null) || (client.equalsIgnoreCase(""))) {
0240:                        logger.finest("PSMA_CSPWPM0002");
0241:                        edit = getDeviceViews(request);
0242:                    } else {
0243:                        edit = getViewEdit(request, client);
0244:                    }
0245:                }
0246:
0247:                return (edit);
0248:            } //end getEdit()
0249:
0250:            /** 
0251:             * getRules returns the Manage Rules screen
0252:             * @return StringBuffer containing the Manage Rules screen
0253:             * @param HttpServletRequest
0254:             * @throws ProviderException 
0255:             */
0256:
0257:            private StringBuffer getRules(HttpServletRequest request)
0258:                    throws ProviderException {
0259:
0260:                /* template:views-manage-rules.template 
0261:                 * tags:
0262:                 *      [tag:iwtDesktop-fontFace1] = font
0263:                 *      [tag:ruleConfigs] = stringbuffer containing rules options list
0264:                 */
0265:                logger.entering(this .getClass().getName(), "getRules");
0266:
0267:                StringBuffer ruleConfigs = new StringBuffer(0);
0268:                Hashtable manageRulesHash = new Hashtable();
0269:                Hashtable ruleOptionHash = new Hashtable();
0270:
0271:                //add theme tags
0272:                try {
0273:                    ProviderUtility.setDefaultPresentation(provider.getName(),
0274:                            provider.getProviderContext(), ruleOptionHash);
0275:                    ProviderUtility.setDefaultPresentation(provider.getName(),
0276:                            provider.getProviderContext(), manageRulesHash);
0277:                } catch (ProviderContextException pce) {
0278:                    logger.log(Level.INFO, "PSMA_CSPWPM0003", pce);
0279:                }
0280:
0281:                //desktopURL = makeReturnURL(request);
0282:
0283:                try {
0284:                    manageRulesHash.put("iwtDesktop-fontFace1", provider
0285:                            .getStringProperty("fontFace1", "Sans-serif"));
0286:
0287:                    Enumeration availableRules = rulesFactory
0288:                            .getConfigurationNames(new SSOAdapterSession(
0289:                                    request));
0290:                    while (availableRules.hasMoreElements()) {
0291:                        String ruleName = String.valueOf(availableRules
0292:                                .nextElement());
0293:                        if (logger.isLoggable(Level.FINEST)) {
0294:                            String[] param = { "ruleName", ruleName };
0295:                            logger.log(Level.FINEST, "PSMA_CSPWPM0001", param);
0296:                        }
0297:
0298:                        ruleOptionHash.put("ruleId", ruleName);
0299:                        ruleConfigs.append(provider.getTemplate(
0300:                                "views-rule-options.template", ruleOptionHash));
0301:                    }
0302:
0303:                    manageRulesHash.put("ruleConfigs", ruleConfigs);
0304:                    manageRulesHash.put("isAppHandler", appHelper.getName());
0305:                    return (provider.getTemplate("views-manage-rules.template",
0306:                            manageRulesHash));
0307:
0308:                } catch (Exception e) {
0309:                    logger.log(Level.INFO, "", e);
0310:                    throw new ProviderException(e.getMessage());
0311:                }
0312:            }
0313:
0314:            /**
0315:             * getRuleConfig() returns the rule config template
0316:             * @return StringBuffer containing the rule
0317:             * @param HttpServletRequest
0318:             * @throws ProviderException 
0319:             */
0320:
0321:            private StringBuffer getRuleConfig(HttpServletRequest request)
0322:                    throws ProviderException {
0323:                /* template:views-rule-config.template 
0324:                 * tags:
0325:                 *      [tag:iwtDesktop-fontFace1] = font
0326:                 *      [tag:ruleName] = ""
0327:                 *
0328:                 *      [tag:recentReadChecked] = ""
0329:                 *          [tag:isSelected] = SELECTED
0330:                 *          [tag:isntSelected] = ""
0331:                 *          [tag:recentSelected] = "SELECTED"
0332:                 *          [tag:readSelected] = ""
0333:                 *
0334:                 *      [tag:headerChecked] = "CHECKED"
0335:                 *          [tag:subjectSelected] = "SELECTED"
0336:                 *          [tag:senderSelected] = ""
0337:                 *          [tag:dateSelected] = ""
0338:                 *          [tag:prioritySelected] = ""
0339:                 *          [tag:toSelected] = ""
0340:                 *          [tag:ccSelected] = ""
0341:                 *          [tag:containsSelected] = "SELECTED"
0342:                 *          [tag:doesntSelected] = ""
0343:                 *          [tag:ruleValue] = ""
0344:                 */
0345:
0346:                Hashtable rulesHash = new Hashtable();
0347:                try {
0348:                    //add theme tags
0349:                    ProviderUtility.setDefaultPresentation(provider.getName(),
0350:                            provider.getProviderContext(), rulesHash);
0351:
0352:                    rulesHash.put("action", "Add");
0353:                    rulesHash.put("iwtDesktop-fontFace1", provider
0354:                            .getStringProperty("fontFace1", "Sans-serif"));
0355:                    rulesHash.put("ruleName", "");
0356:
0357:                    rulesHash.put("recentReadChecked", "");
0358:                    rulesHash.put("isSelected", "SELECTED");
0359:                    rulesHash.put("isntSelected", "");
0360:                    rulesHash.put("recentSelected", "SELECTED");
0361:                    rulesHash.put("readSelected", "");
0362:
0363:                    rulesHash.put("headerChecked", "CHECKED");
0364:                    rulesHash.put("subjectSelected", "SELECTED");
0365:                    rulesHash.put("senderSelected", "");
0366:                    rulesHash.put("dateSelected", "");
0367:                    rulesHash.put("prioritySelected", "");
0368:                    rulesHash.put("toSelected", "");
0369:                    rulesHash.put("ccSelected", "");
0370:                    rulesHash.put("containsSelected", "SELECTED");
0371:                    rulesHash.put("doesntSelected", "");
0372:                    rulesHash.put("ruleValue", "");
0373:
0374:                    rulesHash.put("isAppHandler", appHelper.getName());
0375:
0376:                    return provider.getTemplate("views-rule-config.template",
0377:                            rulesHash);
0378:
0379:                } catch (Exception e) {
0380:                    logger.log(Level.INFO, "", e);
0381:                    throw new ProviderException(e.getMessage());
0382:                }
0383:            } //end getRuleConfig
0384:
0385:            /**
0386:             * returns the rule config template with all the values filled in per the 
0387:             * <b>selected rule configuration name</b>.
0388:             *
0389:             * @return StringBuffer containing the rule config template
0390:             * @param HttpServletRequest 
0391:             * @param String selected configuration name
0392:             * @throws ProviderException in case of an error
0393:             */
0394:
0395:            private StringBuffer getRuleConfig(HttpServletRequest request,
0396:                    String selected) throws ProviderException {
0397:
0398:                String configName = null;
0399:                String ruleStr = null;
0400:                String target = null;
0401:                String opr = null;
0402:                String str = null;
0403:                boolean match = false;
0404:                Hashtable rulesHash = new Hashtable();
0405:
0406:                Configuration ruleConfig = null;
0407:
0408:                //get the rule configuration
0409:                try {
0410:                    ruleConfig = rulesFactory.readConfiguration(selected,
0411:                            false, new SSOAdapterSession(request));
0412:                    match = true;
0413:                } catch (Exception e) {
0414:                    logger.log(Level.INFO, "PSMA_CSPWPM0004", selected);
0415:                }
0416:
0417:                if (match) {
0418:                    configName = selected;
0419:                    target = ruleConfig.getProperty("target");
0420:                    if (logger.isLoggable(Level.FINEST)) {
0421:                        String[] param = { "target", target };
0422:                        logger.log(Level.FINEST, "PSMA_CSPWPM0001", param);
0423:                    }
0424:
0425:                    opr = ruleConfig.getProperty("op");
0426:                    if (logger.isLoggable(Level.FINEST)) {
0427:                        String[] param = { "op", opr };
0428:                        logger.log(Level.FINEST, "PSMA_CSPWPM0001", param);
0429:                    }
0430:
0431:                    str = ruleConfig.getProperty("ruleValue");
0432:                    if (logger.isLoggable(Level.FINEST)) {
0433:                        String[] param = { "ruleValue", str };
0434:                        logger.log(Level.FINEST, "PSMA_CSPWPM0001", param);
0435:                    }
0436:                }
0437:
0438:                try {
0439:                    rulesHash.put("action", "Edit");
0440:                    rulesHash.put("iwtDesktop-fontFace1", provider
0441:                            .getStringProperty("fontFace1", "Sans-serif"));
0442:                    rulesHash.put("ruleName", configName);
0443:
0444:                    rulesHash.put("recentReadChecked", "");
0445:                    rulesHash.put("isSelected", "SELECTED");
0446:                    rulesHash.put("isntSelected", "");
0447:                    rulesHash.put("recentSelected", "SELECTED");
0448:                    rulesHash.put("readSelected", "");
0449:
0450:                    rulesHash.put("headerChecked", "CHECKED");
0451:                    rulesHash.put("subjectSelected", "");
0452:                    rulesHash.put("senderSelected", "");
0453:                    rulesHash.put("dateSelected", "");
0454:                    rulesHash.put("prioritySelected", "");
0455:                    rulesHash.put("toSelected", "");
0456:                    rulesHash.put("ccSelected", "");
0457:                    rulesHash.put("containsSelected", "SELECTED");
0458:                    rulesHash.put("doesntSelected", "");
0459:                    rulesHash.put("ruleValue", "");
0460:
0461:                    if (match) {
0462:                        //target
0463:                        if (target.equalsIgnoreCase("flag")) {
0464:                            rulesHash.put("recentReadChecked", "CHECKED");
0465:                            rulesHash.put("headerChecked", "");
0466:                        } else if (target.equalsIgnoreCase("subject")) {
0467:                            rulesHash.put("subjectSelected", "SELECTED");
0468:                        } else if (target.equalsIgnoreCase("sender")) {
0469:                            rulesHash.put("senderSelected", "SELECTED");
0470:                        } else if (target.equalsIgnoreCase("date")) {
0471:                            rulesHash.put("dateSelected", "SELECTED");
0472:                        } else if (target.equalsIgnoreCase("priority")) {
0473:                            rulesHash.put("prioritySelected", "SELECTED");
0474:                        } else if (target.equalsIgnoreCase("to")) {
0475:                            rulesHash.put("toSelected", "SELECTED");
0476:                        } else if (target.equalsIgnoreCase("cc")) {
0477:                            rulesHash.put("ccSelected", "SELECTED");
0478:                        }
0479:
0480:                        //opr
0481:                        if (opr.startsWith("does")) {
0482:                            rulesHash.put("containsSelected", "");
0483:                            rulesHash.put("doesntSelected", "SELECTED");
0484:                        } else if (opr.startsWith("isn")) {
0485:                            rulesHash.put("isSelected", "");
0486:                            rulesHash.put("isntSelected", "SELECTED");
0487:                        }
0488:
0489:                        // ruleValue
0490:                        if (str.equalsIgnoreCase("read")) {
0491:                            rulesHash.put("recentSelected", "");
0492:                            rulesHash.put("readSelected", "SELECTED");
0493:                        } else if (!(str.equalsIgnoreCase("recent"))
0494:                                && !(str.equalsIgnoreCase("read"))) {
0495:                            rulesHash.put("ruleValue", str);
0496:                        }
0497:                    }
0498:
0499:                    rulesHash.put("isAppHandler", appHelper.getName());
0500:
0501:                    //add theme tags
0502:                    ProviderUtility.setDefaultPresentation(provider.getName(),
0503:                            provider.getProviderContext(), rulesHash);
0504:
0505:                    return provider.getTemplate("views-rule-config.template",
0506:                            rulesHash);
0507:
0508:                } catch (Exception e) {
0509:                    logger.log(Level.INFO, "", e);
0510:                    throw new ProviderException(e.getMessage());
0511:                }
0512:            }
0513:
0514:            /** 
0515:             * getViews returns the Manage Views screen
0516:             * @return StringBuffer containing the Manage Views screen
0517:             * @param HttpServletRequest
0518:             * @throws ProviderException 
0519:             */
0520:
0521:            private StringBuffer getViews(HttpServletRequest request)
0522:                    throws ProviderException {
0523:
0524:                /* template:views-manage-views.template 
0525:                 * tags:
0526:                 *      [tag:iwtDesktop-fontFace1] = font
0527:                 *      [tag:viewConfigs] = stringbuffer containing views options list
0528:                 */
0529:
0530:                logger.entering(this .getClass().getName(), "getViews");
0531:
0532:                StringBuffer viewConfigs = new StringBuffer(0);
0533:                Hashtable manageViewsHash = new Hashtable();
0534:                Hashtable viewOptionHash = new Hashtable();
0535:
0536:                //add theme tags
0537:                try {
0538:                    ProviderUtility.setDefaultPresentation(provider.getName(),
0539:                            provider.getProviderContext(), viewOptionHash);
0540:                    ProviderUtility.setDefaultPresentation(provider.getName(),
0541:                            provider.getProviderContext(), manageViewsHash);
0542:                } catch (ProviderContextException pce) {
0543:                    logger.log(Level.INFO, "", pce);
0544:                }
0545:
0546:                //desktopURL = makeReturnURL(request);
0547:
0548:                try {
0549:                    manageViewsHash.put("iwtDesktop-fontFace1", provider
0550:                            .getStringProperty("fontFace1", "Sans-serif"));
0551:
0552:                    Enumeration availableViews = viewsFactory
0553:                            .getConfigurationNames(new SSOAdapterSession(
0554:                                    request));
0555:                    while (availableViews.hasMoreElements()) {
0556:                        String viewName = String.valueOf(availableViews
0557:                                .nextElement());
0558:                        if (logger.isLoggable(Level.FINEST)) {
0559:                            String[] param = { "viewName", viewName };
0560:                            logger.log(Level.FINEST, "PSMA_CSPWPM0001", param);
0561:                        }
0562:
0563:                        viewOptionHash.put("viewName", viewName);
0564:                        viewConfigs.append(provider.getTemplate(
0565:                                "views-options.template", viewOptionHash));
0566:                    }
0567:
0568:                    manageViewsHash.put("viewConfigs", viewConfigs);
0569:                    manageViewsHash.put("isAppHandler", appHelper.getName());
0570:                    return (provider.getTemplate("views-manage-views.template",
0571:                            manageViewsHash));
0572:
0573:                } catch (Exception e) {
0574:                    logger.log(Level.INFO, "", e);
0575:                    throw new ProviderException(e.getMessage());
0576:                }
0577:            }
0578:
0579:            /** 
0580:             * getViewConfig returns the empty rule selection screen
0581:             * @return StringBuffer containing the rule selection screen
0582:             * @param HttpServletRequest
0583:             * @throws ProviderException 
0584:             */
0585:
0586:            private StringBuffer getViewConfig(HttpServletRequest request)
0587:                    throws ProviderException {
0588:
0589:                /* template:views-rule-selection.template 
0590:                 * tags:
0591:                 *      [tag:action] = Add
0592:                 *      [tag:iwtDesktop-fontFace1] = font
0593:                 *      [tag:viewName] = ""
0594:                 *      [tag:anyCheck] = SELECTED
0595:                 *      [tag:allCheck] = ""
0596:                 *      [tag:ruleConfigs] = stringbuffer containing rules template
0597:                 */
0598:                logger.entering(this .getClass().getName(), "getAddViewConfig");
0599:
0600:                StringBuffer addViewPage = null;
0601:                StringBuffer ruleConfigs = new StringBuffer(0);
0602:                Hashtable addViewHash = new Hashtable();
0603:                Hashtable ruleOptionHash = new Hashtable();
0604:
0605:                //add theme tags
0606:                try {
0607:                    ProviderUtility.setDefaultPresentation(provider.getName(),
0608:                            provider.getProviderContext(), ruleOptionHash);
0609:                    ProviderUtility.setDefaultPresentation(provider.getName(),
0610:                            provider.getProviderContext(), addViewHash);
0611:                } catch (ProviderContextException pce) {
0612:                    logger.log(Level.INFO, "", pce);
0613:                }
0614:
0615:                desktopURL = makeReturnURL(request);
0616:
0617:                try {
0618:                    addViewHash.put("action", "Add");
0619:                    addViewHash.put("iwtDesktop-fontFace1", provider
0620:                            .getStringProperty("fontFace1", "Sans-serif"));
0621:                    addViewHash.put("viewName", "");
0622:                    addViewHash.put("selectedRules", "");
0623:                    addViewHash.put("anyCheck", "CHECKED");
0624:                    addViewHash.put("allCheck", "");
0625:
0626:                    Enumeration availableRules = rulesFactory
0627:                            .getConfigurationNames(new SSOAdapterSession(
0628:                                    request));
0629:                    while (availableRules.hasMoreElements()) {
0630:                        String ruleName = String.valueOf(availableRules
0631:                                .nextElement());
0632:                        if (logger.isLoggable(Level.FINEST)) {
0633:                            String[] param = { "ruleName", ruleName };
0634:                            logger.log(Level.FINEST, "PSMA_CSPWPM0001", param);
0635:                        }
0636:
0637:                        ruleOptionHash.put("ruleId", ruleName);
0638:                        ruleConfigs.append(provider.getTemplate(
0639:                                "views-rule-options.template", ruleOptionHash));
0640:                    }
0641:
0642:                    addViewHash.put("availableRules", ruleConfigs);
0643:                    addViewHash.put("isAppHandler", appHelper.getName());
0644:                    return (provider.getTemplate(
0645:                            "views-rule-selection.template", addViewHash));
0646:
0647:                } catch (Exception e) {
0648:                    logger.log(Level.INFO, "", e);
0649:                    throw new ProviderException(e.getMessage());
0650:                }
0651:            }
0652:
0653:            /**
0654:             * getViewConfig() returns the view-rule-selection.template
0655:             * @return StringBuffer containing the rule selection edit page 
0656:             * @param HttpServletRequest
0657:             * @throws ProviderException 
0658:             */
0659:
0660:            public StringBuffer getViewConfig(HttpServletRequest request,
0661:                    String selected) throws ProviderException {
0662:                logger.entering(this .getClass().getName(), "getAddViewConfig");
0663:
0664:                //logParams(request);
0665:
0666:                String rule = null;
0667:                String ruleName = null;
0668:                String selectedRule = "";
0669:                Hashtable editViewHash = new Hashtable();
0670:                Hashtable selectRuleHash = new Hashtable();
0671:                Hashtable availRuleHash = new Hashtable();
0672:                StringBuffer selectRules = new StringBuffer(0);
0673:                StringBuffer availRules = new StringBuffer(0);
0674:
0675:                String providerName = editContainer;
0676:
0677:                desktopURL = makeReturnURL(request);
0678:
0679:                Configuration viewConfig = null;
0680:
0681:                try {
0682:                    editViewHash.put("action", "Edit");
0683:                    editViewHash.put("iwtDesktop-fontFace1", provider
0684:                            .getStringProperty("fontFace1", "Sans-serif"));
0685:
0686:                    //Add theme tags
0687:                    ProviderUtility.setDefaultPresentation(provider.getName(),
0688:                            provider.getProviderContext(), editViewHash);
0689:                    ProviderUtility.setDefaultPresentation(provider.getName(),
0690:                            provider.getProviderContext(), selectRuleHash);
0691:                    ProviderUtility.setDefaultPresentation(provider.getName(),
0692:                            provider.getProviderContext(), availRuleHash);
0693:
0694:                    // Get the view configuration
0695:                    try {
0696:                        viewConfig = viewsFactory.readConfiguration(selected,
0697:                                false, new SSOAdapterSession(request));
0698:                        editViewHash.put("viewName", selected);
0699:                    } catch (Exception e) {
0700:                        logger.log(Level.SEVERE, "PSMA_CSPWPM0010", selected);
0701:                    }
0702:
0703:                    // Put the selected rules for the view in the template
0704:                    String[] selectedRules = viewConfig
0705:                            .getPropertyArray("ruleName");
0706:
0707:                    if (selectedRules != null) {
0708:                        for (int j = 0; j < selectedRules.length; j++) {
0709:                            selectRuleHash.put("ruleId", selectedRules[j]);
0710:                            selectRuleHash.put("preSelect", "selected");
0711:                            selectRules.append(provider.getTemplate(
0712:                                    "views-rule-options.template",
0713:                                    selectRuleHash));
0714:                        }
0715:                        if (logger.isLoggable(Level.FINEST)) {
0716:                            String[] param = { "Selected rules",
0717:                                    selectRules.toString() };
0718:                            logger.log(Level.FINEST, "PSMA_CSPWPM0001", param);
0719:                        }
0720:
0721:                        editViewHash.put("selectedRules", selectRules);
0722:
0723:                        // Put all the rules that are not selected in the available
0724:                        // list of views-rule-options.template
0725:                        Enumeration availableRules = rulesFactory
0726:                                .getConfigurationNames(new SSOAdapterSession(
0727:                                        request));
0728:                        while (availableRules.hasMoreElements()) {
0729:                            ruleName = (String) availableRules.nextElement();
0730:
0731:                            boolean alreadySelected = false;
0732:                            for (int j = 0; j < selectedRules.length; j++) {
0733:                                if (ruleName.equals(selectedRules[j])) {
0734:                                    alreadySelected = true;
0735:                                    break;
0736:                                }
0737:                            }
0738:                            if (!alreadySelected) {
0739:                                availRuleHash.put("ruleId", ruleName);
0740:                                availRules.append(provider.getTemplate(
0741:                                        "views-rule-options.template",
0742:                                        availRuleHash));
0743:                            }
0744:                        }
0745:                        if (logger.isLoggable(Level.FINEST)) {
0746:                            String[] param = { "Available Rules",
0747:                                    availRules.toString() };
0748:                            logger.log(Level.FINEST, "PSMA_CSPWPM0001", param);
0749:                        }
0750:                    } else {
0751:                        logger.finest("PSMA_CSPWPM0026");
0752:                        // Put all the rules in the available list of
0753:                        // views-rule-options.template. There are no selected rules.
0754:                        Enumeration availableRules = rulesFactory
0755:                                .getConfigurationNames(new SSOAdapterSession(
0756:                                        request));
0757:                        while (availableRules.hasMoreElements()) {
0758:                            ruleName = (String) availableRules.nextElement();
0759:
0760:                            availRuleHash.put("ruleId", ruleName);
0761:                            availRules.append(provider.getTemplate(
0762:                                    "views-rule-options.template",
0763:                                    availRuleHash));
0764:                        }
0765:                    }
0766:
0767:                    editViewHash.put("availableRules", availRules);
0768:
0769:                    // Get the value of "applyAll"
0770:                    String applyVal = viewConfig.getProperty("applyAll");
0771:                    if (logger.isLoggable(Level.FINEST)) {
0772:                        String[] param = { "applyVal", applyVal };
0773:                        logger.log(Level.FINEST, "PSMA_CSPWPM0001", param);
0774:                    }
0775:
0776:                    // Check for value of applyAll attr. 
0777:                    if (applyVal.equalsIgnoreCase("true")) {
0778:                        editViewHash.put("anyCheck", "");
0779:                        editViewHash.put("allCheck", "CHECKED");
0780:
0781:                    } else {
0782:                        editViewHash.put("anyCheck", "CHECKED");
0783:                        editViewHash.put("allCheck", "");
0784:                    }
0785:
0786:                    editViewHash.put("isAppHandler", appHelper.getName());
0787:
0788:                    return (provider.getTemplate(
0789:                            "views-rule-selection.template", editViewHash));
0790:
0791:                } catch (Exception e) {
0792:                    logger.log(Level.INFO, "", e);
0793:                    throw new ProviderException(e.getMessage());
0794:                }
0795:            } // end getViewConfig()
0796:
0797:            private StringBuffer getDeviceViews(HttpServletRequest request)
0798:                    throws ProviderException {
0799:
0800:                StringBuffer editContent = new StringBuffer(0);
0801:                String client = request.getParameter(CLIENT);
0802:                try {
0803:                    if ((client == null) || client.equalsIgnoreCase("")) {
0804:                        editContent = getClientConfigEdit(request);
0805:                    } else {
0806:                        // TODO:  WTH???
0807:                        editContent = new StringBuffer("You have selected "
0808:                                + client + " device");
0809:                    }
0810:                } catch (Exception e) {
0811:                    throw new ProviderException("MailViews.getDeviceViews(): ",
0812:                            e);
0813:                }
0814:                return editContent;
0815:            }
0816:
0817:            private StringBuffer getClientConfigEdit(HttpServletRequest request)
0818:                    throws Exception {
0819:                logger.entering(this .getClass().getName(),
0820:                        "getClientConfigEdit");
0821:
0822:                Hashtable mainTags = new Hashtable();
0823:                Hashtable optionTags = new Hashtable();
0824:                Hashtable selectTags = new Hashtable();
0825:
0826:                //add theme tags
0827:                try {
0828:                    ProviderUtility.setDefaultPresentation(provider.getName(),
0829:                            provider.getProviderContext(), optionTags);
0830:                    ProviderUtility.setDefaultPresentation(provider.getName(),
0831:                            provider.getProviderContext(), selectTags);
0832:                    ProviderUtility.setDefaultPresentation(provider.getName(),
0833:                            provider.getProviderContext(), mainTags);
0834:                } catch (ProviderContextException pce) {
0835:                    logger.log(Level.INFO, "PSMA_CSPWPM0005", pce);
0836:                }
0837:
0838:                ProviderContext pcontext = provider.getProviderContext();
0839:
0840:                String desktopURL = pcontext.getDesktopURL(request);
0841:
0842:                StringBuffer clientOptions = new StringBuffer(0);
0843:                StringBuffer clientSelect = new StringBuffer(0);
0844:                StringBuffer viewselectURL = new StringBuffer(desktopURL);
0845:                StringBuffer mailviewURL = new StringBuffer(desktopURL);
0846:
0847:                String clientType = null;
0848:                String clientName = null;
0849:                String client_type_name = null;
0850:
0851:                Set selectedClients = null;
0852:
0853:                if (logger.isLoggable(Level.FINEST)) {
0854:                    String[] param = { "desktopURL", desktopURL };
0855:                    logger.log(Level.FINEST, "PSMA_CSPWPM0001", param);
0856:                }
0857:
0858:                //construct the view url
0859:                mailviewURL = mailviewURL.append('?').append(ACTION)
0860:                        .append('=').append(EDIT)
0861:
0862:                        .append(getAmpersand()).append(PROVIDER).append('=')
0863:                        .append(URLEncoder.encode(editContainer))
0864:
0865:                        .append(getAmpersand()).append(TARGET_PROVIDER).append(
0866:                                '=').append(provider.getName())
0867:
0868:                        .append(getAmpersand()).append("containerName=")
0869:                        .append(URLEncoder.encode(containerName))
0870:
0871:                        .append(getAmpersand()).append("appPref=").append(
0872:                                URLEncoder.encode(appHelper.getName()))
0873:
0874:                        .append(getAmpersand()).append("viewmode=edit")
0875:
0876:                ;
0877:
0878:                if (logger.isLoggable(Level.FINEST)) {
0879:                    String[] param = { "mailviewURL", mailviewURL.toString() };
0880:                    logger.log(Level.FINEST, "PSMA_CSPWPM0001", param);
0881:                }
0882:
0883:                //now put it in hash
0884:                mainTags.put(VIEWSELECTLINK_TAG, pcontext.encodeURL(mailviewURL
0885:                        .toString()));
0886:
0887:                selectedClients = pcontext.getCollectionProperty(
0888:                        DESKTOP_DISPATCHER, SELECTEDCLIENTS).keySet();
0889:                int size = selectedClients.size();
0890:
0891:                for (Iterator i = selectedClients.iterator(); i.hasNext();) {
0892:
0893:                    clientType = (String) i.next();
0894:
0895:                    if (clientType == null) {
0896:                        String invc = null;
0897:                        try {
0898:                            invc = bundle.getString("MailViews-invalidClient");
0899:                            if (invc != null) {
0900:                                throw new ProviderException(invc);
0901:                            }
0902:                        } catch (Throwable t) { //just log 
0903:                            logger.log(Level.INFO, "", t);
0904:                        } finally {
0905:                            invc = null;
0906:                        }
0907:                    }
0908:
0909:                    if (clientType != null) {
0910:                        if (logger.isLoggable(Level.FINEST)) {
0911:                            String[] param = { "clientType", clientType };
0912:                            logger.log(Level.FINEST, "PSMA_CSPWPM0001", param);
0913:                        }
0914:                        try {
0915:                            //Get the device resource bundle
0916:                            client_type_name = deviceBundle
0917:                                    .getString(clientType);
0918:
0919:                        } catch (MissingResourceException mre) {
0920:                            logger.log(Level.INFO, "", mre);
0921:                            client_type_name = clientType;
0922:                        }
0923:
0924:                        try {
0925:                            optionTags.clear();
0926:                            optionTags.put(CLIENTTYPENAME_TAG, clientType); //this is the value submitted
0927:                            optionTags.put(CLIENT, client_type_name); //this is the name thats displayed
0928:                            clientOptions.append(pcontext.getTemplate(provider
0929:                                    .getName(), CLIENTOPTION_TEMPLATE,
0930:                                    optionTags));
0931:                        } catch (Throwable e) {
0932:                            client_type_name = null;
0933:                            logger.log(Level.INFO, "", e);
0934:                        }
0935:                    }
0936:                }
0937:
0938:                selectTags.clear();
0939:                selectTags.put(CLIENTSIZE_TAG, String.valueOf(size));
0940:                selectTags.put(CLIENTOPTIONS_TAG, clientOptions);
0941:                clientSelect.append(pcontext.getTemplate(provider.getName(),
0942:                        CLIENTSELECT_TEMPLATE, selectTags));
0943:
0944:                mainTags.put(SELECTCLIENTS_TAG, clientSelect);
0945:                mainTags.put("isAppHandler", appHelper.getName());
0946:                mainTags.put("views-display-error", bundle
0947:                        .getString("MailViews-NoClientValue"));
0948:
0949:                return (pcontext.getTemplate(provider.getName(),
0950:                        CLIENTCONFIG_TEMPLATE, mainTags));
0951:            }
0952:
0953:            /*
0954:             * gets the &amp; symbol required for the client
0955:             * @return String representation of &amp;
0956:             * @throws ProviderException
0957:             */
0958:            public String getAmpersand() {
0959:                return "&amp;";
0960:            }
0961:
0962:            /**
0963:             * Overide super.processEdit() PAPI method.
0964:             */
0965:
0966:            public URL processEdit(HttpServletRequest request,
0967:                    HttpServletResponse response) throws ProviderException {
0968:
0969:                logger.entering(this .getClass().getName(), "processEdit");
0970:                String errMsg = null;
0971:                URL url = null;
0972:                String selected = null;
0973:                String editURL = null;
0974:
0975:                // Errors resulting from Edit, or Delete processing from error template
0976:                if ((request.getParameter("RulesError") != null)
0977:                        || (request.getParameter("EditRule") != null)
0978:                        || (request.getParameter("DeleteRule") != null)) {
0979:                    editURL = makeReturnURL(request, "Rules");
0980:                } else if ((request.getParameter("ViewsError") != null)
0981:                        || (request.getParameter("EditView") != null)
0982:                        || (request.getParameter("DeleteView") != null)) {
0983:                    editURL = makeReturnURL(request, "Views");
0984:                } else {
0985:                    if (request.getParameter("Submit") != null) {
0986:                        if (request.getParameter("Submit").equalsIgnoreCase(
0987:                                "Finished")) {
0988:                            //editURL = makeCallerReturnURL(request);
0989:                            if (request.getParameter("Rules") != null) {
0990:                                editURL = makeReturnURL(request, "Rules");
0991:                            } else if (request.getParameter("Views") != null) {
0992:                                editURL = makeReturnURL(request, "Views");
0993:                            } else {
0994:                                logger.log(Level.FINEST, "PSMA_CSPWPM0006");
0995:                                editURL = makeReturnURL(request);
0996:                            }
0997:                        }
0998:                    } else {
0999:                        editURL = makeReturnURL(request);
1000:                    }
1001:                }
1002:
1003:                /* 
1004:                 * RULES 
1005:                 *  Similar to views, depending on the user selection 
1006:                 *  of add & edit send back to getEdit() with a page
1007:                 *  parameter. However, if it's "delete", take care of it
1008:                 *  directly.
1009:                 */
1010:
1011:                // Add Rule
1012:                if (request.getParameter("addRule") != null) {
1013:                    editURL += "&page=AddRule&viewmode=edit";
1014:                }
1015:
1016:                // Edit Rule
1017:                if (request.getParameter("editRule") != null) {
1018:                    // This value can have multi-byte so encode it 
1019:                    String orderVal = request.getParameter("order");
1020:                    editURL += "&page=EditRule&viewmode=edit";
1021:                    editURL += "&order="
1022:                            + provider.getProviderContext().encodeURLParameter(
1023:                                    orderVal);
1024:                }
1025:
1026:                // Delete Rule
1027:                if (request.getParameter("deleteRule") != null) {
1028:                    if (request.getParameter("order") != null) {
1029:                        editURL += "&viewmode=Rules";
1030:                        url = deleteRule(request, editURL);
1031:                        return url;
1032:                    } else {
1033:                        String err = "MailViews-NoRuleValue";
1034:                        editURL += "&err=" + err;
1035:                        editURL += "&page=DeleteRule&viewmode=edit";
1036:                    }
1037:                }
1038:
1039:                // Rules configuration processing
1040:                if ((request.getParameter("action") != null)
1041:                        && (request.getParameter("Rules") != null)) {
1042:                    url = processRuleConfig(request, editURL);
1043:                    return url;
1044:                }
1045:
1046:                /* VIEWS
1047:                 *  Depending on the user selection, add a 'page' parameter 
1048:                 *  to the url to indicate the operation to be performed and 
1049:                 *  send back to getEdit()
1050:                 */
1051:
1052:                // Add View
1053:                if (request.getParameter("addView") != null) {
1054:                    editURL += "&page=AddView&viewmode=edit";
1055:                }
1056:
1057:                // Edit View
1058:                if (request.getParameter("editView") != null) {
1059:                    String orderVal = request.getParameter("order");
1060:                    editURL += "&page=EditView&viewmode=edit";
1061:                    editURL += "&order="
1062:                            + provider.getProviderContext().encodeURLParameter(
1063:                                    orderVal);
1064:                }
1065:
1066:                // Delete View
1067:                if (request.getParameter("deleteView") != null) {
1068:                    if (request.getParameter("order") != null) {
1069:                        editURL += "&viewmode=Views";
1070:                        url = deleteView(request, editURL);
1071:                        return url;
1072:                    } else {
1073:                        String err = "MailViews-NoViewValue";
1074:                        editURL += "&err=" + err;
1075:                        editURL += "&page=DeleteView&viewmode=edit";
1076:                    }
1077:                }
1078:
1079:                // Views configuration processing
1080:                if ((request.getParameter("action") != null)
1081:                        && (request.getParameter("Views") != null)) {
1082:                    url = processViewConfig(request, editURL);
1083:                    return url;
1084:                    //}
1085:                }
1086:
1087:                // View-Client processing/store
1088:                // from views.template
1089:                if ((request.getParameter("viewClient") != null)
1090:                        && (request.getParameter("addView") == null)
1091:                        && (request.getParameter("editView") == null)
1092:                        && (request.getParameter("deleteView") == null)
1093:                        && (request.getParameter("Submit")
1094:                                .equalsIgnoreCase("Finished"))) {
1095:                    //it's the final submit for views
1096:                    url = processClientViews(request, editURL);
1097:                    return url;
1098:                }
1099:
1100:                try {
1101:                    if (logger.isLoggable(Level.FINEST)) {
1102:                        String[] param = { "Return URL", editURL };
1103:                        logger.log(Level.FINEST, "PSMA_CSPWPM0001", param);
1104:                    }
1105:
1106:                    url = new URL(editURL);
1107:                } catch (MalformedURLException e) {
1108:                    logger.log(Level.SEVERE, "", e);
1109:                    throw new ProviderException(e.getMessage());
1110:                }
1111:
1112:                return (url);
1113:            } //end processEdit()
1114:
1115:            /**
1116:             * processRuleConfig() process the rule and update attribute
1117:             * <b>sunMobileAppMailViewRules</b>; Example URL looks like:
1118:             * <code>rules:///?configName=value
1119:             *         &amp;target=<flag|subject|sender|date|priority|to|cc>
1120:             *         &amp;op=<contains|doesnotcontain|is|isnt>
1121:             *         &amp;readValue=read|recent|value
1122:             * </code>
1123:             * @return String url to be returned by processEdit
1124:             * @param HttpServletRequst 
1125:             */
1126:
1127:            private URL processRuleConfig(HttpServletRequest request,
1128:                    String editURL) {
1129:                logger.entering(this .getClass().getName(), "processRuleConfig");
1130:
1131:                URL returnURL = null;
1132:                String ruleName = null;
1133:                String ruleType = null;
1134:                String action = request.getParameter("action");
1135:                String returnPage = "RulesError";
1136:
1137:                //ruleName and ruleType
1138:                ruleName = request.getParameter("ruleName");
1139:                ruleType = request.getParameter("ruleType");
1140:
1141:                if ((ruleName == null) || (ruleName.equals(""))
1142:                        || (ruleType == null) || (ruleType.equals(""))) {
1143:                    String errMsg = "MailViews-NoRuleName";
1144:                    return (getEditReturnURL(request, errMsg, returnPage));
1145:                }
1146:
1147:                Configuration ruleConfig = new Configuration();
1148:
1149:                if (action.equals("Edit")) {
1150:                    //get the rule configuration
1151:                    try {
1152:                        ruleConfig = rulesFactory.readConfiguration(ruleName,
1153:                                false, new SSOAdapterSession(request));
1154:                    } catch (Exception e) {
1155:                        logger.log(Level.INFO, "PSMA_CSPWPM0004", ruleName);
1156:                    }
1157:                } else {
1158:                    ruleName = ruleName.trim();
1159:                    ruleConfig.setConfigurationName(ruleName);
1160:                }
1161:
1162:                //check the flag and non flag cases
1163:                if (ruleType.equalsIgnoreCase("recentRead")) { // NOTE: if flag
1164:                    String op = request.getParameter("operation_recent");
1165:                    String age = request.getParameter("age");
1166:
1167:                    ruleConfig.setProperty("target", "flag");
1168:                    ruleConfig.setProperty("op", op);
1169:                    ruleConfig.setProperty("ruleValue", age);
1170:
1171:                } else if (ruleType.equalsIgnoreCase("header")) { // NOTE: not flag
1172:                    String target = request.getParameter("target");
1173:                    String op = request.getParameter("operation_header");
1174:                    String ruleValue = request.getParameter("ruleValue");
1175:
1176:                    ruleConfig.setProperty("target", target);
1177:                    ruleConfig.setProperty("op", op);
1178:
1179:                    //check if a rule value is entered
1180:                    if ((ruleValue != null) || !(ruleValue.equals(""))) {
1181:                        ruleConfig.setProperty("ruleValue", ruleValue);
1182:                    } else {
1183:                        String errMsg = "MailViews-NoRuleValue";
1184:                        return (getEditReturnURL(request, errMsg, returnPage));
1185:                    }
1186:                }
1187:
1188:                // Write the configuration
1189:                try {
1190:                    rulesFactory.writeConfiguration(ruleConfig,
1191:                            new SSOAdapterSession(request));
1192:                } catch (Exception e) {
1193:                    if (logger.isLoggable(Level.INFO)) {
1194:                        LogRecord rec = new LogRecord(Level.INFO,
1195:                                "PSMA_CSPWPM0025");
1196:                        Object[] param = { ruleConfig };
1197:                        rec.setParameters(param);
1198:                        rec.setThrown(e);
1199:                        rec.setLoggerName(logger.getName());
1200:                        logger.log(rec);
1201:                    }
1202:
1203:                    String errMsg = "MailViews-addRuleFailed";
1204:                    return (getEditReturnURL(request, errMsg, returnPage));
1205:                }
1206:
1207:                try {
1208:                    returnURL = new URL(editURL);
1209:                } catch (MalformedURLException me) {
1210:                    if (logger.isLoggable(Level.INFO)) {
1211:                        LogRecord rec = new LogRecord(Level.INFO,
1212:                                "PSMA_CSPWPM0007");
1213:                        rec.setThrown(me);
1214:                        String[] param = { editURL };
1215:                        rec.setLoggerName(logger.getName());
1216:                        logger.log(rec);
1217:                    }
1218:
1219:                    String errMsg = "MailViews-invalidURLErr";
1220:                    return (getEditReturnURL(request, errMsg, returnPage));
1221:                }
1222:
1223:                return returnURL;
1224:            } //end processRuleConfig()
1225:
1226:            /**
1227:             * deleteRule() deletes a rule and updates the attribute
1228:             * <b>sunMobileAppMailViewRules</b>
1229:             * @param String editURL indicating the edit view page url
1230:             * @param HttpServletRequst 
1231:             * @return URL to be returned by processEdit()
1232:             */
1233:
1234:            private URL deleteRule(HttpServletRequest request, String editURL) {
1235:                logger.entering(this .getClass().getName(), "deleteRule");
1236:
1237:                Configuration viewConf = new Configuration();
1238:                String ruleName = request.getParameter("order");
1239:
1240:                if (logger.isLoggable(Level.FINEST))
1241:                    logger.log(Level.FINEST, "PSMA_CSPWPM0008", ruleName);
1242:
1243:                /** check if this rule name is in any views url */
1244:                try {
1245:                    Enumeration availableViews = viewsFactory
1246:                            .getConfigurationNames(new SSOAdapterSession(
1247:                                    request));
1248:                    while (availableViews.hasMoreElements()) {
1249:                        viewConf = viewsFactory.readConfiguration(
1250:                                (String) availableViews.nextElement(), false,
1251:                                new SSOAdapterSession(request));
1252:                        String[] viewRules = viewConf
1253:                                .getPropertyArray("ruleName");
1254:
1255:                        boolean inUse = false;
1256:                        for (int j = 0; j < viewRules.length; j++) {
1257:                            if (ruleName.equals(viewRules[j])) {
1258:                                inUse = true;
1259:                                break;
1260:                            }
1261:                        }
1262:                        if (inUse) {
1263:                            // Can't delete - a view uses it
1264:                            errMsg = "MailViews-deleteRuleViewFailed";
1265:                            editURL += "&err=" + errMsg;
1266:                            editURL += "&page=DeleteRule&viewmode=edit";
1267:                            try {
1268:                                return new URL(editURL);
1269:                            } catch (MalformedURLException mf) {
1270:                                logger.log(Level.INFO, "", mf);
1271:                            }
1272:                        }
1273:                        continue;
1274:                    }
1275:                } catch (Exception e) {
1276:                    logger.log(Level.INFO, "", e);
1277:                }
1278:
1279:                // Remove the rule configuration
1280:                try {
1281:                    rulesFactory.removeConfiguration(ruleName,
1282:                            new SSOAdapterSession(request));
1283:                } catch (ConfigurationException ce) {
1284:                    logger.log(Level.INFO, "", ce);
1285:                    errMsg = "MailViews-deleteRuleFailed";
1286:                    editURL += "&err=" + errMsg;
1287:                    editURL += "&page=DeleteRule&viewmode=edit";
1288:                }
1289:
1290:                try {
1291:                    return new URL(editURL);
1292:                } catch (MalformedURLException mf) {
1293:                    logger.log(Level.INFO, "", mf);
1294:                    return null;
1295:                }
1296:            } //end deleteRule()
1297:
1298:            /**
1299:             * <b>processViewConfig()</b> stores a view url in attribute: 
1300:             * <b>sunMobileAppMailViews</b>
1301:             * URL syntax to store: 
1302:             * <b>views:///?configName=value&amp;applyAll=<true|false>&amp;ruleName=rule1..</b>
1303:             *
1304:             * @param HttpServletRequst
1305:             * @return URL to be returned by processEdit()
1306:             */
1307:
1308:            private URL processViewConfig(HttpServletRequest request,
1309:                    String editURL) throws ProviderException {
1310:                logger.entering(this .getClass().getName(), "processViewConfig");
1311:
1312:                String viewsConfigURL = null;
1313:                String errMsg = null;
1314:                URL returnURL = null;
1315:                String action = request.getParameter("action");
1316:                String returnPage = "ViewsError";
1317:
1318:                //logParams(request);
1319:
1320:                // Check to make sure viewName is entered
1321:                String viewName = request.getParameter("viewName");
1322:                if (logger.isLoggable(Level.FINEST)) {
1323:                    String[] param = { "viewName", viewName };
1324:                    logger.log(Level.FINEST, "PSMA_CSPWPM0001", param);
1325:                }
1326:
1327:                if ((viewName == null) || (viewName.trim()).equals("")) {
1328:                    errMsg = "MailViews-NoViewName";
1329:                    return (getEditReturnURL(request, errMsg, returnPage));
1330:                }
1331:
1332:                // Check to make sure the view has selected rules
1333:                String rules = request.getParameter("selectedRules");
1334:                if (logger.isLoggable(Level.FINEST)) {
1335:                    String[] param = { "viewName", viewName };
1336:                    logger.log(Level.FINEST, "PSMA_CSPWPM0001", "null");
1337:                }
1338:
1339:                if ((rules == null) || rules.equals("")) {
1340:                    errMsg = "MailViews-NoSelectedRule";
1341:                    return (getEditReturnURL(request, errMsg, returnPage));
1342:                }
1343:
1344:                Configuration viewConfig = new Configuration();
1345:
1346:                if (action.equals("Edit")) {
1347:                    // get the view configuration
1348:                    try {
1349:                        viewConfig = viewsFactory.readConfiguration(viewName,
1350:                                false, new SSOAdapterSession(request));
1351:                    } catch (Exception e) {
1352:                        logger.log(Level.INFO, "PSMA_CSPWPM0009", viewName);
1353:                    }
1354:                } else {
1355:                    viewName = viewName.trim();
1356:                    viewConfig.setConfigurationName(viewName);
1357:                }
1358:
1359:                // Set the applyAll property
1360:                if ((request.getParameter("ruleMatch") != null)
1361:                        && (request.getParameter("ruleMatch")
1362:                                .equalsIgnoreCase("all"))) {
1363:                    viewConfig.setProperty("applyAll", "true");
1364:                } else {
1365:                    viewConfig.setProperty("applyAll", "false");
1366:                }
1367:
1368:                ArrayList ruleList = new ArrayList();
1369:                Enumeration paramEnum = request.getParameterNames();
1370:                while (paramEnum.hasMoreElements()) {
1371:                    String key = String.valueOf(paramEnum.nextElement());
1372:                    String[] values = request.getParameterValues(key);
1373:                    for (int i = 0; i < values.length; i++) {
1374:                        if (key.equals("selectedRules")) {
1375:                            ruleList.add(values[i]);
1376:                        }
1377:                    }
1378:                }
1379:                String[] ruleArray = (String[]) ruleList.toArray(new String[0]);
1380:                viewConfig.setPropertyArray("ruleName", ruleArray);
1381:
1382:                // Write the configuration
1383:                try {
1384:                    viewsFactory.writeConfiguration(viewConfig,
1385:                            new SSOAdapterSession(request));
1386:                } catch (Exception e) {
1387:                    if (logger.isLoggable(Level.INFO)) {
1388:                        LogRecord rec = new LogRecord(Level.INFO,
1389:                                "PSMA_CSPWPM0010");
1390:                        Object[] param = { viewConfig };
1391:                        rec.setThrown(e);
1392:                        rec.setParameters(param);
1393:                        rec.setLoggerName(logger.getName());
1394:                        logger.log(rec);
1395:                    }
1396:
1397:                    errMsg = "MailViews-addViewFailed";
1398:                    return (getEditReturnURL(request, errMsg, returnPage));
1399:                }
1400:
1401:                // Return to manage views
1402:                try {
1403:                    returnURL = new URL(editURL);
1404:                } catch (MalformedURLException me) {
1405:                    if (logger.isLoggable(Level.INFO)) {
1406:                        LogRecord rec = new LogRecord(Level.INFO,
1407:                                "PSMA_CSPWPM0007");
1408:                        String[] param = { editURL };
1409:                        rec.setThrown(me);
1410:                        rec.setParameters(param);
1411:                        rec.setLoggerName(logger.getName());
1412:                        logger.log(rec);
1413:                    }
1414:
1415:                    errMsg = "MailViews-invalidURLErr";
1416:                    return (getEditReturnURL(request, errMsg, returnPage));
1417:                }
1418:
1419:                return returnURL;
1420:            } //end processViewConfig()
1421:
1422:            /**
1423:             * <b>deleteView()</b> deletes a view and updates the attribute
1424:             * <b>sunMobileAppMailViews</b>
1425:             * @param String editURL indicating the edit view page url
1426:             * @param HttpServletRequst 
1427:             * @return URL to be returned by processEdit()
1428:             */
1429:
1430:            private URL deleteView(HttpServletRequest request, String editURL)
1431:                    throws ProviderException {
1432:                logger.entering(this .getClass().getName(), "deleteView");
1433:
1434:                //logParams(request);
1435:
1436:                boolean inselected = false;
1437:                boolean match = false;
1438:                URL returnURL = null;
1439:                String viewStr = null;
1440:                String viewConfigURL = null;
1441:
1442:                // Get the view name to be deleted
1443:                String viewName = request.getParameter("order");
1444:                logger.log(Level.FINEST, "PSMA_CSPWPM0012", viewName);
1445:
1446:                // Next check if the view to be deleted has any client association
1447:                Set viewclientSet = null;
1448:                try {
1449:                    viewclientSet = dsameConn.getAttribute(VIEWCLIENTATTR);
1450:                } catch (Exception e) {
1451:                    logger.log(Level.SEVERE, "", e);
1452:                    throw new ProviderException(e.getMessage());
1453:                }
1454:                //Set viewclientSet = getSAALAttribute(VIEWCLIENTATTR);
1455:                if (viewclientSet != null) {
1456:                    Iterator viewclient = viewclientSet.iterator();
1457:                    while (viewclient.hasNext()) {
1458:                        String viewcl = String.valueOf(viewclient.next());
1459:                        logger.log(Level.FINEST, "PSMA_CSPWPM0013", viewcl);
1460:                        if (viewcl != null) {
1461:                            String vwname = viewcl.substring(
1462:                                    viewcl.lastIndexOf('|') + 1).trim();
1463:                            logger.log(Level.FINEST, "PSMA_CSPWPM0025", vwname);
1464:                            if (vwname.equals(viewName)) {
1465:                                inselected = true;
1466:                                logger.log(Level.FINEST, "PSMA_CSPWPM0014",
1467:                                        viewName);
1468:                                errMsg = "MailViews-deleteViewClient";
1469:                                editURL += "&err=" + errMsg;
1470:                                editURL += "&page=DeleteView&viewmode=edit";
1471:                                try {
1472:                                    return new URL(editURL);
1473:                                } catch (MalformedURLException mf) {
1474:                                    logger.log(Level.INFO, "", mf);
1475:                                }
1476:                            }
1477:                        } else
1478:                            break;
1479:                    }
1480:                }
1481:
1482:                if (!inselected) {
1483:                    // Remove the view configuration
1484:                    try {
1485:                        viewsFactory.removeConfiguration(viewName,
1486:                                new SSOAdapterSession(request));
1487:                    } catch (ConfigurationException ce) {
1488:                        logger.log(Level.INFO, "", ce);
1489:                        String errMsg = "MailViews-deleteViewFailed";
1490:                        editURL += "&err=" + errMsg;
1491:                        editURL += "&page=DeleteView&viewmode=edit";
1492:                    }
1493:                }
1494:
1495:                try {
1496:                    return new URL(editURL);
1497:                } catch (MalformedURLException me) {
1498:
1499:                    logger.log(Level.SEVERE, "", me);
1500:                    throw new ProviderException(me.getMessage());
1501:                }
1502:            } //end deleteView()
1503:
1504:            /**
1505:             * getViewEdit() displays the first mailview screen to select a 
1506:             * views for a device.
1507:             * @param HttpServletRequest http request
1508:             * @param String client name 
1509:             * @return StringBuffer containing the main view edit page
1510:             * @throws ProviderException
1511:             *
1512:             */
1513:
1514:            private StringBuffer getViewEdit(HttpServletRequest request,
1515:                    String client) throws ProviderException {
1516:                Hashtable viewHash = new Hashtable();
1517:                Hashtable avlHash = new Hashtable();
1518:                Hashtable selHash = new Hashtable();
1519:
1520:                StringBuffer selViews = new StringBuffer(0);
1521:
1522:                //Put theme tags
1523:                try {
1524:                    ProviderUtility.setDefaultPresentation(provider.getName(),
1525:                            provider.getProviderContext(), viewHash);
1526:                    ProviderUtility.setDefaultPresentation(provider.getName(),
1527:                            provider.getProviderContext(), avlHash);
1528:                    ProviderUtility.setDefaultPresentation(provider.getName(),
1529:                            provider.getProviderContext(), selHash);
1530:                } catch (ProviderContextException pce) {
1531:                    logger.log(Level.INFO, "", pce);
1532:                }
1533:
1534:                String selName = null;
1535:                String viewClient = null;
1536:                String views = null;
1537:
1538:                logger.entering(this .getClass().getName(), "getViewEdit");
1539:
1540:                viewHash.put("clientName", client);
1541:
1542:                client = request.getParameter("client");
1543:
1544:                if (logger.isLoggable(Level.FINEST)) {
1545:                    String[] param = { "client", client };
1546:                    logger.log(Level.FINEST, "PSMA_CSPWPM0001", param);
1547:                }
1548:
1549:                Set viewsSet = getSAALAttribute(VIEWCLIENTATTR, client);
1550:
1551:                // See if any of the existing client views match this client
1552:                ArrayList selList = new ArrayList();
1553:                if (viewsSet != null) {
1554:                    logger.log(Level.FINEST, "PSMA_CSPWPM0015", ""
1555:                            + viewsSet.size());
1556:                    for (Iterator l = viewsSet.iterator(); l.hasNext();) {
1557:                        selName = String.valueOf(l.next());
1558:                        selHash.put("viewName", selName);
1559:                        selList.add(selName);
1560:                        selViews.append(provider.getTemplate(
1561:                                "views-selected-options.template", selHash));
1562:                    }
1563:                    viewHash.put("selectedViews", selViews);
1564:                }
1565:
1566:                // Get available views
1567:                StringBuffer avlViews = new StringBuffer(0);
1568:                String avlName = null;
1569:
1570:                Enumeration avlConfigs = viewsFactory
1571:                        .getConfigurationNames(new SSOAdapterSession(request));
1572:                while (avlConfigs.hasMoreElements()) {
1573:                    avlName = (String) avlConfigs.nextElement();
1574:                    if (!selList.contains((String) avlName)) {
1575:                        avlHash.put("viewName", avlName);
1576:                        avlViews.append(provider.getTemplate(
1577:                                "views-options.template", avlHash));
1578:                        logger.log(Level.FINEST, "PSMA_CSPWPM0016", avlName);
1579:                    } else {
1580:                        logger.log(Level.FINEST, "PSMA_CSPWPM0017", avlName);
1581:                    }
1582:                }
1583:                viewHash.put("availableViews", avlViews);
1584:                viewHash.put("isAppHandler", appHelper.getName());
1585:
1586:                return provider.getTemplate("views.template", viewHash);
1587:            }
1588:
1589:            /**
1590:             * <b>processClientViews</b> stores the selected views for selected client 
1591:             * in <b>sunMobileAppMailViewClients</b> attribute. 
1592:             * The syntax to store:
1593:             * <b><client1>|<view_name1></b>
1594:             *
1595:             * @param HttpServletRequst
1596:             * @return URL to be returned by processEdit()
1597:             * @throws ProviderException
1598:             */
1599:
1600:            private URL processClientViews(HttpServletRequest request,
1601:                    String editURL) throws ProviderException {
1602:                logger
1603:                        .entering(this .getClass().getName(),
1604:                                "processClientViews");
1605:
1606:                //logParams(request);
1607:
1608:                String clientName = request.getParameter("client");
1609:                if (logger.isLoggable(Level.FINEST)) {
1610:                    String[] param = { "client name", clientName };
1611:                    logger.log(Level.FINEST, "PSMA_CSPWPM0001", param);
1612:                }
1613:
1614:                // Make the return url to Device Selection page
1615:                String returnURL = provider.getProviderContext().getDesktopURL(
1616:                        request);
1617:                returnURL += "?action=edit";
1618:                returnURL += "&provider=" + URLEncoder.encode(editContainer);
1619:                returnURL += "&targetprovider="
1620:                        + URLEncoder.encode(provider.getName());
1621:                returnURL += "&appPref="
1622:                        + URLEncoder.encode(appHelper.getName());
1623:                returnURL += "&viewmode=Device";
1624:                if (logger.isLoggable(Level.FINEST)) {
1625:                    String[] param = { "returnURL", returnURL };
1626:                    logger.log(Level.FINEST, "PSMA_CSPWPM0001", param);
1627:                }
1628:
1629:                // Get the set from the attribute for this client type
1630:                Set viewClientSet = getSAALAttribute(VIEWCLIENTATTR, clientName);
1631:
1632:                if (viewClientSet == null) {
1633:                    logger.log(Level.FINEST, "PSMA_CSPWPM0018");
1634:                    viewClientSet = new HashSet();
1635:                }
1636:
1637:                // Get the view selection(s) from the request
1638:                String[] selectedViews = request
1639:                        .getParameterValues("selectedViews");
1640:                if (selectedViews == null) { // i.e nothing is selected
1641:                    //So remove any existing values for this clientType
1642:                    synchronized (viewClientSet) {
1643:                        if (!viewClientSet.isEmpty()) {
1644:                            viewClientSet.clear();
1645:                        }
1646:                        try {
1647:                            setSAALAttribute(VIEWCLIENTATTR, viewClientSet,
1648:                                    clientName);
1649:                            return new URL(returnURL);
1650:                        } catch (Exception e) {
1651:                            throw new ProviderException(e.getMessage());
1652:                        }
1653:                    }
1654:                } else { // i.e selection is not null
1655:                    logger.finest("PSMA_CSPWPM0019");
1656:                    synchronized (viewClientSet) {
1657:                        if (viewClientSet.size() != 0) {
1658:                            viewClientSet.clear();
1659:                        }
1660:                        // Now add the new selected value(s)
1661:                        for (int k = 0; k < selectedViews.length; k++) {
1662:                            String viewclientURL = String
1663:                                    .valueOf(selectedViews[k]);
1664:                            if (viewClientSet.add(viewclientURL)) {
1665:                                logger.log(Level.FINEST, "PSMA_CSPWPM0020",
1666:                                        viewclientURL);
1667:                                try {
1668:                                    setSAALAttribute(VIEWCLIENTATTR,
1669:                                            viewClientSet, clientName);
1670:                                } catch (Exception ee) {
1671:                                    throw new ProviderException(ee.getMessage());
1672:                                }
1673:                            } else {
1674:                                logger.log(Level.FINEST, "PSMA_CSPWPM0022",
1675:                                        viewclientURL);
1676:                            }
1677:                        }
1678:                    }
1679:                }
1680:                try {
1681:                    return new URL(returnURL);
1682:                } catch (MalformedURLException mex) {
1683:                    logger.log(Level.SEVERE, "", mex);
1684:                    throw new ProviderException(mex.getMessage());
1685:                }
1686:            } //end processClientViews()
1687:
1688:            /**
1689:             * @return a StringBuffer containing Error Page
1690:             */
1691:            private StringBuffer getErrorMessage(HttpServletRequest request,
1692:                    String errMesg, String errPage) {
1693:                if (errMesg != null) {
1694:                    Hashtable errHash = new Hashtable();
1695:                    try {
1696:                        //put theme tags
1697:                        ProviderUtility.setDefaultPresentation(provider
1698:                                .getName(), provider.getProviderContext(),
1699:                                errHash);
1700:
1701:                        errHash.put("page", errPage);
1702:                        errHash.put("views-display-error", bundle
1703:                                .getString(errMesg));
1704:                        errHash.put("iwtDesktop-fontFace1", provider
1705:                                .getStringProperty("fontFace1", "Sans-serif"));
1706:                        errHash.put("isAppHandler", appHelper.getName());
1707:                        return provider.getTemplate(
1708:                                "views-display-error.template", errHash);
1709:
1710:                    } catch (Throwable np) {
1711:                        logger.log(Level.INFO, "", np);
1712:                        return new StringBuffer(0);
1713:                    }
1714:                } else {
1715:                    return new StringBuffer(0);
1716:                }
1717:            }
1718:
1719:            /**
1720:             * Utility methods 
1721:             * 
1722:             * Logs every parameter value from the request
1723:             * to the desktop log file
1724:             * @param HttpServletRequest
1725:             */
1726:
1727:            //    private void logParams(HttpServletRequest request) {
1728:            //        Enumeration paramEnum = request.getParameterNames();
1729:            //        debugMessage("***** ======BEGIN REQUEST PARAMS===== ******");
1730:            //        while(paramEnum.hasMoreElements()) {
1731:            //            String key = String.valueOf(paramEnum.nextElement());
1732:            //            String[] values = request.getParameterValues(key);
1733:            //            for (int i = 0; i < values.length; i++) {
1734:            //                    debugMessage(key+ " = " + values[i]);
1735:            //            }
1736:            //        }
1737:            //        debugMessage("***** ======END REQUEST PARAMS===== ******");
1738:            //    }
1739:
1740:            //    private void debugMessage(Object o) {
1741:            //        if (provider.getProviderContext().isDebugMessageEnabled()) {
1742:            //            provider.getProviderContext().debugMessage(o);
1743:            //        }
1744:            //    }
1745:            //
1746:            //    private void debugMessage(Object o, Throwable t) {
1747:            //        if (provider.getProviderContext().isDebugMessageEnabled()) {
1748:            //            provider.getProviderContext().debugMessage(o, t);
1749:            //        }
1750:            //    }
1751:            //
1752:            //
1753:            //    private void debugError(Object o, Throwable t) {
1754:            //        if (provider.getProviderContext().isDebugErrorEnabled()) {
1755:            //            provider.getProviderContext().debugError(o, t);
1756:            //        }
1757:            //    }
1758:            //
1759:            //
1760:            //    private void debugError(Object o) {
1761:            //        if (provider.getProviderContext().isDebugErrorEnabled()) {
1762:            //            provider.getProviderContext().debugError(o);
1763:            //        }
1764:            //    }
1765:
1766:            /**
1767:             * Set a DSAME string attribute using SAAL.
1768:             */
1769:            private void setSAALStringAttribute(String name, String value)
1770:                    throws IllegalStateException, MissingResourceException,
1771:                    IOException {
1772:                try {
1773:                    mailViewUserContext.setStringAttribute(serviceMap, name,
1774:                            value);
1775:                } catch (IOException e) {
1776:                    if (logger.isLoggable(Level.SEVERE)) {
1777:                        LogRecord rec = new LogRecord(Level.SEVERE,
1778:                                "PSMA_CSPWPM0022");
1779:                        String[] param = { name, value };
1780:                        rec.setParameters(param);
1781:                        rec.setThrown(e);
1782:                        rec.setLoggerName(logger.getName());
1783:                        logger.log(rec);
1784:                    }
1785:                    throw (e);
1786:                }
1787:            }
1788:
1789:            /**
1790:             * Get a DSAME Set attribute using SAAL for a specific clientType
1791:             */
1792:
1793:            private Set getSAALAttribute(String name, String clientType)
1794:                    throws IllegalStateException {
1795:                Set value = null;
1796:                try {
1797:                    value = mailViewUserContext.getAttribute(serviceMap,
1798:                            clientType, name);
1799:                } catch (Exception e) {
1800:                    if (logger.isLoggable(Level.SEVERE)) {
1801:                        LogRecord rec = new LogRecord(Level.SEVERE,
1802:                                "PSMA_CSPWPM0024");
1803:                        String[] param = { name };
1804:                        rec.setParameters(param);
1805:                        rec.setThrown(e);
1806:                        rec.setLoggerName(logger.getName());
1807:                        logger.log(rec);
1808:                    }
1809:                }
1810:                return (value);
1811:            }
1812:
1813:            /**
1814:             * Set a DSAME Set attribute using SAAL.
1815:             */
1816:
1817:            private void setSAALAttribute(String name, Set value)
1818:                    throws IllegalStateException, MissingResourceException,
1819:                    IOException {
1820:                if ((value == null) || (value.size() == 0)) {
1821:                    try {
1822:                        removeSAALAttribute(name);
1823:                    } catch (Exception ie) {
1824:                        if (logger.isLoggable(Level.SEVERE)) {
1825:                            LogRecord rec = new LogRecord(Level.SEVERE,
1826:                                    "PSMA_CSPWPM0023");
1827:                            String[] param = { name };
1828:                            rec.setParameters(param);
1829:                            rec.setThrown(ie);
1830:                            rec.setLoggerName(logger.getName());
1831:                            logger.log(rec);
1832:                        }
1833:                    }
1834:                } else {
1835:                    try {
1836:                        mailViewUserContext.setAttribute(serviceMap, name,
1837:                                value);
1838:                        mailViewUserContext.store();
1839:                    } catch (IOException e) {
1840:                        if (logger.isLoggable(Level.SEVERE)) {
1841:                            LogRecord rec = new LogRecord(Level.SEVERE,
1842:                                    "PSMA_CSPWPM0022");
1843:                            Object[] param = { name, value };
1844:                            rec.setParameters(param);
1845:                            rec.setThrown(e);
1846:                            rec.setLoggerName(logger.getName());
1847:                            logger.log(rec);
1848:                        }
1849:                        throw (e);
1850:                    }
1851:                }
1852:            }
1853:
1854:            /**
1855:             * Set a DSAME Set attribute using SAAL for a specific clientType.
1856:             */
1857:
1858:            private void setSAALAttribute(String name, Set value,
1859:                    String clientType) throws IllegalStateException,
1860:                    MissingResourceException, IOException {
1861:                if ((value == null) || (value.size() == 0)) {
1862:                    try {
1863:                        mailViewUserContext.setAttribute(serviceMap,
1864:                                clientType, name, null);
1865:                        mailViewUserContext.store();
1866:                    } catch (Exception ie) {
1867:                        if (logger.isLoggable(Level.SEVERE)) {
1868:                            LogRecord rec = new LogRecord(Level.SEVERE,
1869:                                    "PSMA_CSPWPM0023");
1870:                            String[] param = { name };
1871:                            rec.setParameters(param);
1872:                            rec.setThrown(ie);
1873:                            rec.setLoggerName(logger.getName());
1874:                            logger.log(rec);
1875:                        }
1876:                    }
1877:                } else {
1878:                    try {
1879:                        mailViewUserContext.setAttribute(serviceMap,
1880:                                clientType, name, value);
1881:                        mailViewUserContext.store();
1882:                    } catch (IOException e) {
1883:                        if (logger.isLoggable(Level.SEVERE)) {
1884:                            LogRecord rec = new LogRecord(Level.SEVERE,
1885:                                    "PSMA_CSPWPM0022");
1886:                            Object[] param = { name, value };
1887:                            rec.setParameters(param);
1888:                            rec.setThrown(e);
1889:                            rec.setLoggerName(logger.getName());
1890:                            logger.log(rec);
1891:                        }
1892:                        throw (e);
1893:                    } catch (IllegalStateException ise) {
1894:                        if (logger.isLoggable(Level.SEVERE)) {
1895:                            LogRecord rec = new LogRecord(Level.SEVERE,
1896:                                    "PSMA_CSPWPM0022");
1897:                            Object[] param = { name, value };
1898:                            rec.setParameters(param);
1899:                            rec.setThrown(ise);
1900:                            rec.setLoggerName(logger.getName());
1901:                            logger.log(rec);
1902:                        }
1903:                        throw (ise);
1904:                    } catch (MissingResourceException me) {
1905:                        if (logger.isLoggable(Level.SEVERE)) {
1906:                            LogRecord rec = new LogRecord(Level.SEVERE,
1907:                                    "PSMA_CSPWPM0022");
1908:                            Object[] param = { name, value };
1909:                            rec.setParameters(param);
1910:                            rec.setThrown(me);
1911:                            rec.setLoggerName(logger.getName());
1912:                            logger.log(rec);
1913:                        }
1914:                        throw (me);
1915:                    }
1916:
1917:                }
1918:            }
1919:
1920:            /**
1921:             * removes a DSAME attribute
1922:             */
1923:
1924:            private void removeSAALAttribute(String name)
1925:                    throws IllegalStateException, MissingResourceException,
1926:                    IOException {
1927:                try {
1928:                    mailViewUserContext.removeAttribute(serviceMap, name);
1929:                    mailViewUserContext.store();
1930:                } catch (IOException e) {
1931:                    if (logger.isLoggable(Level.SEVERE)) {
1932:                        LogRecord rec = new LogRecord(Level.SEVERE,
1933:                                "PSMA_CSPWPM0023");
1934:                        String[] param = { name };
1935:                        rec.setParameters(param);
1936:                        rec.setThrown(e);
1937:                        rec.setLoggerName(logger.getName());
1938:                        logger.log(rec);
1939:                    }
1940:                    throw (e);
1941:                }
1942:            }
1943:
1944:            /** Makes the return URL based on request object. Also appends the client.
1945:             * @return String url to be returned
1946:             * @param HttpServletRequest the request object
1947:             */
1948:
1949:            private String makeReturnURL(HttpServletRequest request) {
1950:                String client = request.getParameter("client");
1951:                String desktopURL = provider.getProviderContext()
1952:                        .getDesktopURL(request);
1953:                desktopURL += "?action=edit";
1954:                desktopURL += "&provider=" + URLEncoder.encode(editContainer);
1955:                desktopURL += "&targetprovider="
1956:                        + URLEncoder.encode(provider.getName());
1957:                desktopURL += "&appPref="
1958:                        + URLEncoder.encode(appHelper.getName());
1959:
1960:                return desktopURL;
1961:            }
1962:
1963:            private String makeReturnURL(HttpServletRequest request,
1964:                    String target) {
1965:                String desktopURL = provider.getProviderContext()
1966:                        .getDesktopURL(request);
1967:                desktopURL += "?action=edit";
1968:                desktopURL += "&provider=" + URLEncoder.encode(editContainer);
1969:                desktopURL += "&targetprovider="
1970:                        + URLEncoder.encode(provider.getName());
1971:                desktopURL += "&appPref="
1972:                        + URLEncoder.encode(appHelper.getName());
1973:                desktopURL += "&viewmode=" + target;
1974:
1975:                return desktopURL;
1976:            }
1977:
1978:            /**
1979:             * Return URL to view edit page
1980:             */
1981:
1982:            private URL getEditReturnURL(HttpServletRequest request,
1983:                    String errMsg, String returnPage) {
1984:                URL url = null;
1985:                String editURL = makeReturnURL(request, returnPage);
1986:                editURL += "&err=" + errMsg;
1987:                editURL += "&page=" + returnPage;
1988:
1989:                try {
1990:                    url = new URL(editURL);
1991:                } catch (MalformedURLException e) {
1992:                    logger.log(Level.INFO, "", e);
1993:                }
1994:                return (url);
1995:            }
1996:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.