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


001:        /*
002:         * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
003:         *
004:         * Redistribution and use in source and binary forms, with or without
005:         * modification, are permitted provided that the following conditions
006:         * are met:
007:         *
008:         * - Redistributions of source code must retain the above copyright
009:         *   notice, this list of conditions and the following disclaimer.
010:         *
011:         * - Redistribution in binary form must reproduce the above copyright
012:         *   notice, this list of conditions and the following disclaimer in
013:         *   the documentation and/or other materials provided with the
014:         *   distribution.
015:         *
016:         * Neither the name of Sun Microsystems, Inc. or the names of
017:         * contributors may be used to endorse or promote products derived
018:         * from this software without specific prior written permission.
019:         *
020:         * This software is provided "AS IS," without a warranty of any
021:         * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
022:         * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
023:         * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
024:         * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
025:         * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
026:         * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
027:         * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
028:         * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
029:         * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
030:         * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE,
031:         * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
032:         *
033:         * You acknowledge that Software is not designed, licensed or intended
034:         * for use in the design, construction, operation or maintenance of
035:         * any nuclear facility.
036:         */
037:
038:        package com.sun.portal.siebelportlet.portlet;
039:
040:        import java.util.Vector;
041:        import java.util.Hashtable;
042:        import java.util.Enumeration;
043:        import java.util.Properties;
044:        import java.util.ResourceBundle;
045:        import java.io.IOException;
046:        import java.io.Writer;
047:        import java.util.logging.*;
048:
049:        import javax.portlet.*;
050:
051:        import com.sun.portal.siebelportlet.util.*;
052:        import com.sun.portal.iwayutil.config.*;
053:        import com.sun.portal.iwayutil.sorting.*;
054:
055:        /**
056:         *
057:         * This Portlet is used to access data from the eSales module of the Siebel
058:         * CRM Application. The Portlet is used to display the customer account data.
059:         * The portlet uses the third party iWay J2EE Connectors to access the
060:         * Siebel application.
061:         *
062:         * @version 1.0
063:         * @author Deepak H P
064:         * @date 25 Feb 2005
065:         *
066:         **/
067:        public class SiebelCustomerAccountsPortlet extends GenericPortlet
068:                implements  SiebelConstants {
069:
070:            int defAccountRows = 3;
071:            String defAccountRowsStr = "3";
072:            String siebelConfigName = null;
073:            String siebelChannelName = null;
074:            Logger logger = null;
075:            Hashtable pageCache = new Hashtable();
076:            Hashtable responseCache = new Hashtable();
077:
078:            public void init(PortletConfig config) throws PortletException {
079:                super .init(config);
080:                System.out.println("Inside SiebelPortlet Initialization");
081:                initialize(config);
082:                System.out.println("Initialized SiebelPortlet ");
083:            }
084:
085:            /**
086:             * This method generates the contetnt to be shown for help
087:             **/
088:            public void doHelp(RenderRequest request, RenderResponse response)
089:                    throws PortletException, IOException {
090:
091:                debug("doHelp()", "Inside Help");
092:                response.setContentType("text/html");
093:                debug("doHelp()", "Dispatching");
094:                PortletSession session = request.getPortletSession(true);
095:                PortletContext ctx = session.getPortletContext();
096:                PortletRequestDispatcher reqDisp = ctx
097:                        .getRequestDispatcher("/jsps/SiebelPortletHelp.jsp");
098:                reqDisp.include(request, response);
099:                debug("doHelp()", "Dispatched");
100:            }
101:
102:            /**
103:             * This method generates the contetnt to be shown in the channel
104:             **/
105:            public void doEdit(RenderRequest request, RenderResponse response)
106:                    throws PortletException, IOException {
107:
108:                debug("doEdit()", "Inside Edit");
109:                response.setContentType("text/html");
110:                SiebelProcessActionUtils
111:                        .addSiebelPortletPreferencesToRequest(request);
112:                debug("doEdit()", "Dispatching");
113:                PortletSession session = request.getPortletSession(true);
114:                PortletContext ctx = session.getPortletContext();
115:                PortletRequestDispatcher reqDisp = ctx
116:                        .getRequestDispatcher("/jsps/SiebelPortletPreferences.jsp");
117:                reqDisp.include(request, response);
118:                debug("doEdit()", "Dispatched");
119:            }
120:
121:            /**
122:             * This method generates the contetnt to be shown in the channel
123:             **/
124:            public void doView(RenderRequest request, RenderResponse response)
125:                    throws PortletException, IOException {
126:
127:                String requestType = null;
128:                String query = null;
129:                String queryField = null;
130:                String queryValue = null;
131:                String linkType = null;
132:                String sortField = null;
133:                String sortOrder = null;
134:                String curSumPage = null;
135:                String curPage = null;
136:                String accountName = null;
137:                String tableSize = null;
138:                String paginationType = null;
139:                boolean toBeSorted = false;
140:                boolean toBeForwarded = false;
141:                Vector records = null;
142:                PortletSession session = request.getPortletSession(true);
143:                PortletContext ctx = session.getPortletContext();
144:                String sessionID = session.getId();
145:
146:                response.setContentType("text/html");
147:
148:                SiebelUserInfo userInfo = (SiebelUserInfo) session
149:                        .getAttribute(SESSION_USERCONFIG,
150:                                PortletSession.APPLICATION_SCOPE);
151:
152:                if (userInfo == null) {
153:                    SiebelAuthUtils.getUserInfo(request, siebelConfigName,
154:                            siebelChannelName);
155:                    String status = (String) session.getAttribute(SSOA_STATUS,
156:                            PortletSession.APPLICATION_SCOPE);
157:
158:                    if ((status != null) && (status == NO_SSOA_STATUS)) {
159:                        session.removeAttribute(SSOA_STATUS,
160:                                PortletSession.APPLICATION_SCOPE);
161:                        SiebelAccountRequestUtils.dispatchToNOSSOErrorPage(
162:                                request, response);
163:                        return;
164:                    } else {
165:                        userInfo = (SiebelUserInfo) session.getAttribute(
166:                                SESSION_USERCONFIG,
167:                                PortletSession.APPLICATION_SCOPE);
168:
169:                        if (userInfo == null) {
170:                            debug("doView()",
171:                                    "User Info Is Null, Displaying Error Page");
172:                            SiebelAccountRequestUtils
173:                                    .dispatchToConfigErrorPage(request,
174:                                            response);
175:                            SiebelAccountRequestUtils
176:                                    .dispatchToConfigLoginPage(request,
177:                                            response);
178:                            return;
179:                        }
180:                    }
181:                }
182:                debug("doView()", "Initializing");
183:                String opType = (String) session.getAttribute(
184:                        HTML_FIELD_OPERATION, PortletSession.APPLICATION_SCOPE);
185:                debug("doView()", "opType : " + opType);
186:                if ((opType != null) && (opType.equals(OPERATION_LOGIN))) {
187:                    session.removeAttribute(HTML_FIELD_OPERATION,
188:                            PortletSession.APPLICATION_SCOPE);
189:                    records = (Vector) session.getAttribute(
190:                            ACCOUNT_SUMMARY_RECORDS,
191:                            PortletSession.APPLICATION_SCOPE);
192:                    requestType = "Search";
193:                    queryField = "Name";
194:                    records = TableSorting.sortTable(records, queryField,
195:                            "DOWN");
196:                    int rowsToShow = getRowsToShow(request);
197:                    Vector cacheData = SiebelAccountRequestUtils
198:                            .setPageCacheData(records, sessionID, rowsToShow);
199:                    responseCache.put(sessionID, cacheData);
200:                    records = SiebelAccountRequestUtils.getPageCacheData(
201:                            request, responseCache, "CurrentSummaryPage",
202:                            sessionID);
203:                    request.setAttribute("SortOrder", "DOWN");
204:                    request.setAttribute("SortColumn", "Name");
205:                }
206:                requestType = request.getParameter("RequestType");
207:                curSumPage = request.getParameter("CurrentSummaryPage");
208:                curPage = request.getParameter("CurrentPage");
209:                accountName = request.getParameter("AccountName");
210:                tableSize = request.getParameter("TableSize");
211:                paginationType = request.getParameter("PaginationType");
212:
213:                debug("doView()", " RequestType " + requestType);
214:                debug("doView()", "curSumPage " + curSumPage);
215:                debug("doView()", "curPage " + curPage);
216:
217:                if (curSumPage != null) {
218:                    request.setAttribute("CurrentSummaryPage", curSumPage);
219:                }
220:
221:                if (curPage != null) {
222:                    request.setAttribute("CurrentPage", curPage);
223:                }
224:
225:                if (accountName != null) {
226:                    debug("doView()", "Setting Account Name : " + accountName);
227:                    request.setAttribute("AccountName", accountName);
228:                }
229:
230:                if (requestType == null) {
231:                    // doView might have been called for the first time.
232:                    // Need to pass the default values
233:                    queryField = "Name";
234:                    queryValue = "*";
235:                    requestType = "Search";
236:                } else {
237:                    queryField = request.getParameter("QueryField");
238:                    queryValue = request.getParameter("QueryValue");
239:
240:                    debug("doView()", "queryField = " + queryField);
241:                    debug("doView()", "queryValue = " + queryValue);
242:
243:                    if (requestType.equals("Search")) { // Request is from Search button
244:                        if (queryField.equals("All")) { // Default Search Criteria
245:                            queryField = "Name";
246:                            queryValue = "*";
247:                            requestType = "Search";
248:                        }
249:                        StringBuffer sb = new StringBuffer();
250:                        sb.append("<" + queryField + ">");
251:                        sb.append(queryValue);
252:                        sb.append("</" + queryField + ">");
253:                        query = sb.toString();
254:                        String reqStr = SiebelAccountRequestUtils
255:                                .getSiebelCustomerAccountsSummaryQuery(query);
256:                        String xmlOutput = SiebelIwayUtils
257:                                .getResponseString(reqStr);
258:                        records = SiebelResponseUtils
259:                                .getAccountSummary(xmlOutput);
260:                        records = TableSorting.sortTable(records, queryField,
261:                                "DOWN");
262:                        int rowsToShow = getRowsToShow(request);
263:                        Vector cacheData = SiebelAccountRequestUtils
264:                                .setPageCacheData(records, sessionID,
265:                                        rowsToShow);
266:                        responseCache.put(sessionID, cacheData);
267:                        records = SiebelAccountRequestUtils.getPageCacheData(
268:                                request, responseCache, "CurrentSummaryPage",
269:                                sessionID);
270:                        request.setAttribute("SortOrder", "DOWN");
271:                        request.setAttribute("SortColumn", "Name");
272:                    }
273:
274:                    if (requestType.equals("Link")) {
275:                        request.setAttribute("CurrentPage", curSumPage);
276:                        // Request is from the link.
277:                        // The request could be from the link in summary table or
278:                        // from the tabs.
279:                        linkType = request.getParameter("LinkType");
280:                        // Get the previously store record.
281:                        records = (Vector) pageCache.get(sessionID);
282:                        debug("doView()", "linkType " + linkType);
283:                        request.setAttribute("SelectedRow", queryValue);
284:                        toBeForwarded = true;
285:                    }
286:
287:                    if (requestType.equals("Sort")) {
288:                        request.setAttribute("CurrentPage", curSumPage);
289:                        String sortTable = request.getParameter("SortTable");
290:
291:                        // Get the previously store record.
292:                        records = (Vector) pageCache.get(sessionID);
293:
294:                        if (sortTable.equals("AccountSummary")) {
295:                            toBeSorted = true;
296:                            sortField = queryValue;
297:                            sortOrder = queryField;
298:                            request.setAttribute("SortOrder", sortOrder);
299:                            request.setAttribute("SortColumn", sortField);
300:                        } else {
301:                            toBeForwarded = true;
302:                            linkType = sortTable;
303:                        }
304:                    }
305:
306:                    if (requestType.equals("Paginate")) {
307:                        request.setAttribute("CurrentPage", curSumPage);
308:                        request.setAttribute("CurrentSummaryPage", curSumPage);
309:                        debug("doView()", "paginationType " + paginationType);
310:                        if (paginationType.equals("PaginateSummary")) {
311:                            if (queryField.equals("goTo")) {
312:                                queryValue = SiebelAccountRequestUtils
313:                                        .checkGoToValue(queryValue, tableSize);
314:                            }
315:                            request.setAttribute("CurrentPage", queryValue);
316:                            request.setAttribute("CurrentSummaryPage",
317:                                    queryValue);
318:                        } else {
319:                            toBeForwarded = true;
320:                            linkType = paginationType;
321:                        }
322:                        records = SiebelAccountRequestUtils.getPageCacheData(
323:                                request, responseCache, "CurrentSummaryPage",
324:                                sessionID);
325:                    }
326:
327:                    if (requestType.equals("SiebelPreferences")) {
328:                        queryField = "Name";
329:                        queryValue = "*";
330:                        requestType = "Search";
331:                        request.setAttribute("CurrentSummaryPage", "1");
332:                        request.setAttribute("CurrentPage", "1");
333:                        int rowsToShow = getRowsToShow(request);
334:                        Vector rowData = (Vector) responseCache.get(sessionID);
335:                        Vector cacheData = SiebelAccountRequestUtils
336:                                .resetPageCacheData(rowData, sessionID,
337:                                        rowsToShow);
338:                        responseCache.put(sessionID, cacheData);
339:                        records = SiebelAccountRequestUtils.getPageCacheData(
340:                                request, responseCache, "CurrentSummaryPage",
341:                                sessionID);
342:                        SiebelAccountRequestUtils.resetDetailsCache(sessionID);
343:                    }
344:                }
345:                debug("doView()", "queryField " + queryField);
346:                debug("doView()", "queryValue " + queryValue);
347:
348:                try {
349:                    if (toBeSorted) {
350:                        Vector responseData = SiebelAccountRequestUtils
351:                                .getMergedCacheData(responseCache, sessionID);
352:                        responseData = TableSorting.sortTable(responseData,
353:                                queryValue, sortOrder);
354:                        int rowsToShow = getRowsToShow(request);
355:                        Vector cacheData = SiebelAccountRequestUtils
356:                                .setPageCacheData(responseData, sessionID,
357:                                        rowsToShow);
358:                        responseCache.put(sessionID, cacheData);
359:                        records = SiebelAccountRequestUtils.getPageCacheData(
360:                                request, responseCache, "CurrentSummaryPage",
361:                                sessionID);
362:                    } else if (requestType.equals("Link")) {
363:                        records = (Vector) pageCache.get(sessionID);
364:                    }
365:
366:                    if (records == null) {
367:                        records = SiebelAccountRequestUtils.getPageCacheData(
368:                                request, responseCache, "CurrentSummaryPage",
369:                                sessionID);
370:                    }
371:                    Vector rowData = (Vector) responseCache.get(sessionID);
372:                    TablePagination.setPaginationRow(request, response,
373:                            "PaginateSummary", null, rowData.size());
374:                    request.setAttribute("SiebelAccounts", records);
375:                    pageCache.put(sessionID, records);
376:
377:                    debug("doView()", "Dispatching");
378:                    PortletRequestDispatcher reqDisp = ctx
379:                            .getRequestDispatcher("/jsps/SiebelAccountsSummary.jsp");
380:                    reqDisp.include(request, response);
381:                    debug("doView()", "Dispatched");
382:
383:                    // If the request is from the link, dispatch the request to
384:                    // utility code to display the account details.
385:                    if (toBeForwarded) {
386:                        if (curPage != null) {
387:                            request.setAttribute("CurrentPage", curPage);
388:                        }
389:                        SiebelAccountRequestUtils.displayDetails(linkType,
390:                                queryField, queryValue, request, response,
391:                                session);
392:                    }
393:                } catch (Exception ex) {
394:                    debug("doView()", "Exception is request : " + ex);
395:                }
396:            }
397:
398:            /**
399:             * This method is the entry point for all the actions on the portal channel
400:             * This method will get the form field values and passes to doView for
401:             * further processing.
402:             **/
403:            public void processAction(ActionRequest request,
404:                    ActionResponse response) throws PortletException,
405:                    IOException {
406:                debug("processAction()", "processAction : Entering ");
407:                String action = request.getParameter(HTML_FIELD_OPERATION);
408:                if ((action != null) && (action.equals(OPERATION_LOGIN))) {
409:                    SiebelAuthUtils.setUserConfig(request, siebelConfigName,
410:                            siebelChannelName);
411:                } else {
412:                    SiebelProcessActionUtils.processAction(request, response);
413:                }
414:                debug("processAction()", "processAction : Coming out ");
415:            }
416:
417:            private int getRowsToShow(RenderRequest request) {
418:                PortletPreferences prefs = request.getPreferences();
419:                String row = prefs.getValue("AccountRowPreference",
420:                        defAccountRowsStr);
421:                int retVal = 0;
422:
423:                try {
424:                    retVal = Integer.parseInt(row);
425:                } catch (Exception ex) {
426:                    retVal = defAccountRows;
427:                }
428:                if (retVal == 0) {
429:                    retVal = defAccountRows;
430:                }
431:                return retVal;
432:            }
433:
434:            private void initialize(PortletConfig config) {
435:
436:                try {
437:                    logger = SiebelLogger.getLogger();
438:                    SiebelConfigUtils.loadSiebelPortletConfiguration(config);
439:                    defAccountRowsStr = SiebelConfigUtils
440:                            .getDefaultAccountRowCount();
441:                    defAccountRows = Integer.parseInt(defAccountRowsStr);
442:                    ResourceBundle siebelConfig = null;
443:                    siebelConfig = ResourceBundle
444:                            .getBundle(SSO_SIEBEL_CONFIG_FILE_NAME);
445:                    siebelConfigName = siebelConfig
446:                            .getString(SSO_SIEBEL_CONFIG_PREF_NAME);
447:                    siebelChannelName = siebelConfig
448:                            .getString(SSO_SIEBEL_CHANNEL_PREF_NAME);
449:                } catch (Exception ex) {
450:                    debug("initialize()", "Exception in Initializing " + ex);
451:                }
452:            }
453:
454:            /**
455:             * This method will print the log the messages.
456:             **/
457:            private void debug(String methodName, String msg) {
458:                logger.log(Level.INFO, this .getClass().getName() + ":"
459:                        + methodName + ":" + msg);
460:            }
461:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.