Source Code Cross Referenced for ServletRequestImpl.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » portal » pluto » servlet » 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 » Content Management System » apache lenya 2.0 » org.apache.cocoon.portal.pluto.servlet 
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.cocoon.portal.pluto.servlet;
018:
019:        import java.io.UnsupportedEncodingException;
020:        import java.util.Collections;
021:        import java.util.Enumeration;
022:        import java.util.HashMap;
023:        import java.util.Iterator;
024:        import java.util.Map;
025:
026:        import javax.servlet.http.HttpServletRequest;
027:        import javax.servlet.http.HttpServletRequestWrapper;
028:
029:        import org.apache.cocoon.portal.coplet.CopletInstanceData;
030:        import org.apache.cocoon.portal.pluto.PortletURLProviderImpl;
031:        import org.apache.cocoon.portal.pluto.om.PortletWindowImpl;
032:        import org.apache.pluto.om.window.PortletWindow;
033:
034:        /**
035:         * Our request wrapper.
036:         *
037:         * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
038:         * @version CVS $Id: ServletRequestImpl.java 433543 2006-08-22 06:22:54Z crossley $
039:         */
040:        public class ServletRequestImpl extends HttpServletRequestWrapper {
041:
042:            /** Cache the parameter map. */
043:            protected Map portletParameterMap;
044:
045:            /** Request object used for {@link #portletParameterMap}. */
046:            protected HttpServletRequest cachedRequest;
047:
048:            /** Original Request. */
049:            final protected HttpServletRequest originalRequest;
050:
051:            final protected PortletURLProviderImpl provider;
052:
053:            final protected PortletWindow window;
054:
055:            public ServletRequestImpl(HttpServletRequest request,
056:                    PortletURLProviderImpl provider) {
057:                this (request, provider, null);
058:            }
059:
060:            private ServletRequestImpl(HttpServletRequest request,
061:                    PortletURLProviderImpl provider, PortletWindow window) {
062:                super (request);
063:                this .provider = provider;
064:                this .window = window;
065:                this .originalRequest = request;
066:            }
067:
068:            public ServletRequestImpl getRequest(PortletWindow window) {
069:                return new ServletRequestImpl((HttpServletRequest) this 
070:                        .getRequest(), provider, window);
071:            }
072:
073:            /**
074:             * @see javax.servlet.ServletRequest#setCharacterEncoding(java.lang.String)
075:             */
076:            public void setCharacterEncoding(String arg0)
077:                    throws UnsupportedEncodingException {
078:                //this.request.setCharacterEncoding(arg0);
079:            }
080:
081:            /**
082:             * @see javax.servlet.ServletRequest#getContentType()
083:             */
084:            public String getContentType() {
085:                String contentType = "text/html";
086:                if (getCharacterEncoding() != null) {
087:                    contentType += ";" + getCharacterEncoding();
088:                }
089:                return contentType;
090:            }
091:
092:            /**
093:             * @see javax.servlet.ServletRequest#getParameter(java.lang.String)
094:             */
095:            public String getParameter(String name) {
096:                final String[] values = (String[]) this .getParameterMap().get(
097:                        name);
098:                if (values != null && values.length > 0) {
099:                    return values[0];
100:                }
101:                return null;
102:
103:            }
104:
105:            /**
106:             * @see javax.servlet.ServletRequest#getParameterMap()
107:             */
108:            public Map getParameterMap() {
109:                HttpServletRequest currentRequest = (HttpServletRequest) this 
110:                        .getRequest();
111:                if (this .portletParameterMap == null
112:                        || currentRequest != this .cachedRequest) {
113:                    this .cachedRequest = currentRequest;
114:
115:                    // get control params
116:
117:                    if (this .provider != null
118:                            && this .provider.getPortletWindow().equals(
119:                                    this .window)) {
120:
121:                        this .portletParameterMap = new HashMap();
122:
123:                        // get render parameters
124:                        Iterator i = this .provider.getParameters().entrySet()
125:                                .iterator();
126:                        while (i.hasNext()) {
127:                            Map.Entry entry = (Map.Entry) i.next();
128:                            // convert simple values to string arrays
129:                            if (entry.getValue() instanceof  String) {
130:                                this .portletParameterMap.put(entry.getKey(),
131:                                        new String[] { (String) entry
132:                                                .getValue() });
133:                            } else {
134:                                this .portletParameterMap.put(entry.getKey(),
135:                                        entry.getValue());
136:                            }
137:                        }
138:
139:                        // get request params from the original Cocoon request
140:                        // but filter all cocoon portal request parameters.
141:                        Enumeration parameters = currentRequest
142:                                .getParameterNames();
143:                        while (parameters.hasMoreElements()) {
144:                            String paramName = (String) parameters
145:                                    .nextElement();
146:                            String[] paramValues = this .getRequest()
147:                                    .getParameterValues(paramName);
148:                            String[] values = (String[]) this .portletParameterMap
149:                                    .get(paramName);
150:
151:                            if (!paramName.startsWith("cocoon-")) {
152:                                if (values != null) {
153:                                    String[] temp = new String[paramValues.length
154:                                            + values.length];
155:                                    System.arraycopy(paramValues, 0, temp, 0,
156:                                            paramValues.length);
157:                                    System.arraycopy(values, 0, temp,
158:                                            paramValues.length, values.length);
159:                                    paramValues = temp;
160:                                }
161:                                this .portletParameterMap.put(paramName,
162:                                        paramValues);
163:                            }
164:                        }
165:                    } else {
166:                        // provider is null or different window, use stored render parameters
167:                        // first do NP check
168:                        if (this .window != null
169:                                && ((PortletWindowImpl) this .window)
170:                                        .getLayout() != null) {
171:                            final CopletInstanceData cid = ((PortletWindowImpl) this .window)
172:                                    .getLayout().getCopletInstanceData();
173:                            this .portletParameterMap = (Map) cid
174:                                    .getTemporaryAttribute("render-parameters");
175:                        }
176:                    }
177:                    if (this .portletParameterMap == null) {
178:                        this .portletParameterMap = Collections.EMPTY_MAP;
179:                    }
180:                }
181:
182:                return this .portletParameterMap;
183:            }
184:
185:            /**
186:             * @see javax.servlet.ServletRequest#getParameterNames()
187:             */
188:            public Enumeration getParameterNames() {
189:                return Collections.enumeration(this .getParameterMap().keySet());
190:            }
191:
192:            /**
193:             * @see javax.servlet.ServletRequest#getParameterValues(java.lang.String)
194:             */
195:            public String[] getParameterValues(String name) {
196:                return (String[]) this .getParameterMap().get(name);
197:            }
198:
199:            /**
200:             * JST-168 PLT.16.3.3 cxxix
201:             * @see javax.servlet.ServletRequest#getProtocol()
202:             */
203:            public String getProtocol() {
204:                return null;
205:            }
206:
207:            /**
208:             * JST-168 PLT.16.3.3 cxxix
209:             * @see javax.servlet.ServletRequest#getRemoteAddr()
210:             */
211:            public String getRemoteAddr() {
212:                return null;
213:            }
214:
215:            /**
216:             * JST-168 PLT.16.3.3 cxxix
217:             * @see javax.servlet.ServletRequest#getRemoteHost()
218:             */
219:            public String getRemoteHost() {
220:                return null;
221:            }
222:
223:            /**
224:             * JST-168 PLT.16.3.3 cxxix
225:             * @see javax.servlet.http.HttpServletRequest#getRequestURL()
226:             */
227:            public StringBuffer getRequestURL() {
228:                return null;
229:            }
230:
231:            /**
232:             * JST-168 PLT.16.3.3 cxxx
233:             * @see javax.servlet.http.HttpServletRequest#getPathInfo()
234:             */
235:            public String getPathInfo() {
236:                String attr = (String) super 
237:                        .getAttribute("javax.servlet.include.path_info");
238:                return (attr != null) ? attr : super .getPathInfo();
239:            }
240:
241:            /**
242:             * JST-168 PLT.16.3.3 cxxx
243:             * @see javax.servlet.http.HttpServletRequest#getPathTranslated()
244:             */
245:            public String getPathTranslated() {
246:                // TODO: Don't know yet how to implement this. 
247:                //       A null value is a valid value. 
248:                return null;
249:            }
250:
251:            /**
252:             * JST-168 PLT.16.3.3 cxxx
253:             * @see javax.servlet.http.HttpServletRequest#getQueryString()
254:             */
255:            public String getQueryString() {
256:                String attr = (String) super 
257:                        .getAttribute("javax.servlet.include.query_string");
258:                return (attr != null) ? attr : super .getQueryString();
259:            }
260:
261:            /**
262:             * JST-168 PLT.16.3.3 cxxx
263:             * @see javax.servlet.http.HttpServletRequest#getRequestURI()
264:             */
265:            public String getRequestURI() {
266:                String attr = (String) super 
267:                        .getAttribute("javax.servlet.include.request_uri");
268:                return (attr != null) ? attr : super .getRequestURI();
269:            }
270:
271:            /**
272:             * JST-168 PLT.16.3.3 cxxx
273:             * @see javax.servlet.http.HttpServletRequest#getServletPath()
274:             */
275:            public String getServletPath() {
276:                String attr = (String) super 
277:                        .getAttribute("javax.servlet.include.servlet_path");
278:                return (attr != null) ? attr : super .getServletPath();
279:            }
280:
281:            /**
282:             * JST-168 PLT.16.3.3 cxxxi
283:             * @see javax.servlet.http.HttpServletRequest#getContextPath()
284:             */
285:            public String getContextPath() {
286:                String attr = (String) super 
287:                        .getAttribute("javax.servlet.include.context_path");
288:                return (attr != null) ? attr : super.getContextPath();
289:            }
290:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.