Source Code Cross Referenced for PortalDriverServlet.java in  » Portal » Pluto » org » apache » pluto » driver » 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 » Pluto » org.apache.pluto.driver 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.pluto.driver;
018:
019:        import java.io.IOException;
020:
021:        import javax.portlet.PortletException;
022:        import javax.servlet.RequestDispatcher;
023:        import javax.servlet.ServletContext;
024:        import javax.servlet.ServletException;
025:        import javax.servlet.http.HttpServlet;
026:        import javax.servlet.http.HttpServletRequest;
027:        import javax.servlet.http.HttpServletResponse;
028:
029:        import org.apache.commons.logging.Log;
030:        import org.apache.commons.logging.LogFactory;
031:        import org.apache.pluto.PortletContainer;
032:        import org.apache.pluto.PortletContainerException;
033:        import org.apache.pluto.driver.config.DriverConfiguration;
034:        import org.apache.pluto.driver.core.PortalRequestContext;
035:        import org.apache.pluto.driver.core.PortletWindowImpl;
036:        import org.apache.pluto.driver.services.portal.PageConfig;
037:        import org.apache.pluto.driver.services.portal.PortletWindowConfig;
038:        import org.apache.pluto.driver.url.PortalURL;
039:
040:        /**
041:         * The controller servlet used to drive the Portal Driver. All requests mapped
042:         * to this servlet will be processed as Portal Requests.
043:         *
044:         * @version 1.0
045:         * @since Sep 22, 2004
046:         */
047:        public class PortalDriverServlet extends HttpServlet {
048:
049:            /** Internal Logger. */
050:            private static final Log LOG = LogFactory
051:                    .getLog(PortalDriverServlet.class);
052:
053:            /** The Portal Driver sServlet Context */
054:            private ServletContext servletContext;
055:
056:            public static final String DEFAULT_PAGE_URI = "/WEB-INF/themes/pluto-default-theme.jsp";
057:
058:            /** The portlet container to which we will forward all portlet requests. */
059:            protected PortletContainer container;
060:
061:            // HttpServlet Impl --------------------------------------------------------
062:
063:            public String getServletInfo() {
064:                return "Pluto Portal Driver Servlet";
065:            }
066:
067:            /**
068:             * Initialize the Portal Driver. This method retrieves the portlet container
069:             * instance from the servlet context scope.
070:             * @see PortletContainer
071:             */
072:            public void init() {
073:                servletContext = getServletContext();
074:                container = (PortletContainer) servletContext
075:                        .getAttribute(AttributeKeys.PORTLET_CONTAINER);
076:            }
077:
078:            /**
079:             * Handle all requests. All POST requests are passed to this method.
080:             * @param request  the incoming HttpServletRequest.
081:             * @param response  the incoming HttpServletResponse.
082:             * @throws ServletException  if an internal error occurs.
083:             * @throws IOException  if an error occurs writing to the response.
084:             */
085:            public void doGet(HttpServletRequest request,
086:                    HttpServletResponse response) throws ServletException,
087:                    IOException {
088:
089:                PortalRequestContext portalRequestContext = new PortalRequestContext(
090:                        getServletContext(), request, response);
091:
092:                PortalURL portalURL = portalRequestContext
093:                        .getRequestedPortalURL();
094:                String actionWindowId = portalURL.getActionWindow();
095:
096:                PortletWindowConfig actionWindowConfig = actionWindowId == null ? null
097:                        : PortletWindowConfig.fromId(actionWindowId);
098:
099:                // Action window config will only exist if there is an action request.
100:                if (actionWindowConfig != null) {
101:                    PortletWindowImpl portletWindow = new PortletWindowImpl(
102:                            actionWindowConfig, portalURL);
103:                    if (LOG.isDebugEnabled()) {
104:                        LOG.debug("Processing action request for window: "
105:                                + portletWindow.getId().getStringId());
106:                    }
107:                    try {
108:                        container.doAction(portletWindow, request, response);
109:                    } catch (PortletContainerException ex) {
110:                        throw new ServletException(ex);
111:                    } catch (PortletException ex) {
112:                        throw new ServletException(ex);
113:                    }
114:                    if (LOG.isDebugEnabled()) {
115:                        LOG.debug("Action request processed.\n\n");
116:                    }
117:                }
118:
119:                // Otherwise (actionWindowConfig == null), handle the render request.
120:                else {
121:                    if (LOG.isDebugEnabled()) {
122:                        LOG.debug("Processing render request.");
123:                    }
124:                    PageConfig pageConfig = getPageConfig(portalURL);
125:                    if (pageConfig == null) {
126:                        // TODO Shouldn't we throw an exception here?
127:                        LOG.error("PageConfig for render path ["
128:                                + portalURL.getRenderPath()
129:                                + "] could not be found.");
130:                    }
131:
132:                    request
133:                            .setAttribute(AttributeKeys.CURRENT_PAGE,
134:                                    pageConfig);
135:                    String uri = (pageConfig.getUri() != null) ? pageConfig
136:                            .getUri() : DEFAULT_PAGE_URI;
137:                    if (LOG.isDebugEnabled()) {
138:                        LOG.debug("Dispatching to: " + uri);
139:                    }
140:                    RequestDispatcher dispatcher = request
141:                            .getRequestDispatcher(uri);
142:                    dispatcher.forward(request, response);
143:                    if (LOG.isDebugEnabled()) {
144:                        LOG.debug("Render request processed.\n\n");
145:                    }
146:                }
147:            }
148:
149:            /**
150:             * Pass all POST requests to {@link #doGet(HttpServletRequest, HttpServletResponse)}.
151:             * @param request  the incoming servlet request.
152:             * @param response  the incoming servlet response.
153:             * @throws ServletException if an exception occurs.
154:             * @throws IOException if an exception occurs writing to the response.
155:             */
156:            public void doPost(HttpServletRequest request,
157:                    HttpServletResponse response) throws ServletException,
158:                    IOException {
159:                doGet(request, response);
160:            }
161:
162:            // Private Methods ---------------------------------------------------------
163:
164:            /**
165:             * Returns the config of the portal page to be rendered.
166:             * @param currentURL  the current portal URL.
167:             * @return the config of the portal page to be rendered.
168:             */
169:            private PageConfig getPageConfig(PortalURL currentURL) {
170:                String requestedPageId = currentURL.getRenderPath();
171:                if (LOG.isDebugEnabled()) {
172:                    LOG.debug("Rendering Portal: Requested Page: "
173:                            + requestedPageId);
174:                }
175:                return getDriverConfiguration().getPageConfig(requestedPageId);
176:            }
177:
178:            /**
179:             * Returns the portal driver configuration object.
180:             * @return the portal driver configuration object.
181:             */
182:            private DriverConfiguration getDriverConfiguration() {
183:                return (DriverConfiguration) getServletContext().getAttribute(
184:                        AttributeKeys.DRIVER_CONFIG);
185:            }
186:
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.