EMMA Coverage Report (generated Fri Sep 15 10:32:43 EDT 2006)
[all classes][org.apache.pluto.driver.core]

COVERAGE SUMMARY FOR SOURCE FILE [PortalServletRequest.java]

nameclass, %method, %block, %line, %
PortalServletRequest.java0%   (0/1)0%   (0/7)0%   (0/162)0%   (0/39)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PortalServletRequest0%   (0/1)0%   (0/7)0%   (0/162)0%   (0/39)
PortalServletRequest (HttpServletRequest, PortletWindow): void 0%   (0/1)0%   (0/15)0%   (0/5)
getContentType (): String 0%   (0/1)0%   (0/5)0%   (0/2)
getParameter (String): String 0%   (0/1)0%   (0/15)0%   (0/4)
getParameterMap (): Map 0%   (0/1)0%   (0/9)0%   (0/3)
getParameterNames (): Enumeration 0%   (0/1)0%   (0/5)0%   (0/1)
getParameterValues (String): String [] 0%   (0/1)0%   (0/7)0%   (0/1)
initParameterMap (): void 0%   (0/1)0%   (0/106)0%   (0/23)

1/*
2 * Copyright 2003,2004 The Apache Software Foundation.
3 * 
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 * 
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 * 
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.apache.pluto.driver.core;
17 
18import java.util.Collections;
19import java.util.Enumeration;
20import java.util.HashMap;
21import java.util.Iterator;
22import java.util.Map;
23 
24import javax.servlet.http.HttpServletRequest;
25import javax.servlet.http.HttpServletRequestWrapper;
26 
27import org.apache.pluto.PortletWindow;
28import org.apache.pluto.driver.url.PortalURL;
29import org.apache.pluto.driver.url.PortalURLParameter;
30 
31public class PortalServletRequest extends HttpServletRequestWrapper {
32 
33    private PortletWindow portletWindow = null;
34 
35    private PortalURL url;
36    private Map portletParameters;
37 
38    public PortalServletRequest(HttpServletRequest request,
39                                PortletWindow window) {
40        super(request);
41        this.portletWindow = window;
42 
43        url =
44        PortalEnvironment.getPortalEnvironment(request).getRequestedPortalURL();
45    }
46 
47 
48// HttpServletRequestWrapper overlay
49          
50    public java.lang.String getContentType() {
51        String contentType = super.getContentType();
52        return contentType;
53    }
54 
55// ServletRequestWrapper overlay
56 
57    public String getParameter(String name) {
58        String[] values = (String[]) this.getParameterMap().get(name);
59        if (values != null) {
60            return values[0];
61        }
62        return null;
63    }
64 
65    /**
66     * Retreive the Parameters.
67     * @return Map of parameters targeted to the window associated with this
68     *         request.
69     */
70    public Map getParameterMap() {
71        if (portletParameters == null) {
72            initParameterMap();
73        }
74        return Collections.unmodifiableMap(portletParameters);
75    }
76 
77    /**
78     * Initialize parameters for this request.  We must be careful to make sure
79     * that render parameters are only made available if they were targeted for
80     * this specific window.
81     */
82    private void initParameterMap() {
83        portletParameters = new HashMap();
84 
85        Iterator iterator = url.getParameters().iterator();
86        while (iterator.hasNext()) {
87            PortalURLParameter param = (PortalURLParameter) iterator.next();
88            String name = param.getName();
89            String[] values = param.getValues();
90            if (param.getWindowId().equals(portletWindow.getId().getStringId())) {
91                portletParameters.put(name, values);
92            }
93        }
94 
95        String id = portletWindow.getId().getStringId();
96        if (portletWindow.getId().getStringId().equals(id)) {
97            Enumeration params = super.getParameterNames();
98            while (params.hasMoreElements()) {
99                String name = params.nextElement().toString();
100                String[] values = super.getParameterValues(name);
101                if (portletParameters.containsKey(name)) {
102                    String[] temp = (String[]) portletParameters.get(name);
103                    String[] all = new String[values.length + temp.length];
104                    System.arraycopy(values, 0, all, 0, values.length);
105                    System.arraycopy(temp, 0, all, values.length, temp.length);
106                }
107                portletParameters.put(name, values);
108            }
109        }
110    }
111 
112    /**
113     * Get an enumeration which contains each of the names for which parameters
114     * exist.
115     * @return an enumeration of all names bound as parameters.
116     */
117    public Enumeration getParameterNames() {
118        return Collections.enumeration(getParameterMap().keySet());
119    }
120 
121    /**
122     * Get the values associated with the given parameter key.
123     * @param name the Parameter name used to key the parameter.
124     * @return a String[] of all values bound to the given name as a parameter.
125     */
126    public String[] getParameterValues(String name) {
127        return (String[]) getParameterMap().get(name);
128    }
129 
130}
131 
132 

[all classes][org.apache.pluto.driver.core]
EMMA 2.0.5312 (C) Vladimir Roubtsov